[Closed] Maxscript for merging in a scene
Im working on a small script to automatically load the current max model into another scene. At the moment it merges but i cant seem to get the current model to align with an object in the merged scene it brings up an error along the lines of ‘pos is undefined’
Can anyone help me out?
Also is there a simple way to uniformly scale a selected object until it is a certain height?
Thanks
Jack
max file save
p = maxfilepath
n = maxfilename
select objects
loadmaxfile("X:\\MR Studio rig\Studio_scene_MR.max")
mergemaxfile(p + n)
select all
deselect $studio
deselect $Dummy001
group selection name:"merged"
$merged.pos = $Dummy001.pos
Hi there,
I once had a similiar problem. To move a group of objects I do this:
for ob in selectedObjects where ob.parent == undefined do
(
local newTransform = ob.transform
local oldPosition = newTransform.row4
newTransform.row4 = oldPosition + [x, y, z ]
ob.transform = newTransform
--alternative: move ob [x, y, z ]
)
It moves all selected objects, but only those without parents, so that the children are not moved twice.
As for x, y, z: It would be Dummy001.pos – merged.pos, but I think there we have the same problem… but maybe you know the position of the merged group?
For the uniformly scaling, maybe calculate the scale factor like this:
scaleFactor = objectSize.z / goalHeight
where objectSize could be object.max-object.min
and then use uniform scaling with this factor?
Just some ideas… I hope I could help you!
Ill give that a go thanks. You dont happen to know how i can run the collapse util with script do you? Nothing shows in the listener
I am not sure what do you mean with “collapse util”.
To you refer to a Biped, move all mode then collapse? If so:
-- Get your biped root node
bip = getNodeByName "Name_Bip01"
--Turn on Move All Mode
bip.controller.moveAllMode = true
move bip [x,y,z]
--Make sure you collapse Move All Mode if you need to
biped.collapseMoveAllMode bip.controller
If you refer to collapse the modifier stack, I have no idea. But if you use functions like “convertToPoly”, it automatically collapses the stack. There are also snapshot-functions. This topic is already discussed in various forums.
I think there is already a thread here about this.
http://forums.cgsociety.org/showthread.php?t=735390
I have nothing to add, sorry!