USAGE
- Select one or more geometry objects
- run script
- choose from any of the below buttons
- Reset Xform - Resets selected objects XForms
- Reset Normals - applies an edit normals modifier and resets all of the normals (so that they are again controlled by smoothing groups)
- Reset Object - creates a new box object and attaches the existing mesh to it, then deletes the temporary box.. This essentially wipes all object properties. material, wire colour and pivot are all retained.
- New Scene - exports the selected geometry, creates a new scene and imports it again. deletes the FBX file when done.
-- Mixescript snippet: Fix Objects
-- attempts to correct common problems with meshes
-- USAGE
-- select the bad meshes
-- run script
-- choose any of the buttons. I recommend working top to bottom
rollout rol_FixObject "Fix Object" width:104 height:168
(
button btn_ResetXForm "Reset XForm" pos:[8,40] width:88 height:24
button btn_ResetNormals "Reset Normals" pos:[8,72] width:88 height:24
button btn_ResetObject "Reset Object" pos:[8,104] width:88 height:24
button btn_NewScene "New Scene" pos:[8,136] width:88 height:24
label lbl1 "Warning: will collapse stack" pos:[16,8] width:72 height:32
on btn_ResetXForm pressed do
(
undo on
(
objarray = getcurrentselection()
for obj in objarray do
(
ResetXform obj
ConvertTo obj Editable_poly
)
select objarray
)
)
on btn_ResetObject pressed do
(
undo on
(
max modify mode
objarray = getcurrentselection()
newsel = #{}
for i = 1 to objarray.count do
(
obj = objarray[i]
fixedobj = Box name:obj.name lengthsegs:1 widthsegs:1 heightsegs:1 length:1 width:1 height:1 mapcoords:on pos:[0,0,0] isSelected:off
fixedobj.pivot = obj.position
fixedobj.wirecolor = obj.wirecolor
fixedobj.mat = obj.mat
ConvertTo fixedobj Editable_poly
polyop.attach fixedobj obj
polyop.deleteverts fixedobj #{1..8} --delete original box
objarray[i] = fixedobj
)
select objarray
)
)
on btn_ResetNormals pressed do
(
undo on
(
max modify mode
objarray = getcurrentselection()
for obj in objarray do
(
ConvertTo obj Editable_poly
select obj
modPanel.setCurrentObject obj
polyop.setVertSelection obj #all
allverts = polyop.getVertSelection obj
allnormals = #{}
enMod = Edit_Normals ()
modPanel.addModToSelection (enMod) ui:on
enMod.ConvertVertexSelection allverts allnormals
enMod.Reset selection:allnormals
ConvertTo obj Editable_poly
)
select objarray
)
)
on btn_NewScene pressed do
(
--checks
cancel = false
if selection.count == 0 then (messagebox ("please select one or more objects"); cancel = true)
if maxfilepath == "" then (messagebox ("please save your scene first."); cancel = true)
if cancel == false then (
ContinueScript = queryBox "This will create a new scene and only copy across geometry. Unsaved changes will be lost. Continue?"
if ContinueScript then
(
exportpath = maxfilepath + maxfilename + ".FBX"
exportFile exportpath #noPrompt selectedOnly:true
actionMan.executeAction 0 "16" --new scene
--actionMan.executeAction 0 "40005" -- reset scene -switch this out for above line if you want to keep materials etc. this is essentially less aggressive.
importFile exportpath #noPrompt
deleteFile exportpath
)
)
)
)
CreateDialog rol_FixObject NewDlg

No comments:
Post a Comment