/* Tools for 3dsmax at the standard of NN4 project */ --override existing dialog try(DestroyDialog MyTimeSaviour)catch() --rollout definition rollout MyTimeSaviour "NN4EnvMaxToos(WIP)" width:209 height:304 ( button 'btn1' "Fixing Axis" pos:[107,28] width:88 height:30 align:#left button 'btn2' "Fixing Normal" pos:[11,28] width:88 height:30 align:#left button 'btn3' "Scaling 2U on Distance(wip)" pos:[14,94] width:180 height:30 align:#left button 'btn4' "Preparing UV for SP" pos:[14,130] width:180 height:30 align:#left button 'btn5' "Delete Intesect Faces" pos:[11,193] width:88 height:30 align:#left button 'btn6' "Delete Backside Faces" pos:[107,193] width:88 height:30 align:#left --button 1"fixing axis" GroupBox 'grp1' "Export Fixing" pos:[4,5] width:200 height:64 align:#left GroupBox 'grp4' "UV ADJ" pos:[7,76] width:195 height:95 align:#left GroupBox 'grp5' "Optimizing" pos:[7,176] width:195 height:60 align:#left on btn1 pressed do ( select $ rotate $ (angleaxis -90 [1,0,0]) macros.run "PolyTools" "ResetXForm" rotate $ (angleaxis 90 [1,0,0]) ) on btn2 pressed do--button 2"preparing 2U" ( select $ ( function smoothByUVShells=( clearListener(); if (getCommandPanelTaskMode() != #modify)then(--make sure we are in the modify panel section setCommandPanelTaskMode #modify; ) (--at least an object selected local obj = selection[1]; local uv = modPanel.getCurrentObject(); --modPanel.addModToSelection (Normalmodifier ()) ui:on --modPanel.addModToSelection (Normalmodifier ()) ui:on if (classof(uv) != Unwrap_UVW)then( modPanel.addModToSelection (Unwrap_UVW ()) ui:on; uv = modPanel.getCurrentObject(); ) uv.unwrap.edit(); uv.unwrap.edit(); uv.unwrap2.setTVSubObjectMode(3); local totalFaces = uv.unwrap.numberPolygons(); local faceElemArray = #(); for f=1 to totalFaces do ( faceElemArray[ f ] = 0; ) local elem = #(); --with redraw off; for f=1 to totalFaces do ( if faceElemArray[ f ] == 0 then ( uv.unwrap2.selectFaces #{ f }; uv.unwrap2.selectElement(); local elemFaces = uv.unwrap2.getSelectedFaces() as array; append elem (uv.unwrap2.getSelectedFaces()); for i in elemFaces do ( faceElemArray[ i ] = elem.count; -- Mark these vertices with their element number in vertElemArray. ) ) ) print("num shells: "+elem.count as string+"t"+totalFaces as string); modPanel.addModToSelection (Edit_Poly ()) ui:on; obj.modifiers[#Edit_Poly].autoSmoothThreshold = 180 for e in elem do( obj.modifiers[#Edit_Poly].SetSelection #Face e; obj.modifiers[#Edit_Poly].ButtonOp #Autosmooth ) macros.run "Modifier Stack" "Convert_to_Poly" ) ) smoothByUVShells(); ) --maxOps.cloneNodes $ cloneType:#copy newNodes:&nnl --select nnl --modPanel.addModToSelection (Unwrap_UVW ()) ui:on --$.modifiers[#unwrap_uvw].unwrap.setMapChannel 2 ) ) CreateDialog MyTimeSaviour