Reload FBX

   2813   2   1
User Avatar
Member
208 posts
Joined: Nov. 2010
Offline
Thinking there's an easy answer I'm missing here - I import an FBX from Modo, work on it in Houdini. FBX gets modified and re-exported from Modo (or whatever). Question is, is there an easy way to force Houdini to reload the FBX scene without having to go into each node and hit Reload on the respective File in nodes?
Thanks, Kevin
User Avatar
Member
2537 posts
Joined: June 2008
Offline
I typically just copy the material node to the clipboard to save any changes I may have made in there. Then I head up to the top level and throw the entire FBX subnet away. Then I import it again, dive inside and delete the new material node and paste in the material node on the clipboard. as long as you don't rename the materials or do extensive fixup on individual mesh items this can work.

Here is a script that you can place in a toolshelf button. You will have to manually type in the path to your imported FBX subnet. Click the button and it will search the subnet for geo files. Then it will look inside each geo nodes for File based nodes. When a File based node is located it will turn off the lock flag. At this point you should be able to save the HIP file and reopen it. Because the geometry is no longer locked the next reload would come from the revised local file. I also noticed there are locked Capture nodes as well. I am not sure how unlocking the File will affect the Capture.
# Scan a subnet looking for geo type nodes.
# Then scan inside each geo type node for a File type node.
# When File type nodes are located, turn off their Lock flag.
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))                    # name~type.
                    result += childrenOfNode(n, filter)
    return result
    
# Path to the root of the FBX subnet.
subnet_root = "/obj/name_of_FBX_subnet"    #CHANGE THIS LINE OF CODE!
root_node = hou.node(subnet_root)
if root_node != None:
    # Scan subnet for geo type nodes.
    nodes = childrenOfNode(hou.node(subnet_root),["Object geo"])
    for (i,node) in enumerate(nodes):
        ary = node.split(USER_DATA_DELIMITER)
        if len(ary) > 0:
            node_candidate = "%s/%s" % (subnet_root, ary[0])
            n = hou.node(node_candidate)
            if n != None:
                more_nodes = childrenOfNode(hou.node(node_candidate),["Sop file"])
                for (j,node_item) in enumerate(more_nodes):
                    ary = node_item.split(USER_DATA_DELIMITER)
                    if len(ary) > 0:
                        node_item_candidate = "%s/%s" % (node_candidate, ary[0])
                        m = hou.node(node_item_candidate)
                        if m != None:
                            m.setHardLocked(0)     # Use this line of code to unlock the File node.
                            #m.evalParm("reload")  # Or use this line of code to simply click the Reload Geometry button instead.
Edited by Enivob - Oct. 9, 2016 11:57:30
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
208 posts
Joined: Nov. 2010
Offline
Thanks Enivob, that's a handy script. Much appreciated, Kevin
  • Quick Links