Animate merge or display flag

   2906   8   2
User Avatar
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
Edited by winkel - Sept. 12, 2016 08:40:32
User Avatar
Member
1192 posts
Joined: July 2005
Offline
One way to do it.

Attachments:
sequence.hip (96.0 KB)

Dragos Stefan
producer + director @ www.dsg.ro
www.dragosstefan.ro
User Avatar
Member
217 posts
Joined: March 2006
Offline
ok that's the way I do it, if I have numbers in the name;o) I import a step file from a CAD-model with thousand different names.

Detlef
User Avatar
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.
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
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.
Edited by Enivob - Sept. 12, 2016 09:50:10

Attachments:
ap_subnet_object_pre-frame_display.hiplc (211.4 KB)

Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
217 posts
Joined: March 2006
Offline
Hi,
that's a good starting point and I'll give it a try.
Thanks

Detlef
User Avatar
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.

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)
User Avatar
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
Edited by winkel - Sept. 14, 2016 09:37:11

Attachments:
Sequenze01.hip (662.6 KB)

User Avatar
Member
1737 posts
Joined: May 2006
Online
you could skip code solutions, merge all the geometry into a single shape, and blast-isolate each piece using $F.

Attachments:
switcher.hipnc (765.6 KB)

http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
User Avatar
Member
217 posts
Joined: March 2006
Offline
Ha,
that was it! Thanks a lot.
Because I wan't to let the geometry grow by parts I just make a group with:
$N-($F*$N/200)
where 200 is the frame where all object should be visible
and just delete the group.

Detlef (now stop scripting;o)
  • Quick Links