PDA

View Full Version : isvalid controller


distract
03-26-2007, 01:04 PM
Hello,

Iīm using trackView.pickTrackDlg() to let the user pick a controller and store the controller for some export later. I need to check if the controller is still valid in the scene.

Like isValidNode() or isValidObj()

The problem is: even if I delete the object containing the controller or a simple floatcontroller in trackview, the controller still exists and is valid. I believe itīs then like some kind of copy in the variable where I stored it from the trackviewPick.

At the moment Iīm checking the refs.dependents of the controller for the string "ReferenceTarget:Animatable" since that makes a difference when the controller is deleted in the scene. But I donīt have to say that this procedure feels like a really dirty way to do it. And I havenīt checked enough for exceptions and errors.

How would you check if a controller of a TrackViewPick is still valid in the scene?

thanks,
Julian

distract
03-26-2007, 01:33 PM
that didnīt work anyway. I think I could check if one of the refs.dependents is a validNode or if referenceTarget:scene (if itīs a controller in the trackview globals) but still looking for a clean way to do it...

Jon-Huhn
03-27-2007, 08:14 AM
For finding out what nodes a controller belongs to, do something like this:

fn getControllerNodes controllerRef = (
local nodeArray=for o in (refs.dependents controllerRef) where (classof (superclassof o)) == node collect o
)

Then you can just do your isValidNode check on those nodes.

This solution is derived from a response by Bobo in this thread http://forums.cgsociety.org/showthread.php?f=98&t=477330

Thanks, Bobo!

distract
03-27-2007, 08:44 AM
thanks a lot for your answer.
julian

so i think the principal is the same and itīs ok to do it that way. I used this at the moment. because I also want floats added in the globals in trackview to be true (#scene):

fn isControllerUsedInScene fcController =
(
bCheck = false
for i = 1 to (refs.dependents fcController).count do
(
objectCheck = isValidNode((refs.dependents fcController)[i])
sceneCheck = (classof (refs.dependents fcController)[i] == Scene)
if ( objectCheck ) or ( sceneCheck ) then (bCheck = true)
)
bcheck
)

CGTalk Moderation
03-27-2007, 08:44 AM
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.