View Full Version : instance Target Spot

03-29-2012, 12:18 PM
Hi guys,
I'm trying to create instances of a "target spot" that is selected through a pickbutton but I have difficulty in creating the instances with its relative target.
Can you help? :banghead:

03-29-2012, 02:25 PM
Use "maxOps.cloneNodes".
For example, with just the spot selected, this code works :

maxOps.cloneNodes $ clonetype:#instance

03-29-2012, 04:43 PM
Thanks MrPingouin for your help
the command works perfectly
but now, how can write a different position for the new object instantiated?
I saw that there is only the "offset" parameter in the function maxOps.cloneNodes

03-29-2012, 04:48 PM
Just store the cloned nodes to an array. Then from there you can just call up those objects whenever you want and do whatever you want to them.

03-29-2012, 05:01 PM
Currently i have solved my problem in this way:

maxOps.cloneNodes SelectedOBJ clonetype:#instance newNodes:&nnl
nnl.position = [0,0,0]

Now I do not know how to control even his relative target :banghead: :banghead:

03-30-2012, 09:37 AM
The variable nnl returned by line:
maxOps.cloneNodes SelectedOBJ clonetype:#instance newNodes:&nnlis an array. It might be an array with only one element but it is still an array. So you should use:nnl[1].position = [0,0,0]to set position of the light.

Then you can change the position of the light's target with:nnl[1].target.position = [100,0,0]or if you want to set the position of the target relative to the light then:nnl[1].target.position = nnl[1].position + [100,0,0]

03-30-2012, 11:11 AM
check the full signature of clonenodes :

maxOps.CloneNodes <&node array>nodes offset:<point3> expandHierarchy:<boolean> cloneType:<enum> actualNodeList:<node array> newNodes:<node array>

The positional offset that will be applied to the cloned nodes.

so providing a point3 value will offset the clones nodes automatically!

Which means you can do really useful stuff like create an army of teapots: :-)

delete $*GridifyClone_*
t = Teapot radius:2.0 wirecolor:yellow prefix:"GridifyClone_"
select t
--specify the grid size
Ngrid = 4
Numclones = 33

for d = 1 to Numclones do
--grab the bounding box of the selection
Bounds = (selection.max- selection.min)
--calculate the offset according to the grid
offset = -[(Bounds.x * (mod d Ngrid)), (bounds.y * floor (d/Ngrid)), 0]
maxops.clonenodes (selection as array) actualNodeList:&OrigNodes newNodes:&ClonedNodes offset:offset

But obviously if you removed the first three lines and ran this with a light and target selected, it would clone them correctly with an offset. It's just that I like teapots more than I do lights.

03-30-2012, 02:04 PM
if you are using maxops.clonenodes with expandHierarchy:on you don't need to select the target. only light might be selected. the same behavior is for all nodes with defined target.

03-31-2012, 02:53 PM
Thank you all for your help :bounce: :bounce: :bounce:

CGTalk Moderation
03-31-2012, 02:53 PM
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.