a max script about resetXForm

LuRenJia

05-04-2007 20:04:52

hi guys.

i wrote the max script to "ResetPivot and ResetXForm " all of the geometry in a scene. i found it's useful, maybe someone need it too.


fn isNormalFliped pt1 pt2 =
(
for i = 1 to pt1.count do
if (length (pt1[i] - pt2[i])) > 0.0001 then return true
return false
)

fn doResetXForm obj =
(
if obj == undefined or ((classOf obj != Editable_Mesh) and (classOf obj != Editable_Poly)) then return ok
local oldNormal = #()
for i=1 to obj.numFaces do
oldNormal[i] = getFaceNormal obj i
ResetPivot obj
ResetXForm obj
local newNormal = #()
for i=1 to obj.numFaces do
newNormal[i] = getFaceNormal obj i
if(isNormalFliped oldNormal newNormal) then
meshOp.flipNormals obj #{1..obj.numFaces}
update obj
)

for ent in geometry do
doResetXForm ent
messageBox "done!"

Lioric

06-04-2007 16:37:23

Excellent job :) I will add this to the main site articles as this will be helpful for other users

ilyh76

29-04-2007 04:52:14

I have Max 7.0SP1 and had to made several modifications to get it to work


fn isNormalFliped pt1 pt2 =
(
for i = 1 to pt1.count do
if (length (pt1[i] - pt2[i])) > 0.0001 then return true
return false
)

fn doResetXForm obj =
(
if obj == undefined or ((classOf obj != Editable_Mesh) and (classOf obj != Editable_Poly)) then return ok
local oldNormal = #()
for i=1 to obj.numFaces do
oldNormal[i] = polyop.getFaceNormal obj i
ResetPivot obj
ResetXForm obj
local newNormal = #()
for i=1 to obj.numFaces do
newNormal[i] = polyop.getFaceNormal obj i
if(isNormalFliped oldNormal newNormal) then
polyop.flipNormals obj #{1..obj.numFaces}
update obj
)

for ent in geometry do
doResetXForm ent
messageBox "done!"


Hope this will help others.