How to get the targets of a Lookat_constraint

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 12 December 2008   #1
How to get the targets of a Lookat_constraint

How do I select the target(or targets) of a Lookat_Constraint?

Or better yet, how do I understand this section of the help file. I understand .properties when I see them in the help. But the <rules> of methods aren't clear to me. I just don't script enough...
From the Max Help:

Quote:
LookAt_Constraint interfaces:
Interface: constraints
Methods:
<integer>getNumTargets()
Returns the number of target nodes in the target list.
<node>getNode <index>targetNumber
Returns the indexed target node.
<float>getWeight <index>targetNumber
Returns the weight of the indexed target if the targetNumber is relevant, 0.0 otherwise.
<boolean>setWeight <index>targetNumber <float>weight
Sets the weight of the indexed node specified by targetNumber. Returns True on success, False otherwise.
<boolean>appendTarget <node>target <float>weight
Appends the specified node to the list and sets its weight to the specified value. Returns True on success, False otherwise.
<boolean>deleteTarget <index>targetNumber
Deletes the indexed target. Returns True on success, False otherwise.
__________________

 
Old 12 December 2008   #2
The <rules> just tell you the type of the arguments (or, if in front of the method, the return value type).

Let's assume you have a Teapot01 with a LookAt Constraint in the Rotation track looking at 3 Spheres.

theObj = $Teapot01 --this is the host object
$Teapot:Teapot01 @ [-53.237698,71.865959,0.000000]

theController = theObj.rotation.controller --this is the rotation (LookAt) Constraint
Controller:LookAt_Constraint

--Now loop from 1 to the number of targets in the constraint and collect
--each node into an array called theTargets:

theTargets = for i = 1 to theController.getNumTargets() collect theController.getNode i
#($Sphere:Sphere01 @ [-77.946899,-10.454015,0.000000], $Sphere:Sphere02 @ [-43.879711,-0.831173,0.000000], $Sphere:Sphere03 @ [17.187794,69.950142,0.000000])

select theTargets --now all you have to do is select them
OK
__________________
Bobo
 
Old 12 December 2008   #3
WOOT!!

Thanks Bobo.

I'll be glad when this project is over so I can switch to 2009 and the new script editor and help system. Still on good ol' Max 9 for now.

So here are my meager additions for anyone who is interested.

macroscript SelectLookAtTarget 
category: "MyTools"
(
	theObjects = selection
	allTargets = #()
	for o in theObjects where classof o.rotation.controller == LookAt_Constraint do
	(
		theController = o.rotation.controller
		theTargets = for i = 1 to theController.getNumTargets() collect theController.getNode i
		join allTargets theTargets
	)
	select allTargets
)
__________________


Last edited by jonahhawk : 12 December 2008 at 09:15 AM.
 
Old 12 December 2008   #4
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 03:19 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.