Jump to content

python, find a node's attribute by type instead of name


pushpathadam

Recommended Posts

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

Link to comment
Share on other sites

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.

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...