Notifications
Clear all

[Closed] <Unwrap_UVW>.renderuv, 2nd UV channel and multiple objects

I’m currently setting up a quick way to render masks from 1st and 2nd UV channel when one or more objects selected. Here’s a snippet and parts of the code I use


fn confirmReset =
(
   -- function by Swordslayer:  http://discourse.techart.online/t/maxscript-modifiers-unwrap-uvw-unwrap-setmapchannel-2/4643/3 
   local hwnd = dialogMonitorOps.getWindowHandle()
   if UIAccessor.GetWindowText hwnd == "Unwrap UVW" then
   (
      uiAccessor.pressDefaultButton()
      true
   )
   else false
)
(
   modPanel.addModToSelection (Unwrap_UVW ()) ui:on;               
   UnwrapModifier = modPanel.getCurrentObject();   
                  
   if s3d_MaskUVChannel == 1 then
   (                                 
      UnwrapModifier.setMapChannel s3d_MaskUVChannel                  
   )
   else
   (
      UnwrapModifier.setMapChannel s3d_MaskUVChannel
      dialogMonitorOps.enabled = true
      dialogMonitorOps.interactive = false
      dialogMonitorOps.registerNotification confirmReset id:#unwrap_reset
      UnwrapModifier.unwrap.reset()
      dialogMonitorOps.enabled = false
      UnwrapModifier.unwrap.edit()                     
   )                           
   UnwrapModifier.renderuv_width = s3d_MaskBakingRes
   UnwrapModifier.renderuv_height = s3d_MaskBakingRes
   UnwrapModifier.renderuv_fillmode = s3d_MaskFillMode
   UnwrapModifier.renderuv_seamColor = white
   UnwrapModifier.renderuv_showframebuffer = s3d_CHK_ShowFrameBuffer.checked
   UnwrapModifier.renderuv_force2sided = false
   UnwrapModifier.renderuv_showoverlap = false
   UnwrapModifier.renderuv_fillColor = s3d_CPL_MaskColor.color
   UnwrapModifier.renderuv_edgeColor = s3d_CPL_MaskColor.color
   UnwrapModifier.renderuv_visibleedges = true
   UnwrapModifier.renderuv_invisibleedges = false
   UnwrapModifier.renderuv_seamedges = false
   UnwrapModifier.renderUV s3d_filePath   
   -- Delete Top Modifier
   deleteModifier $ 1
)


So, I already googled when I wanted to do it and stumbled upon the issue with unwrap.reset() and the resulting query window opening.
https://polycount.com/discussion/62505/max-uvw-unwrap-set-channel-open-uv-channel-broken
http://discourse.techart.online/t/maxscript-modifiers-unwrap-uvw-unwrap-setmapchannel-2/4643/2

My problem now is: It works all great if I have UV1 selected, but as soon as I select more than one object and want to render UV2, it only renders the UV2 channel of the first object in the selection array.

I kinda know a “hack” to prevent this (spawning the objects, assigning a temp material, merging, copying to UV1 eca…) but I really want to prevent this as I fear it might have a.) a big overhead and b.) would extend computation time quiet significantly.