-- maxscript copyUVWchannels -- description: this script was written with intention to ease exporting objects to cinema4d for painting and it copies UVW channels plus some additional functionality ( o = undefined from_uvw_chan = undefined to_uvw_chan = undefined backup_uvw_chan = undefined backup_material = undefined fn inicheck a = ( res = true if o == undefined then res = false try ( if (polyop.getMapSupport o from_uvw_chan) == false then res = false if classof o != Editable_Poly then res = false -------------- adding uv channel to target if (polyop.getMapSupport o to_uvw_chan) == false then (polyop.setMapSupport o to_uvw_chan true) --if (polyop.getMapSupport o backup_uvw_chan) == false and a == true then res = false ------------ adding uv channel for backup if (polyop.getMapSupport o backup_uvw_chan) == false and a == true then (polyop.setMapSupport o backup_uvw_chan true) ) catch (res = false) rollout unnamedRollout "Untitled" width:174 height:300 ( ) if res == false then messagebox "initial check failed! \n- select object to process \n- object must be editable_poly \n- check source UVW channel " return res ) fn copy_uvw_from_to obj from_uvw_channel to_uvw_channel = ( try ( polyop.setNumMapVerts obj to_uvw_channel (polyop.getNumMapVerts obj from_uvw_channel ) keep:false polyop.setNumMapFaces obj to_uvw_channel (polyop.getNumMapFaces obj from_uvw_channel) keep:false for v = 1 to (polyop.getNumMapVerts obj to_uvw_channel) do ( polyop.setMapVert obj to_uvw_channel v (polyop.getMapVert obj from_uvw_channel v) ) for f = 1 to (polyop.getNumMapFaces obj to_uvw_channel) do ( polyop.setMapFace obj to_uvw_channel f (polyop.getMapFace obj from_uvw_channel f) ) print ("UVW channel " +(from_uvw_channel as string) + " copied to channel " +(to_uvw_channel as string) + " for " + (obj.name as string)) ) catch ( print "--- error while copying UVW channels" return false ) ) copy_uvw_from_to o from_uvw_chan to_uvw_chan ----------------- main rollout ------------------ rollout aa "copyUVWchannels" width:150 height:149 ( --label l1 "copy UVW channels:" pos:[2,2] label l2 "from:" pos:[2,4] spinner sp1 "" width:45 pos:[70,4] range:[1,99,7] type:#integer label l3 "to:" pos:[2,22] spinner sp2 "" width:45 pos:[70,22] range:[1,99,1] type:#integer --label l4 "backup:" pos:[18, 40] checkbox chb1 "backup:" pos:[2,40] width:60 checked:false spinner sp3 "" width:45 pos:[70,40] range:[1,99,8] type:#integer enabled:true checkbox chb2 "assign standard mat." pos:[2,60] checked:false checkbox chb3 "backup original mat." pos:[2,78] checked:true enabled:false button btn1 "Copy UVW channels" width:115 height:35 button btn2 "Restore " width:80 height:16 toolTip:"restore original 'to:' channel and material" enabled:false on chb1 changed a do ( sp3.enabled = a if (chb1.checked == false and (chb3.checked == false or chb2.checked == false)) then btn2.enabled = false else btn2.enabled = true ) on chb2 changed a do ( chb3.enabled = a if (chb1.checked == false and (chb3.checked == false or chb2.checked == false)) then btn2.enabled = false else btn2.enabled = true ) on chb3 changed a do ( if (chb1.checked == false and chb3.checked == false) then btn2.enabled = false else btn2.enabled = true ) on btn1 pressed do ( print "------- start copying UVW channels" ----------------- initializing o = selection[1] from_uvw_chan = sp1.value to_uvw_chan = sp2.value backup_uvw_chan = sp3.value ---------------- initial check if inicheck chb1.checked == true then ( ------------ backing up uvs if chb1.checked == true then ( try ( copy_uvw_from_to o to_uvw_chan backup_uvw_chan --print ("backing up channel "+(to_uvw_chan as string)+" to channel "+ (sp3.value as string)) ) catch (print ("--- error while backing up channel " + (to_uvw_chan as string))) ) ----------- main uv channel copying copy_uvw_from_to o from_uvw_chan to_uvw_chan ----------- backing up material try ( if (chb2.checked == true and chb3.checked == true) then ( backup_material = o.material print ("material from " + (o.name as string) + " backed up") ) ) catch (print ("--- error while backing up material from " + (o.name as string))) ----------------- assigning standard material try ( if chb2.checked == true then ( sm = standard () o.material = sm print ("standard material has been assigned to " + (o.name as string) ) ) ) catch (print ("--- error while assigning standard material to " + (o.name as string))) ) ) on btn2 pressed do ( print "------- start restoring target UVW channel and original material" copy_uvw_from_to o backup_uvw_chan to_uvw_chan try (o.material = backup_material) catch (print"--- error while restoring original material") ) ) ----------------- rollout floater -------------- rf = newRolloutFloater "111cUV" 130 210 addRollout aa rf addRollout ak_about rf ak_about.open = 0 )