[Closed] instance Target Spot
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:
Use “maxOps.cloneNodes”.
For example, with just the spot selected, this code works :
maxOps.cloneNodes $ clonetype:#instance
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
Thanks
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.
Currently i have solved my problem in this way:
nnl
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:
The variable nnl returned by line:
maxOps.cloneNodes SelectedOBJ clonetype:#instance newNodes:&nnl
is 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]
check the full signature of clonenodes :
maxOps.CloneNodes <&node array>nodes offset:<point3> expandHierarchy:<boolean> cloneType:<enum> actualNodeList:<node array> newNodes:<node array>
<point3>offset
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.
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.