So you want to center all your selected objects to [0,0,0] , save them to a max file, and then set them back to their original position? If so, this should work:
objSel = selection as array
objPos = for obj in objSel collect (obj.position)
for obj in objSel do (obj.position = [0,0,0])
dirPath = "c:/temp/"
if (doesFileExist dirPath == false) do (makeDir dirPath all:true)
saveNodes objSel (dirPath + "objs.max")
for i=1 to objSel.count do (objSel[i].position = objPos[i])
If you're using the group system in max; A group is basically just an invisible node that the objects are parented to, so get all the unique groups that're selected and perform one export for each which contains all their child objects. Something like this:
origSel = selection as array
allGroups = for obj in origSel collect (obj.parent)
allGroups = makeuniquearray allGroups
dirPath = "c:/temp/"
if (doesFileExist dirPath == false) do (makeDir dirPath all:true)
for grp in allGroups do (
if grp != undefined do (
objSel = grp.children
objPos = #()
for obj in objSel do (
append objPos (obj.position)
obj.position = [0,0,0]
)
saveNodes objSel (dirPath + grp.name + ".max")
for i=1 to objSel.count do (objSel[i].position = objPos[i])
Replies
Is it possible to save each group separately, adding +1 to each next saved name?
Thanks a lot.