ikoon Posted February 6, 2018 Share Posted February 6, 2018 tldr: I cannot work with this type of data <hou.NodeTypeCategory for Chop> please could you post an example of the if statement? I have to check, if the Network Editor is currently inside Sop, or inside Chopnet etc. My skills are not enough to make the if statement right. I tried to search, but everything failed. So this is really wrong, just for example: current_type = node.childTypeCategory() compare_type = "<hou.NodeTypeCategory for Chop>" if current_type == compare_type: print "I am inside Chopnet" I made this working workaround, but if anybody has time, please could you fix the above statement? current_label = node.childTypeCategory().label() compare_label = "Motion FX" if current_label == compare_label: print "I am inside Chopnet" Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 6, 2018 Share Posted February 6, 2018 Preamble: >>> node = hou.node('/obj/geo1') >>> node.childTypeCategory() <hou.NodeTypeCategory for Sop> >>> cat = node.childTypeCategory() Ok. The "wrong" snippet compares object to a string representation, they are different. It prints "<hou.NodeTypeCategory for Chop>" because of its __str__ or __repr__ method: >>> cat.__str__() '<hou.NodeTypeCategory for Sop>' >>> cat.__repr__() '<hou.NodeTypeCategory for Sop>' >>> str(cat) == '<hou.NodeTypeCategory for Sop>' True >>> repr(cat) == '<hou.NodeTypeCategory for Sop>' True You can compare name (or label, like you did) with corresponding string. This is probably what most people will do: >>> cat.name() == 'Sop' True You can compare Python objects directly, if you have one already or know how to make it. Here is couple of methods: >>> hou.nodeTypeCategories()['Sop'] <hou.NodeTypeCategory for Sop> >>> hou.sopNodeTypeCategory() <hou.NodeTypeCategory for Sop> >>> cat == hou.nodeTypeCategories()['Sop'] True >>> cat == hou.sopNodeTypeCategory() True if node.childTypeCategory() == hou.chopNodeTypeCategory(): # In ChopNet. 1 Quote Link to comment Share on other sites More sharing options...
ikoon Posted February 6, 2018 Author Share Posted February 6, 2018 Oh! That's how it is, now I see it clear. F1 you are my savior, thank you very very much. You really help me advance, thank you!!! Btw do you have a patreon? 1 Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 6, 2018 Share Posted February 6, 2018 I don't have it, but thanks anyway. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.