PDA

View Full Version : Link Constraint using getnodebyname


ungoliath
05-21-2009, 02:43 PM
What am I missing in this code?

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

ZeBoxx2
05-21-2009, 02:48 PM
Boxname = getnodebyname "Box05"
Here, Boxname is a variable that refers to the node that you got from getNodeByName()

$Boxname.transform.controller.AddTarget $Box01 0
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

ungoliath
05-21-2009, 03:14 PM
Yeah, it's in a loop that reads off an excel chart.


Thanks. It works great.

ungoliath
05-21-2009, 03:54 PM
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!"
)

ungoliath
05-21-2009, 07:42 PM
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
""

ZeBoxx2
05-21-2009, 08:04 PM
BoxName = readdelimitedstring j ","
This yields a string, e.g. "MyBox12"

Box length:Xsize width:Ysize height:Zsize mapcoords:on pos:[Xpos1,Ypos1,Zpos1] isSelected:on name:BoxName
Which is fine here, because when you specify a name, it must be a string.

BoxName.transform.controller.AddTarget $BoxParent 0
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[/quote]
myBox is a variable you just created, and references the node (object) you just created.

[code]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()

PiXeL_MoNKeY
05-21-2009, 08:07 PM
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.controllerorBoxNode = getNodeByName BoxName
BoxNode.transform.controller-Eric

CGTalk Moderation
05-21-2009, 08:07 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.