[Closed] How to copy a XRef object group as instance?
Hi to all,
I’m new to maxscript and I’ve got a XRef object in my scene which I want to copy as instance. The XRef Object is a group which exists of three other objects. Imported as XRef Object and selected the group in the opened file.
when I use this operation:
newnode = instance $XRefObj
I just get a empty pink wirebox (a dummy) which has nothing in it. So when I copy the children as well and bind them to the first node:
newnode = instance $XRefObj
for subnode in $XRefObj do
(
newsubnode = instance subnode
newsubnode.parent = newnode
)
It doesn’t work because I get an dummy object of the first instance instead of a group head. The three instances of the child objects are fine but the group head is missing and I need this as the groups pivot is moved.
So how can I copy the group head of an xref object or the whole group at once? Thx for all replies!
i think u have to search to copy the path of the object not copy the node
…
i’m sorry i didn’t test what i said but i think it’s the way
i think the xref it’s look like a proxy to me
You’re probably better off using the maxOps.CloneNodes function, which retains node hierarchies/dependencies. The following should do the trick:
maxOps.CloneNodes #($XRefObj) expandHierarchy:true cloneType:#instance
Be sure to check the maxscript reference for more information about this function.
Cheers,
Martijn
Thanks Martijn! This was exactly what I was looking for. I didn’t find it when I used to search for an answer in the maxscript reference, but now I found it. Didn’t know the maxOps before
A little comment to the final code I used:
maxOps.CloneNodes $XRefObj expandHierarchy:true cloneType:#instance newNodes:&newnode
newnode[1].pos = [0,0,0]
newnode[1].rotation = (quat 0 0 0 1)
MAXScript automatically wraps the single argument passed into a temporary array, so you can use $XRefObj instead of #($XRefObj) to supply the node array. To get the new nodes in an array, just assign a new variable as reference to the newNode parameter. But when I want to move the group I have to pick the group head, the first element of the array. Then everything is working fine. Otherwise if I move the whole array every object of the group will be moved.
thanks again Martijn!