Jump to content

How to access `@attribute` in a TOPs python processor?


eldrich

Recommended Posts

Hey folks,
I'm executing a Windows .bat file which is written out by a pythonprocessor TOPs node to run some things on another sever.
Everything works if I hardcode the filename to the batch file, but I want it to generate and execute .bat files for each work item

I'm trying to access `@filename`in the pythonprocessor, but not getting anywhere. 
How can I access the attribute so .format fills in the path correctly?

PidginCode:

outFile = `@filename`
filePath = "path to directory/{}".format(outFile)

The sample file docs are bereft of examples so I'm wondering if I'm going about it the wrong way.
Thoughts? 
 

EDIT: I made a string parameter on the node I'm querying and pointed evalParm at it.
Is that the most sensible way? 

 

node = hou.node('/obj/topnet1/nodeName')

parmName = str(node.evalParm('parm'))

 

 

 

Edited by eldrich
Solved problem.
Link to comment
Share on other sites

  • 1 year later...

If you are doing per work item, I think it's better to use python script node instead of python processor.

It will go through all work items one by one

outFile = work_item.attribValue('filename')

If you are using python processor, It only run once, so you have to use a loop to go through all the items and get the values one by one

outFile1 = upstream_items[0].attribValue("filename")

 

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