Community
3ds Max Forum
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Move Grouped Object using max script

3 REPLIES 3
Reply
Message 1 of 4
dendenny01
2649 Views, 3 Replies

Move Grouped Object using max script

I am new to max and problem that i am facing is I have objects that are grouped togother there are 3 objects a box , a frame surrounding the box which has UV map and some rivets like objects on the frame. and name this group as storage

When I try to move the grouped object using max script all the objects inside the group moves move individually rather than moving as a whole like a whole.

Is there any other possible solution to do this or a method though which i can achieve the same.

Capture1.PNG

max Script:

select $Storage
maxOps.cloneNodes (selection as array) cloneType:#instance newNodes:&nnl #nodialog
select nnl
nnl.pos =  [1,2,1];

 

Tags (3)
3 REPLIES 3
Message 2 of 4
Swordslayer
in reply to: dendenny01

You are now moving the group node and every object in the group, too. I avoid groups as they create and destroy 'invisible' nodes under the hood, anyway to answer your question, you have to get the group node and move just that. If the group you are cloning is not linked to anything nor a part of another group, it boils down to getting the top-level node, like this:

 

fn getTopNode obj =
(
	while obj.parent != undefined do
		obj = obj.parent
	obj
)

maxOps.cloneNodes $Storage cloneType:#instance newNodes:&nnl #nodialog
(getTopNode nnl[1]).pos = [1,2,1]

 If it is, I'd redesign the pipeline, first and foremost.

Message 3 of 4
dendenny01
in reply to: Swordslayer

The Object is Just moving as offset from its current postion and not moving to world corordinate

Message 4 of 4
lxyfj
in reply to: dendenny01

To move the objects having been grouped try these code:

 

If the group would been moved to [0,0,0]:

 

First select the group, then run the code twice (Note : must run it twice. I don't know why...)

 

in coordsys world $.pos = [0, 0, 0]

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report