Jump to content

using a button to call a python function


Recommended Posts

I am writing a node that will output some data that I am calculating as a mapped PNG file.  The file takes a minute to execute, and it will only be getting worse as I increase its complexity, so I am wanting to set up the node so that I can trigger the code when I want it to run.  I tried calling the function in the callback on the button, which is how I would expect it to work, but it doesn't apparently.  I have looked around and found several people talking about hitting buttons automatically in the script, which is really not what I am looking for.  So what am I missing in using a button in a UI?

Link to comment
Share on other sites

The node I am working on is op:obj/Solar_Occlusion_1/occlusion_Calculations/write_to_file

I am trying to call the processPoints() function using a button from the interface instead of calling it in the script itself in an effort to speed up the process by not having it run constantly.

occlusionPassesDev.0.1.4.hipnc

Link to comment
Share on other sites

Python SOP executes the code every time the node cooks as it is usually used to change the geometry

since you don't use it to change geometry you don't need to use Python SOP at all

just create digital asset, store your code in it's python module and call from the interface

here is the file with included HDA, which contains mentioned changes (you can continue work on your code in HDA's python module)

occlusionPassesDev.0.1.4_mod.hipnc

  • Thanks 1
Link to comment
Share on other sites

Thank you so much anim, that is exactly what I was looking for.  One quick question though, where do my print commands go now?  I am still working with the script and I am needing to debug a few things to get it working right, but my print commands don't seem to be going anywhere.  I am running the file in Windows right now, but I will try it in Linux to see if they will dump into the shell when I am finished with my pyro sim that I am running in the background.  I would really prefer to dev in windows though, since I can use Notepad++ as my preferred IDE.

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