I am struggling a bit with the documentation to find the right methods and information regarding;
- Find if a node is animated (SRT) or not… I would expect to have a node.isAnimated() method but don't seem to find it.
- Also, I want to know if the node I have selected is a camera and can't seem to be able to filter the selection…. am I missing something?
thanks.
Python API
2913 6 1- jordibares
- Member
- 655 posts
- Joined: Feb. 2006
- Offline
- Enivob
- Member
- 2529 posts
- Joined: June 2008
- Offline
Many python objects implement a type method. You can discover the type of a node this way. t = node.type(). If you are not familiar with python dir, read up. It is a very common way to discover what options a python variable has. For instance print dir(node) would show the word ‘type’ in the list. That is how I discovered that node has a type. Also docs explain that as well.
Animation detection is fairly broad. Basically you have to come up with a rule that counts as animation then examine the node with that rule to see if it is true. What about an object merged into a SOP network, does that count? It can become complicated quickly.
So you can work backwards. Examine all the keyframes and look for nodes that match the current network you are trying to analyze. If a node has a keyframe, then it is animated.
But what about expression…? How do we detect if someone has placed a $F in any field? Does that mean we have to examine every field in every node in every network to determine if animation is present?
Animation detection is fairly broad. Basically you have to come up with a rule that counts as animation then examine the node with that rule to see if it is true. What about an object merged into a SOP network, does that count? It can become complicated quickly.
So you can work backwards. Examine all the keyframes and look for nodes that match the current network you are trying to analyze. If a node has a keyframe, then it is animated.
But what about expression…? How do we detect if someone has placed a $F in any field? Does that mean we have to examine every field in every node in every network to determine if animation is present?
Edited by Enivob - July 12, 2017 16:38:24
Using Houdini Indie 20.0
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
- pezetko
- Member
- 387 posts
- Joined: Nov. 2008
- Offline
- friedasparagus
- Member
- 402 posts
- Joined: June 2014
- Offline
Hey Jordi!
There is a hou.Node.isTimeDependent() method which may do the trick for the the first point, but there is a chance that you'll have time dependencies that have crept in through other means (Object merge SOP etc.). If that is a problem for your setup then it is back to iterating over SRT parms and testing the length of the keyframes() method.
For node type checking we're looking at either checking against node.type().name() == “cam” or node.type() == hou.objNodeTypeCategory().nodeTypes()
Hope that was what you where pondering,
Henry
There is a hou.Node.isTimeDependent() method which may do the trick for the the first point, but there is a chance that you'll have time dependencies that have crept in through other means (Object merge SOP etc.). If that is a problem for your setup then it is back to iterating over SRT parms and testing the length of the keyframes() method.
For node type checking we're looking at either checking against node.type().name() == “cam” or node.type() == hou.objNodeTypeCategory().nodeTypes()
Hope that was what you where pondering,
Henry
Henry Dean
- jordibares
- Member
- 655 posts
- Joined: Feb. 2006
- Offline
Thank you so much, I must confess I expect the API to do the hard work for me in terms of analysing if there is animation on a node, ultimately I am sure many tools will do this kind of evaluation so seems pretty standard method to build. Anyway, I will crack on.
The tip to discover the methods I didn't know so thanks… good call.
regarding the node type, I did indeed find it but seemed to return something I was not expecting.. I am confused as in other packages you have some TAG/NUMBER returned that signals the type of object. I particularly like the Softimage way where you filter your selection but I guess it is just muscle memory.
thanks a lot.
The tip to discover the methods I didn't know so thanks… good call.
regarding the node type, I did indeed find it but seemed to return something I was not expecting.. I am confused as in other packages you have some TAG/NUMBER returned that signals the type of object. I particularly like the Softimage way where you filter your selection but I guess it is just muscle memory.
thanks a lot.
- jordibares
- Member
- 655 posts
- Joined: Feb. 2006
- Offline
Thanks guys for the help… and just to keep everyone posted on the issue and how it was done…
# Get the selection
selection = hou.selectedNodes()
if len(selection) > 0: # Check if the selection contains something
for object in selection: # Loop through the selected objects
if( object.type().name() == 'cam'): # Check if the selected object is a camera
if( object.isTimeDependent() ): # Check if there is animation in it
# Do something
else:
print ( "You need to select something@)
Edited by jordibares - July 13, 2017 16:09:12
- Andy_23
- Member
- 918 posts
- Joined: March 2014
- Offline
-
- Quick Links