[Closed] isvalid controller
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
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…
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!
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
)