Animate merge or display flag
2906 8 2- winkel
- Member
- 217 posts
- Joined: March 2006
- Offline
Hi to all,
I have thousands of objects in a subnetwork and wan't them to display animated with $F. They should begin with object A and all other should be added.
Idea 1) combine them at sop level with a merge, but how can I animate the input of the merge-sop?
Idea 2) animate the display at obj-level, but how can I animate the display level binding on $F without doing it manually obj by obj?
Would be fine if there a solutions or other ideas;o)
Thanks
Detlef
I have thousands of objects in a subnetwork and wan't them to display animated with $F. They should begin with object A and all other should be added.
Idea 1) combine them at sop level with a merge, but how can I animate the input of the merge-sop?
Idea 2) animate the display at obj-level, but how can I animate the display level binding on $F without doing it manually obj by obj?
Would be fine if there a solutions or other ideas;o)
Thanks
Detlef
Edited by winkel - Sept. 12, 2016 08:40:32
- digitallysane
- Member
- 1192 posts
- Joined: July 2005
- Offline
- winkel
- Member
- 217 posts
- Joined: March 2006
- Offline
- Enivob
- Member
- 2536 posts
- Joined: June 2008
- Offline
You can use Python code for such a task. In this example the order is determined by when the object was added to the subnet. So first in equals first displayed and so on. The list is simply fetched by examining the children of the subnet whose type is GEO. You could sort the list by name with further coding if you like. But here is the basic framework.
When the frame changes the next object's display flag is turned on. If the frame range exceed the object count a warning message is displayed.
USER_DATA_DELIMITER = "~" def childrenOfNode(node, filter): # Return child nodes of type matching the filter (i.e. geo etc...). result = [] if node != None: for n in node.children(): t = str(n.type()) if t != None: for filter_item in filter: if (t.find(filter_item) != -1): # Filter nodes based upon passed list of strings. result.append('%s%s%s' % (n.name(), USER_DATA_DELIMITER, t)) # FORMAT: name~type. result += childrenOfNode(n, filter) return result # Update starts here. node_path = "/obj/subnet1" container_node = hou.node(node_path) if container_node != None: nodes = childrenOfNode(container_node, ["Object geo"]) l = len(nodes) # First turn all the display flags off. for (i,node) in enumerate(nodes): ary = node.split("~") if len(ary) > 0: node_candidate = "%s/%s" % (node_path, ary[0]) n = hou.node(node_candidate) if n !=None: n.setDisplayFlag(0) # Next turn on the display flags in the range a of 1 to current frame #. frame_current = int(hou.frame()) for i in range(frame_current): if i < l: node = nodes[i-1] ary = node.split("~") if len(ary) > 0: node_candidate = "%s/%s" % (node_path, ary[0]) n = hou.node(node_candidate) if n !=None: n.setDisplayFlag(1) else: print "frame range exceed subnet object count." else: print "%s not found." % subnet_name
Edited by Enivob - Sept. 12, 2016 09:50:10
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
- winkel
- Member
- 217 posts
- Joined: March 2006
- Offline
- winkel
- Member
- 217 posts
- Joined: March 2006
- Offline
Hi Enivob,
thanks a lot! I'm not a coder but I need a function, so that I can animate and model all objects at frame 1;o)
So I wrote a smaller function but do't know how to start the function each frame.
thanks a lot! I'm not a coder but I need a function, so that I can animate and model all objects at frame 1;o)
So I wrote a smaller function but do't know how to start the function each frame.
import hou import toolutils import array objArray = [] def showSequenze(node): myobj = node.path() hou.node(myobj).setSelected(False) sViewer = toolutils.sceneViewer() selected = sViewer.selectObjects('Select Objects to include into sequenze', allow_multisel = True) for i in selected: for n in i.allSubChildren(): if n.type().name() == "geo": n.setDisplayFlag(False) objArray.append(n.name()) frame_current = int(hou.frame()) for i in range(frame_current): for j in selected: path = '/obj/' + str(j) + '/' + objArray[i] print(path) hou.node(path).setDisplayFlag(True)
- winkel
- Member
- 217 posts
- Joined: March 2006
- Offline
Hi,
now I have my script and I'm wondering following situation:
1) Load the file = OK
2) turn off the display flag of the python object (don't ask me why) = nothing
… after that the script won't update each frame
Another thing is, that I find no solution to read the array only at frame one, but that is another story;o)
I hope you can help me, attached a sample file…
Detlef
now I have my script and I'm wondering following situation:
1) Load the file = OK
2) turn off the display flag of the python object (don't ask me why) = nothing
… after that the script won't update each frame
Another thing is, that I find no solution to read the array only at frame one, but that is another story;o)
I hope you can help me, attached a sample file…
Detlef
Edited by winkel - Sept. 14, 2016 09:37:11
- mestela
- Member
- 1737 posts
- Joined: May 2006
- Online
- winkel
- Member
- 217 posts
- Joined: March 2006
- Offline
-
- Quick Links