Jump to content

FBX file - unlock all of its nodes so it's not included in file?


Recommended Posts

Hi -

 

I've imported an FBX into my scene, and I want to unlock all of the base nodes so that the entire file is referenced, rather than being baked into the project.

 

How can I do this, other than digging deep down into each and every piece of geo, and unlocking the nodes? (unchecking the red flag)

 

Thanks!

 

 

Also - How can you replace an FBX already in your scene? i.e. i'd like to move it into my HIP directory now (should have before!)

Edited by cwalrus
Link to comment
Share on other sites

Zoom way out and select all the nodes. Then zoom way in and click the Flag you want to change on a single node. All the nodes in the selection will change as well. I have used this to hide and show many bone nodes too.

Remember you can also select by node type by clicking on the Magnifying Glass icon in the network view.

Replacing the file name path would probably require a short python script. Some logic to preface each file name field with $HIP...

Edited by Atom
Link to comment
Share on other sites

Thanks mate - I thought of that, but I can't select all the sub nodes, where this red lock flag is located - do you know what I mean? 

 

Here are the main FBX nodes:

 

post-14434-0-93911400-1457721575_thumb.j

 

 

and here's a node within those nodes, which has the red "Lock" flag I'm trying to unlock:

 

post-14434-0-92460900-1457721609_thumb.j

 

 

Is there some sort of attribute spreadsheet maybe, like in Maya?

 

Or some way to expose the nodes within the nodes? like expand the entire node tree...?

 

 

Link to comment
Share on other sites

Update: 

 

So there is a way to get the list view to show the entire tree - however now I need a way to expose the entire heirarchy with one click... (rather than clicking each + ... 1000 of them)

 

That way I can then click on that "Lock" button on the right...

 

post-14434-0-89717700-1457722229_thumb.j

 

 

But seriously, this is getting ridiculous. There must be some way to automatically do this for an FBX file - this is not production-friendly!

 

Anyone?

 

Thanks for advice!

 

 

Link to comment
Share on other sites

This works on a FBX I imported from MakeHuman, it may work for you.

 

Dive inside the subnet and create a python node.

 

Paste this code into the Python node. It may take a while on a 1,000 nodes so let this single CPU process run it's course. When it is finished delete the python node or it will run again on the next update.

 

#NOTE: This code expects to run inside the root of a sub-net from a FBX import.
 
import os
 
 
# Detect the path to this subnet.
node = hou.pwd()
r = "%s" % node.allNodes
n = r.find("/")
if n != -1:
    s = r[n:-2]
    node_path = s[:-len(str(node))]
else:
    # Detection failed, set path manualy.
    node_path = r"/obj/name_of_my_fbx/"
 
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' % (n.name(), t))                          # name~type.
                    result += childrenOfNode(n, filter)
    return result
 
# Scan object geo nodes looking for File or Capture nodes inside.
nodes = childrenOfNode(hou.node(node_path),["Object geo"])
for (j,node_root) in enumerate(nodes):
    ary = node_root.split("~")
    if len(ary) > 0:
        node_parent_candidate = "%s/%s" % (node_path, ary[0])
        n = hou.node(node_parent_candidate) 
        if n !=None:
            node_type = str(n.type().name())
            if (node_type=="geo"):
                # Look inside this geo node for any file or capture nodes to modify.
                print "looking for children on node [%s]." % node_parent_candidate
                temp_nodes = childrenOfNode(n,["Sop file", "Sop capture"])
                for (i,node) in enumerate(temp_nodes):
                    print node
                    ary = node.split("~")
                    if len(ary) > 0:
                        node_candidate = "%s/%s" % (node_parent_candidate, ary[0])
                        n = hou.node(node_candidate) 
                        if n !=None:
                            node_type = str(n.type().name())
                            if ((node_type=="file") or (node_type=="capture")):
                                # This a candidate for removing the hard lock.
                                n.setHardLocked(False)
                            if (node_type=="file"):
                                # This is a candidate for re-writing the file path.
                                original_path = n.parm("file").eval()
                                file_only = os.path.basename(original_path)
                                new_path = "$HIP/geo/%s" % file_only
                                n.parm("file").set(new_path)
                                print original_path
                                print file_only
                                print new_path
Unfortunately Houdini insists on converting $HIP into the actual file path so make sure that your file is stored where you want it to be before you run this code. Edited by Atom
Link to comment
Share on other sites

DAG NABBIT! I originally imported the FBX from a directory outside of my HIP directory... 

 

So I will copy it to my HIP directory, import it freshly, replace it's usage in the file (ARG!) and then try out your script, for which I am very grateful, by the way!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...