Notifications
Clear all

[Closed] Link Constraint using getnodebyname

What am I missing in this code?

Boxname = getnodebyname “Box05”
$Boxname.transform.controller.AddTarget $Box01 0
$Boxname.transform.controller.AddTarget $Box03 79

6 Replies
1 Reply
(@zeboxx2)
Joined: 11 months ago

Posts: 0

Here, Boxname is a variable that refers to the node that you got from getNodeByName()

Here, $Boxname is a path literal, that refers to -a- node with the name “Boxname”

What you want is…

Boxname.transform.controller.AddTarget $Box01 0

So no $ in front

Alternatively, but I presume you have getNodeByName() for a reason:

$Box05.transform.controller.AddTarget $Box01 0

Yeah, it’s in a loop that reads off an excel chart.

Thanks. It works great.

Here’s my code. What am I doing wrong w/ the seperated line?

j = openfile “c:\Boxes.csv”
if (j != undefined) then
(
skiptonextline j
while not eof j do
(
sliderTime = 0
BoxName = readdelimitedstring j “,”
Xsize = readValue j
Ysize = readValue j
Zsize = readValue j
Xpos1 = readValue j
Ypos1 = readValue j
Zpos1 = readValue j
Start_Time = readValue j
End_Time = readValue j
DelXpos = readValue j
DelYpos = readValue j
DelZpos = readValue j
BoxParent = getnodebyname (readchars j 6)
Box length:Xsize width:Ysize height:Zsize mapcoords:on pos:[Xpos1,Ypos1,Zpos1] isSelected:on name:BoxName

BoxName.transform.controller.AddTarget $BoxParent 0

max set key keys
sliderTime = Start_Time
max set key keys
sliderTime = End_Time
move $ [DelXpos,DelYpos,DelZpos]
max set key keys
skiptonextline j
)
close j
)
else
(
messageBox “Open Failed” title:“Error!”
)

For some reason it worked when I had already created the link but then no dice when I’m making it from scratch. What gives?

I tried this and still get that transform is not a property of BoxName
“”
DelYpos = readValue j
DelZpos = readValue j
mojo = readchars j 6
DelTime = (End_Time – Start_Time)*.33
Box length:Xsize width:Ysize height:Zsize mapcoords:on pos:[Xpos1,Ypos1,Zpos1] isSelected:on name:BoxName
Link_Constraint ()
BoxName.transform.controller $mojo 0
“”

That is because you are trying to access the transform.controller of a string value (string values have no controllers or transform). You have assigned Boxname to a string value from the excel sheet. You need to convert that string to a node before you try to access the transform.controller. So try using

BoxNode = execute (“$”+BoxName)
BoxNode.transform.controller
or
BoxNode = getNodeByName BoxName
BoxNode.transform.controller
-Eric

This yields a string, e.g. “MyBox12”

Which is fine here, because when you specify a name, it must be a string.

But here you’re trying to access a string as if it were a node.

Your best bet would be to change the aforementioned line to:


myBox = Box length:Xsize width:Ysize height:Zsize mapcoords:on pos:[Xpos1,Ypos1,Zpos1] isSelected:on name:BoxName
myBox is a variable you just created, and references the node (object) you just created.


myBox.transform.controller.AddTarget $BoxParent 0


 Here you would be accessing .transform.etc. on that node.

Note that I think you still have to set up the appropriate controller on that node -before- you try accessing .AddTarget , as by default a node will have a Position_Rotation_Scale controller for its transform (unless you changed the defaults in the 3ds Max configuration).


myBox = Box()
$Box:Box01 @ [0.000000,0.000000,0.000000]
myBox.transform.controller
Controller:Position_Rotation_Scale
myBox.transform.controller.addTarget
– Unknown property: “addTarget” in Controller:Position_Rotation_Scale
myBox.transform.controller = Link_Constraint()
Controller:Link_Constraint
myBox.transform.controller.addTarget
addTarget()