Friday, August 7, 2009

Hierarchy selection

Currently I working on the scripts associated with various operations over hierarchical structures and what I can say is that is a real challenge :) For example, cloning hierarchy is done well then made by Max Clone tool or holding Shift key while Move, Rotate or Scale it, but what happens when you have to do it by MAXScript? Yes, sometimes requiring MAXScript, in scripted controllers for example. In this cases the result is broken hierarchy. And this is only one example (about copies), but cases are in fact a lot.

Now I'll only mention the issue of selection of hierarchies. It's useful to know that there are hot-keys for this purpose. With PageUp and PageDown we can loop in selected object hierarchy Up and Down at it levels. Ctrl + PageDown select whole objects in the tree, and this also can be done by double left mouse click over object.

In MAXScript hierarchy tree present similar to the directories tree. For example, if we have to say a box with name "Box01" and link to it as child other box ("Box02"), then the full tree will be just: $Box01/$Box02 . Well, to select all children on that box will be easy, but if the tree is too large there is "shortcut":

select $Box01/.../*

-- or

select $Box01...*

They are the same, the both work full uniform. Slight complication occurs, however, in converting the scene object to "$Box01", ie cannot just select our box and enter:

select $...*

because this code will select all scene objects. So old decision of this case was execute string:

select (execute ("$" + $.name + "...*"))

That's cool, but works slow and as I said, its old coding style.
There is in practical and fast way to select:

for i in selection do selectMore i.children

Also by this way we can work on multiple hierarchy at once.
Here seems easy, right? This is just the beginning :)

No comments:

Post a Comment

Thanks for your comment