Assigning targets to LookAt controller
Hi
This is one of the first scripted tools I try to create.
I'm working on a script for rigging repetetive LookAt systems.
The idea is to have two arrays the "HingedObject" and the "LookAtTarget"
So that when I create bunch of these I can create a "HingeObject" array and a "LookAtTarget" array, assign the Lookatconstraint and assign the target and finally keep the initial offset on all of them at once.
So I'm trying to get the array of LookAt targets but so far all I have is this.
(This is the feedback I get from the system when try to aquire the code to work with)
b = $box001 -- This is a box that I assigned a LookAt controller to
show B.transform.controller[2].LookAtConstraint -- show command returns the following
.weight (LookAt_Weight) : float array
.relative : boolean
.lookat_vector_length (Vector_Length) : float
.set_orientation : boolean
.target_axis : integer
.target_axisFlip : boolean
.upnode_axis : integer
.upnode_world : boolean
.pickUpNode (Pick_Upnode) : node
.StoUP_axis : integer
.StoUP_axisFlip : boolean
.viewline_length_abs (Viewline_Abs) : boolean
.upnode_ctrl (Upnode_Control) : integer
false
With nothing in the list
B.transform.controller[1].LookAtConstraint[1].name --returns
"Vector Length"
if I add object (targets) to the list the "Vector Length" is pushed down the array and gets replaced by "LookAt Weight 0"
Is "LookAt Weight 0" a internal variable for LookAt constraints target nodes?
If so How do I add/remove objects to the list?
It's the only array in the list of commands but I can't grab the name of the objects in the list.
How do I dig further into the workings of Max to get the info that I need?
Comments
-- Unable to convert: "EngineLookTSmall_001" to type: <node>
Here is my script so far. But I hit a snag at the end.
I want it to work like this
1. I make three selections of scene objects
(EngineLookRSmall_001-008, EngineLookTSmall_001-008, UppnodeObj_001-008)
that go into the three different arrays.
I then assign the controller but I want to make sure to assign the corresponding target and upnode So I run a filterstring to get the targetname and the current number of the OriginObj and combine them into one.
So I get -- Unable to convert: "EngineLookTSmall_001" to type:
Am I overthinking? Is there a easier way to match the two arrays?
-- THIS IS THE SCRIPT --
LAC = LookAt_Constraint ()
--Collect Rotation Object Array
OriginObj =#()
if $ != $selection then
(
OriginObj[1] = $
)
else
(
for obj in ($ as array) do
(
append OriginObj obj
)
)
--Collect Target Node Array
TargetObj = #()
if $ != $selection then
(
TargetObj[1] = $
)
else
(
for obj in ($ as array) do
(
append TargetObj obj
)
)
--Collect Upnode Array
UppnodeObj = #()
if $ != $selection then
(
UppnodeObj[1] = $
)
else
(
for obj in ($ as array) do
(
append UppnodeObj obj
)
)
-- Assign LookAt controllers, UpNodes and Targets
for n = 1 to OriginObj.count do
(
(
OriginObj[n].rotation.controller = LAC
LAC.Relative = on
TargetTemp = ((filterstring TargetObj[1].name @"_" )[1] + "_" + (filterstring OriginObj[n].name @"_")[2])
LAC.appendTarget TargetTemp 100
--LAC.pickupnode
)
)
.
You have this error becaue the TargetTemp is a string not a valid object.
Tools and Scripts for Autodesk 3dsMax
Thanks a bunch Schellicon. It
Thanks a bunch Schellicon. It got me almost all the way. I'm really new to coding so I'll try some more before I ask for more assistance.
lookat controller
http://help.autodesk.com/view/3DSMAX/2019/ENU/?guid=GUID-5ACA7739-C848-4...
down in the method section is your answer, something like:
a = box()
b = Sphere pos:[130,0,0]
d = LookAt_Constraint ()
a.rotation.controller = d
d.pickupnode = b
d.appendTarget b 100 -- add object
d.lookat_vector_length=130
d.deleteTarget 1 -- delete object