Jump to content

Assign global variables with python


Spike

Recommended Posts

Hi

i want to assign a global variable as path for a rop node with python - but the thing is that python translates $F to the current frame, and every other parameter...

node_rop.parm('sopoutput').set("$JOB/render/$HIPNAME.$F.bgeo.sc") gets translatet to /Users/xxxx/Project/render/path.12.bgeo.sc in the rop network

so how can i assign a $F to a textinput field with python

thank you for help!

 

 

Link to comment
Share on other sites

1 hour ago, Spike said:

gets translatet to /Users/xxxx/Project/render/path.12.bgeo.sc

Do you mean translated in UI? Cos it's wired. It could be translated when getting this parameter with node.parm('name').eval() , so you need to use node.parm('name').rawValue() instead.

Link to comment
Share on other sites

1 hour ago, kiryha said:

Do you mean translated in UI? Cos it's wired. It could be translated when getting this parameter with node.parm('name').eval() , so you need to use node.parm('name').rawValue() instead.

so node.parm('$F').rawValue() ? - looks strange cause its no parm of node - yes i mean in the UI of the rop

 

Link to comment
Share on other sites

22 hours ago, kiryha said:

Can you post the file with code in Python Source editor reproducing the issue?
 

In node.parm('$F').rawValue(), parm('...') should contain string parameter name, which you take value from.

still cant figure out the solution

pythonRop.hiplc

Edited by Spike
Link to comment
Share on other sites

Ah, Python node... I don't know why it happened and I don't have a solution for this case.
From the other side, this code is working and you will get correct images in your ROP. And why are you doing it with Python node when you can do the same in ROP directly?

Link to comment
Share on other sites

  • 6 months later...

You can use a global variable in other functions by declaring it as global in each function that assigns to it.  Python assumes that any name that is assigned to, anywhere within a function, is local to that function unless explicitly told otherwise. If it is only reading from a name, and the name doesn't exist locally, it will try to look up the name in any containing scopes (e.g. the module's global scope).

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