pushpathadam Posted June 8, 2010 Share Posted June 8, 2010 Hi, how would one find an attribute by type instead of by name? I'm writing a short python script to dump out a list of all the external files used in a hip file. In most contexts the node type I need is called "file" and the attribute I evaluate is also called "file" or "filename1". Pretty trivial. However in shops a texture/environment/whatever map can be called anything you want ..the only consistent hook I have is that the attribute is of type "file". If I get a list of all the node's params.. paramlist = node.parms() for param in paramlist: paramtype = param.type() I was hoping to do the above, same way param.name() works but no such luck. Is there a way to go about doing this? thanks Tom Quote Link to comment Share on other sites More sharing options...
symek Posted June 8, 2010 Share Posted June 8, 2010 Hi, how would one find an attribute by type instead of by name? I'm writing a short python script to dump out a list of all the external files used in a hip file. In most contexts the node type I need is called "file" and the attribute I evaluate is also called "file" or "filename1". Pretty trivial. However in shops a texture/environment/whatever map can be called anything you want ..the only consistent hook I have is that the attribute is of type "file". If I get a list of all the node's params.. paramlist = node.parms() for param in paramlist: paramtype = param.type() I was hoping to do the above, same way param.name() works but no such luck. Is there a way to go about doing this? thanks Tom How about hou.fileRefernces(), which returns a list of tuples consisting with parms and its file strings: ((<hou.Parm file in /obj/geo1/file1>, '/tmp/teapot.bgeo'),) It replaces hscript fdependls command which seems to do what you're after. Alternatively there is a convenient opextern command. If you need to write your own stuff, the only type you can refer to is a string parameter. You could, for example, check every string parm, if the value is a file on disk (os.path.isfile()), but if a file is missing, your method will fail. Another method would be to refer to hou.StringParmTemplate.stringType() which returns stringParmType.FileReference for a file parameters, except no one can guarantee that there won't be any plain (regular) string params instead of file reference type. Quote Link to comment Share on other sites More sharing options...
pushpathadam Posted June 8, 2010 Author Share Posted June 8, 2010 Thank you! Exactly what I was looking for. One unexpected result was that it caught some file type attributes buried in an otl that I wouldn;t have known to look for. -Tom 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.