Shamanek Posted March 27, 2021 Share Posted March 27, 2021 Hi guys, a noob question here but I cannot continue without this and can't figure it out either. How to run a python node? A guy in tutorial said ctrl+enter but that doesn't work for me and nothing happens in python shell. Quote Link to comment Share on other sites More sharing options...
jfaulkner Posted March 27, 2021 Share Posted March 27, 2021 You'll need to assign the operation to a variable first and then output it using print() Like: var = 8+5 print(var) Quote Link to comment Share on other sites More sharing options...
Shamanek Posted March 27, 2021 Author Share Posted March 27, 2021 1 hour ago, jfaulkner said: You'll need to assign the operation to a variable first and then output it using print() Like: var = 8+5 print(var) But that still doesn't execute the code in the shell. Only when I put it directly into it or only if I use the Source Editor. Does the ctrl+enter work for you? Quote Link to comment Share on other sites More sharing options...
jfaulkner Posted March 27, 2021 Share Posted March 27, 2021 Dive inside the python node and place a null, anything will work just need something to have its flags on Because the python nodes been created from obj level, it looks like it doesn't execute any script unless there's a node inside with its flags set on. 1 Quote Link to comment Share on other sites More sharing options...
underscoreus Posted March 27, 2021 Share Posted March 27, 2021 I was just about to write basically what jfaulkner just said, but he got there before me What are you trying to do with this python node? Usually, python nodes are best suited (in my somewhat limited experience) to work with actual geometry in the scene. If you just want to make a tool or something else it is usually better to look into the source editor, the python module of an HDA or just a simple custom shelf tool. Quote Link to comment Share on other sites More sharing options...
Shamanek Posted March 27, 2021 Author Share Posted March 27, 2021 41 minutes ago, jfaulkner said: Dive inside the python node and place a null, anything will work just need something to have its flags on Because the python nodes been created from obj level, it looks like it doesn't execute any script unless there's a node inside with its flags set on. I must do something wrong because that doesn't work for me yet. 35 minutes ago, underscoreus said: I was just about to write basically what jfaulkner just said, but he got there before me What are you trying to do with this python node? Usually, python nodes are best suited (in my somewhat limited experience) to work with actual geometry in the scene. If you just want to make a tool or something else it is usually better to look into the source editor, the python module of an HDA or just a simple custom shelf tool. I've just started with python. The reason I am doing this is that I want to know how it works and if it works. And the Varomix in his tutorial "Bites of Python" has a python node where he has written something simple and it is printed in the console after he hit ctrl+enter but that doesn't work for me. So right now it is just a check on how to make it work before I start to do something more complex like manipulating geometry. And I am stressed out that it doesn't work rightat the start... Quote Link to comment Share on other sites More sharing options...
underscoreus Posted March 27, 2021 Share Posted March 27, 2021 @Shamanek I would not stress out about this. It's not the end of the world if you don't get this one thing working. Also, try doing this: 1. Add a null inside the python script node and make sure the display flag is on it 2. Jump back out to obj level and add this to the script field: print('hello world') 3. Hit ctrl+enter This seems to be working for me. As long as the null node is inside the ctrl+enter thing works perfectly. The thing about executing code inside this node is that it does not echo back simple stuff like just writing 5+5, you have to explicitly call the print function to get anything out of this. However, if you use the python shell tab you'll get automatic echoing from simple stuff like 5+5. Quote Link to comment Share on other sites More sharing options...
Shamanek Posted March 27, 2021 Author Share Posted March 27, 2021 4 minutes ago, underscoreus said: @Shamanek I would not stress out about this. It's not the end of the world if you don't get this one thing working. Also, try doing this: 1. Add a null inside the python script node and make sure the display flag is on it 2. Jump back out to obj level and add this to the script field: print('hello world') 3. Hit ctrl+enter This seems to be working for me. As long as the null node is inside the ctrl+enter thing works perfectly. The thing about executing code inside this node is that it does not echo back simple stuff like just writing 5+5, you have to explicitly call the print function to get anything out of this. However, if you use the python shell tab you'll get automatic echoing from simple stuff like 5+5. Hmm, that's exactly what I did and it is not doing anything. Houdini v18.5.408 Check the file here please if the setup is the same as you have. python_script.hiplc Quote Link to comment Share on other sites More sharing options...
underscoreus Posted March 27, 2021 Share Posted March 27, 2021 @Shamanek Try changing the thing you are printing from "hello world" to "foo bar" or anything else. It is a little fuzzy on opening the print dialog box if there haven't been any changes to the code since the last time you ran it. Your file worked for me by doing that. Also, try to make sure that the viewport is open since nodes in the node network don't always refresh and update if the viewport is not open. Quote Link to comment Share on other sites More sharing options...
Shamanek Posted March 27, 2021 Author Share Posted March 27, 2021 1 minute ago, underscoreus said: @Shamanek Try changing the thing you are printing from "hello world" to "foo bar" or anything else. It is a little fuzzy on opening the print dialog box if there haven't been any changes to the code since the last time you ran it. Your file worked for me by doing that. Also, try to make sure that the viewport is open since nodes in the node network don't always refresh and update if the viewport is not open. ohh, that's the thing. The viewport! It works now. Thanks a lot! 1 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.