Notifications
Clear all
[Closed] Find all LookAt Constraints
Feb 09, 2016 8:28 am
I’m trying to find all LookAt Constraints in the scene. The way I do it now is like this:
--Variable to store the constraints
resultConstraints = #()
--For each object in the scene
for obj in objects as array do
(
--Exclude stuff without a rotation property (tapers etc)
if ((getPropNames obj as array).count > 3) do
(
--If the object's rotation controller is a rotation list
if (obj.rotation.controller as string == "Controller:Rotation_List") do
(
--If the active rotation controller is a LookAt Constraint
if (obj.rotation.controller.getName(obj.rotation.controller.getActive()) == "LookAt Constraint") do
(
appendIfUnique resultConstraints obj.rotation.controller.LookAt_Constraint.controller
)
)
)
)
The problem is that, first off, it’s messy. Also, I don’t know how to exclude nodes that doesn’t have rotation (tapers, camera etc). I’ve tried to do this by counting the properties, however it doesn’t work for cameras. I’m guessing there’s a better way to do this?
Any tips on this? Is it possible to just list all nodes of a certain type? I know that “Helpers”, “Lights”, “Geometry” will list all nodes of those specific types, but I can’t find a similar variable for “Constraints”. Is there one?
3 Replies
1 Reply
Hah, ok that was simpler! Thanks! One question regarding this, is it possible to get the name of the object for each constraint?