View Full Version : Problems to Manipulate GROUPs ?!
12-06-2008, 10:19 PM
I have never participated at this section before, so I hope
you all could be kind with me, I´m pretty sure I can also
give some cool info.
Ok, I´m doing a small job, and I have to populate a Brigde with
some cars, the cars have to roll the wheels and move at
I have done a object placer, that respect the surface contour.
I was wondering if I could have for example 5 different car models
each car set would have a 1 Chassis and 4 wheels, I would like
to place randomly those cars at the bridge surface.
The problem is, If I Attach the wheels to be a single mesh, I lost
the wheel spin animation. So it´s not a solution...
If I just bind the wheels to the car body (chassis) , I have problems
to copy others cars instances because the hierarchycal links are lost.
I was wondering if I can just create a Group named for example "MUSTANG"
and this group contains the mustang car body and wheels... but my problem
is that maxscript seems to treat the Group as a special selection... I mean
It´s not possible to use $MUSTANG.pos to get or set the position, and
also copy the entire group...
How to solve this problem ? how to easly copy and place a group of object ?
Thank you a lot
12-08-2008, 01:54 PM
When you create a group like you have done then the selection (if the group is closed) will count as the group dummy helper and all the objects within the group. i.e the Grouphead which is the dummy helper and all its children.
Any adjustment you make to the transform of the Group Head dummy helper will effect all its children, so it is important that you isolate the Dummy and just make adjustments to that node.
To do this from a selection you could use code like:
Leaders = for o in selection where ((o.parent == undefined or isopengroupmember o) and (not isOpenGroupHead o)) collect o
--Please Shout if anyone can think of a better/safer way to do this
This will return all the group heads of top level groups in your selection into an array. Adjust as you need to. It does this by disgarding anything that has a parent, or is a open group head. Search for "Group-related methods" in the max script reference.
Once you have the group leader you can position and adjust tranforms as you want. If you then want to copy the entire Group you have to use another command called:
maxops.cloneNodes <&node array>nodes offset:<point3> expandHierarchy:<boolean> cloneType:<enum> actualNodeList:<node array> newNodes:<node array>
This is very useful since you can state whether you want to instance or copy, you can apply a transformation offset. When working with a closed group, pass the command the group head dummy helper and make sure that expandHierarchy:true, as this will ensure that the children are copied properly. To then identify the new nodes you have to make sure that you pass a reference to the new array without initiliasing. I.e newNodes:&CopiedNodes
Look at the help section for this command for details. Hopefully this will get you started though.
Give us a shout if you get stuck.
12-09-2008, 09:59 AM
Hi Rich !
Thank you a lot for your help ! It was very useful ! although I have read it late, I managed my problem using a other approch, not so cool as yours... I did the following :
TO script work, each master car object that will be cloned has to be at the following structure : 5 Objects : 1 car Body, and 4 Wheels... each whell has to be a car Body child.
After run the script, the user has to select only the carbodys and click the button...
I have a function associated with this button that do the following :
Get the selection made an array selection with all entrys, after I use this :
allchildselection = for s in Geometry where (s.parent != undefined) collect s
At this line I choose all objects that have a parent object.
And now using the following code I search at the preview selection who is
the parent of each object. So, I create an Array of array called "ListaCarrosMatrizes"
so, each entry at this array, is another array using the following format :
position  = Car body
positions  to  = wheels
for obj in ObjetoParticulas do
childselection = for u in allchildselection where (u.parent == obj) collect u
tempselection = #()
tempselection = obj
y = 2
for o in childselection do
tempselection[y] = o
y= y + 1
ListaCarrosMatrizes[idx] = tempselection
idx = idx + 1
Ok...now i have the objects arranged and separated in a array, every time I
want to copy it, I do the following :
I find at the array the element to be duplicated, and do the following :
TEMP_Lataria = copy ListaCarrosMatrizes [IndiceParticula] 
TEMP_Roda01 = copy ListaCarrosMatrizes [IndiceParticula] 
TEMP_Roda02 = copy ListaCarrosMatrizes [IndiceParticula] 
TEMP_Roda03 = copy ListaCarrosMatrizes [IndiceParticula] 
TEMP_Roda04 = copy ListaCarrosMatrizes [IndiceParticula] 
TEMP_Dummy = point centermarker:false axistripod:false cross:true box:true constantscreensize:false size:3
TEMP_Dummy.pos = TEMP_Lataria.pos
TEMP_Roda01.parent = TEMP_Dummy
TEMP_Roda02.parent = TEMP_Dummy
TEMP_Roda03.parent = TEMP_Dummy
TEMP_Roda04.parent = TEMP_Dummy
TEMP_Lataria.parent = TEMP_Dummy
TEMP_Dummy.pos = BC
TEMP_Dummy.dir = NormaldaFace
Thank you a Lot !
12-09-2008, 09:59 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.