Hi awong,
I really appreciate you taking the time to answer my questions.
Yes I was running Realtime Playback, and as you say goes into subframes.
You also said if its a heavy scene it could jump frames?
So this is why in my case it “missed” my statement to do something like “ if hou.frame() == 120: do something” that perhaps it was a “little busy” at that point and skipped a bit?
The only reason I had it set for Realtime Playback is so I could get a general check on what the final motion will be like.
So what seems to be the solution is when I want to check my code at specific places like in my case I wanted something to happen at frame 120…perhaps just go out of realtime playback set the step value to 3 decimal places ( same as subframes ) and just step through and observe if what happens is what I want kind of thing?
And then maybe for overall flow of the work I can go to realtime playback?
Thanks again.
Found 2040 posts.
Search results Show results as topic list.
Houdini Indie and Apprentice » How to Determine what sub-frames Python code will see
- BabaJ
- 2042 posts
- Offline
Houdini Indie and Apprentice » How to Determine what sub-frames Python code will see
- BabaJ
- 2042 posts
- Offline
Hi,
Ok, so what I mean by sequence is when I reset the pay bar to the start and just press play and let it run.
In this case sequence meaning how are the frames getting incremented and by what value.
So what I am assuming is that for each frame or subframe value the python code in the node is “called”.
So for example if I have subframes turned off I am assuming that the sequence of frames being played will be sequentially:
1,2,3,4…etc. or rather frame1, frame2, frame3, frame4, etc.
Again, I am assuming for each frame number the program looks at the current frame number and with that value looks through the python code in the node to see what will be executed.
So say I have code that says ‘if hou.frame() == 3: then do this’…
well, again I am assuming that this code is looked at for each frame value ‘as it occurs’…sequentially….
when the frame is at 1 or 2 or 4 or 5 and so on nothing will happen because the condition hasn't been met…
but something should happen at frame 3.
But if I turn on sub-frames nothing will happen at frame 3. But it will happen at 3 if sub-frames is turned off.
I understand with sub-frames on we can get values of 2.856 or 3.023; or do we?
How can I ever get something to happen at 3.000 and only at 3.000? (with subframes on)
With math.floor(hou.frames()) it leads me to believe that I may be using another value other than 3…
because it might be taking say subframe 3.234 and converting it to 3 just to be able to do the code.
Am I to understand that by doing something like math.floor(hou.frames()) that the resulting value,
in this case 3 is the actual “driver” of the frames rather than the other way around?
Meaning the code determines what frame values get created and not that the frame values determine what code gets executed?
I had already looked at Global Animation Options for the default step option and played with that;
And yes it will step your frames when you use the ‘+’ and ‘-’ buttons.
But if you run the keyframes with ‘play’ button it doesn't run to that setting
eg. if you have it set to 50, it doesn't play every 50 frames it still runs through each number 1-50 and every sub-frame of each number, although what the subframes are is difficult to determine because they go so fast.
Hope this is more clear in helping me understand how the code gets run in relationship to how the frames are run.
Thank you
Ok, so what I mean by sequence is when I reset the pay bar to the start and just press play and let it run.
In this case sequence meaning how are the frames getting incremented and by what value.
So what I am assuming is that for each frame or subframe value the python code in the node is “called”.
So for example if I have subframes turned off I am assuming that the sequence of frames being played will be sequentially:
1,2,3,4…etc. or rather frame1, frame2, frame3, frame4, etc.
Again, I am assuming for each frame number the program looks at the current frame number and with that value looks through the python code in the node to see what will be executed.
So say I have code that says ‘if hou.frame() == 3: then do this’…
well, again I am assuming that this code is looked at for each frame value ‘as it occurs’…sequentially….
when the frame is at 1 or 2 or 4 or 5 and so on nothing will happen because the condition hasn't been met…
but something should happen at frame 3.
But if I turn on sub-frames nothing will happen at frame 3. But it will happen at 3 if sub-frames is turned off.
I understand with sub-frames on we can get values of 2.856 or 3.023; or do we?
How can I ever get something to happen at 3.000 and only at 3.000? (with subframes on)
With math.floor(hou.frames()) it leads me to believe that I may be using another value other than 3…
because it might be taking say subframe 3.234 and converting it to 3 just to be able to do the code.
Am I to understand that by doing something like math.floor(hou.frames()) that the resulting value,
in this case 3 is the actual “driver” of the frames rather than the other way around?
Meaning the code determines what frame values get created and not that the frame values determine what code gets executed?
I had already looked at Global Animation Options for the default step option and played with that;
And yes it will step your frames when you use the ‘+’ and ‘-’ buttons.
But if you run the keyframes with ‘play’ button it doesn't run to that setting
eg. if you have it set to 50, it doesn't play every 50 frames it still runs through each number 1-50 and every sub-frame of each number, although what the subframes are is difficult to determine because they go so fast.
Hope this is more clear in helping me understand how the code gets run in relationship to how the frames are run.
Thank you
Houdini Indie and Apprentice » How to Determine what sub-frames Python code will see
- BabaJ
- 2042 posts
- Offline
Hi awong,
Thank you for that reply.
I changed my code and it now works but I had simplified my original question, and maybe I shouldn't have but hopefully you catch this reply and may be able to offer more insight.
So I originally changed my code from:
if (hou.frame()) == 120:
to
if (hou.frame() > 120.0) and (hou.frame() < 120.1):
and this worked because like you demonstrated with the print and floor function we are only getting values like 120.023.
So am I to understand that when we use this non-integer setting to get subframes that the sequence of subframes is “undetermined”?
Like in my case using 120 as my aim.
Does the sequence possibly go like:
119.897, 119.976, 120.063, 120.341, etc.
hence the reason it never “sees” 120.000 is because it was never created?
So in my case in the screenshot of my code I am using a sin function to drive changes in an object and using the subframe values to make changes.
So I have a range of < 120 where I do something, then at and only at 120 intend to make a specific change then carry on with something different with values only > 120.
So both with my alternative as I said above and your suggestion of using floor my code works.
But perhaps in this case I don't see the possible difference in results. And what I mean is that what I want to happen at say 120 is likely really happening at another subframe like say 120.024.
I am probably splitting hairs too much and in my particular case I am not seeing any difference but wonder if at another point in time when say I want something to happen at “exactly” “120” I might see a difference.
So again, I was hoping I could get some more insight as to what is going on.
I've read subframes are calculated to 3 decimal points.
But does this mean they run through sequentialy for each value?:
119.998, 119.999, 120.000, 120.001, 120.002, etc.
and for each value the code in a python node is looked at?
This is what I originaly thought which is why I was a little perplexed when it seemd like the “ == 120” wasn't being “looked” at.
I hope I am clear enough and appreciate if you could offer your thoughts on this.
Thank you
Thank you for that reply.
I changed my code and it now works but I had simplified my original question, and maybe I shouldn't have but hopefully you catch this reply and may be able to offer more insight.
So I originally changed my code from:
if (hou.frame()) == 120:
to
if (hou.frame() > 120.0) and (hou.frame() < 120.1):
and this worked because like you demonstrated with the print and floor function we are only getting values like 120.023.
So am I to understand that when we use this non-integer setting to get subframes that the sequence of subframes is “undetermined”?
Like in my case using 120 as my aim.
Does the sequence possibly go like:
119.897, 119.976, 120.063, 120.341, etc.
hence the reason it never “sees” 120.000 is because it was never created?
So in my case in the screenshot of my code I am using a sin function to drive changes in an object and using the subframe values to make changes.
So I have a range of < 120 where I do something, then at and only at 120 intend to make a specific change then carry on with something different with values only > 120.
So both with my alternative as I said above and your suggestion of using floor my code works.
But perhaps in this case I don't see the possible difference in results. And what I mean is that what I want to happen at say 120 is likely really happening at another subframe like say 120.024.
I am probably splitting hairs too much and in my particular case I am not seeing any difference but wonder if at another point in time when say I want something to happen at “exactly” “120” I might see a difference.
So again, I was hoping I could get some more insight as to what is going on.
I've read subframes are calculated to 3 decimal points.
But does this mean they run through sequentialy for each value?:
119.998, 119.999, 120.000, 120.001, 120.002, etc.
and for each value the code in a python node is looked at?
This is what I originaly thought which is why I was a little perplexed when it seemd like the “ == 120” wasn't being “looked” at.
I hope I am clear enough and appreciate if you could offer your thoughts on this.
Thank you
Houdini Indie and Apprentice » Math problem
- BabaJ
- 2042 posts
- Offline
Well your cam of 100 to 16.6 screen size is .166.
So with the same ratio 512 becomes 84.992.
Maybe try that for your screen resolution of cam 2.
But I don't know if it would work.
I don't have experience with cameras, but I think the cameras have a focal length setting? I don't know if that would make a difference or not.
Could always just try 84.992 and see what it looks like.
So with the same ratio 512 becomes 84.992.
Maybe try that for your screen resolution of cam 2.
But I don't know if it would work.
I don't have experience with cameras, but I think the cameras have a focal length setting? I don't know if that would make a difference or not.
Could always just try 84.992 and see what it looks like.
Houdini Indie and Apprentice » How to Determine what sub-frames Python code will see
- BabaJ
- 2042 posts
- Offline
Hi,
As the topic asks I am having problems in my code being able to pick a specific point in time or frame when using hou.time() or frame.time()
My code works fine if the Global Animations Options has Integar frame values ticked on.
However if I take it off, my python code never sees the specific interval so the code doesn't get executed.
If in my Python Source Editor I have a variable say “The_x” set to 0.0 and then in my python node I doing something like:
if hou.frame() == 30:
hou.session.The_x = 5.0
or
if hou.time() == 6:
hou.session.The_x = 19.0
in either case with the check box set for Integer frame values both sets of code give what I expect.
With it checked off, its as if it never saw those values; 30 with hou.frames() or 6 with hou.time()
Should this code be “seen” in either case or is there some inherent limit with the option being checked off ( Integer frame values ) ?
Thanks for any feedback.
As the topic asks I am having problems in my code being able to pick a specific point in time or frame when using hou.time() or frame.time()
My code works fine if the Global Animations Options has Integar frame values ticked on.
However if I take it off, my python code never sees the specific interval so the code doesn't get executed.
If in my Python Source Editor I have a variable say “The_x” set to 0.0 and then in my python node I doing something like:
if hou.frame() == 30:
hou.session.The_x = 5.0
or
if hou.time() == 6:
hou.session.The_x = 19.0
in either case with the check box set for Integer frame values both sets of code give what I expect.
With it checked off, its as if it never saw those values; 30 with hou.frames() or 6 with hou.time()
Should this code be “seen” in either case or is there some inherent limit with the option being checked off ( Integer frame values ) ?
Thanks for any feedback.
Houdini Indie and Apprentice » Variable Scope with Python in Python Module node
- BabaJ
- 2042 posts
- Offline
Hi awong,
Yeah, thanks for the reply.
And yes when I have the frames set to the begining the error message goes away. Don't know why I didn't think to check that as I am in the habit of resetting to the start when I make changes anyways; maybe there was just a glitch at the time or I just thought I did when I didn't.
As for the commenting out blocks of code.
Yeah I opened your file and I get the same thing. The code blocks out to green. But I was assuming that means it will be treated as a string and not something blocked out.
My understanding of Python is that you can define a string through any combination pairs of ‘ or “ and as singles, doubles or triples. In all cases in the Python Source Editor it turns to green.
When you use the ”#" symbol it will block out in yellow. So when I use triple quotes I get the typed blocked out as green and seeing that am assuming it’s going to treat it as a string, perhaps introducing some bugs that may not be apparent?
Thanks again for your comment.
Yeah, thanks for the reply.
And yes when I have the frames set to the begining the error message goes away. Don't know why I didn't think to check that as I am in the habit of resetting to the start when I make changes anyways; maybe there was just a glitch at the time or I just thought I did when I didn't.
As for the commenting out blocks of code.
Yeah I opened your file and I get the same thing. The code blocks out to green. But I was assuming that means it will be treated as a string and not something blocked out.
My understanding of Python is that you can define a string through any combination pairs of ‘ or “ and as singles, doubles or triples. In all cases in the Python Source Editor it turns to green.
When you use the ”#" symbol it will block out in yellow. So when I use triple quotes I get the typed blocked out as green and seeing that am assuming it’s going to treat it as a string, perhaps introducing some bugs that may not be apparent?
Thanks again for your comment.
Houdini Indie and Apprentice » Variable Scope with Python in Python Module node
- BabaJ
- 2042 posts
- Offline
I have a pair of IF statements that I am using in a Python Node.
It appears that Python in the Python Node considers variables created within an IF statement to be out of scope if one attemps to use it outside the IF statement; almost like variables declared within a c function.
I googled a python search and apparently this is typically allowed in Python, at least from what I read. Meaning that an IF statement shouldn't block a variable created within it from being used elsewhere like immediately after that IF statement block.
It seems that the python node may have it's own Python rules?
In the first pair of IF statements below Houdini complains that “New_Positions” is not defined:
if KF_START_A == hou.frame():
New_Positions = hou.session.Current_Positions_HUB_A()
if ( ( KF_START_A < hou.frame()) and ( KF_STOP_A > hou.frame()) ):
hou.session.Translate_Square_Corners_ppmm(List, New_Positions, 1)
However, if I set “New_Positions” in the IF statement where it's going to be used then Houdini is “Happy”:
if KF_START_A == hou.frame():
# Old place where New_Position was
if ( ( KF_START_A < hou.frame()) and ( KF_STOP_A > hou.frame()) ):
New_Positions = hou.session.Current_Positions_HUB_A()
hou.session.Translate_Square_Corners_ppmm(List, New_Positions, 1)
A second not closely related question but while I am at it.
I can't seem to block out large blocks of code with triple quotes.
Apparently you can do this with Python, but it doesn't seem to work in the Python Source Editor ( only pound symbol for single lines )
Any comments are appreciated - Thank you
It appears that Python in the Python Node considers variables created within an IF statement to be out of scope if one attemps to use it outside the IF statement; almost like variables declared within a c function.
I googled a python search and apparently this is typically allowed in Python, at least from what I read. Meaning that an IF statement shouldn't block a variable created within it from being used elsewhere like immediately after that IF statement block.
It seems that the python node may have it's own Python rules?
In the first pair of IF statements below Houdini complains that “New_Positions” is not defined:
if KF_START_A == hou.frame():
New_Positions = hou.session.Current_Positions_HUB_A()
if ( ( KF_START_A < hou.frame()) and ( KF_STOP_A > hou.frame()) ):
hou.session.Translate_Square_Corners_ppmm(List, New_Positions, 1)
However, if I set “New_Positions” in the IF statement where it's going to be used then Houdini is “Happy”:
if KF_START_A == hou.frame():
# Old place where New_Position was
if ( ( KF_START_A < hou.frame()) and ( KF_STOP_A > hou.frame()) ):
New_Positions = hou.session.Current_Positions_HUB_A()
hou.session.Translate_Square_Corners_ppmm(List, New_Positions, 1)
A second not closely related question but while I am at it.
I can't seem to block out large blocks of code with triple quotes.
Apparently you can do this with Python, but it doesn't seem to work in the Python Source Editor ( only pound symbol for single lines )
Any comments are appreciated - Thank you
Houdini Indie and Apprentice » volume display problem
- BabaJ
- 2042 posts
- Offline
I guess I spoke too soon.
Even with Houdini re-installed…initially it would show objects in a new file…now it doesn't.
I guess I will have to report as bug or something.
Even with Houdini re-installed…initially it would show objects in a new file…now it doesn't.
I guess I will have to report as bug or something.
Houdini Indie and Apprentice » volume display problem
- BabaJ
- 2042 posts
- Offline
It's funny I see this post today.
I was doing some Python function scripting - adjusting part of an objects y translation parameter when I made a simple syntax error.
Removed the error and then not only the file seem corrupted but Houdini itself.
The main problem that developed is that I couldn't turn on and off the objects visibility.
In my file I tried adding a new object ( a sphere ) just to see if somehow my code messed up my object, but no I couldn't even turn visibility on to see the sphere and it was more than large enough and the viewport was suitable.
I decided to delete the new object sphere, then after saving the file, I closed it, and then closed Houdini.
When I opened Houdini again and then the file, the sphere I had deleted was now showing in the scene although its node was not listed in the Network Panel…so I opened the Network panel “full screen” so I could find the sphere node that should be there ( because the object was showing in the scene. ). As I just said, the node wasn't there but as soon as I collapsed the Network window to regular size to see the scene view again also, the sphere was now gone.
So this explained to me why when I was working on my Python code and had the syntax error, but corrected it…the original code I had working no longer did so…and I thought I had somehow corrupted my script code, when with further testing it appears something else is going on with the display.
I closed Houdini and opened a new file and tried with a new sphere object again and same problem ( not being visible/flagging display not having affect). So then I thought, no it's not just the one file.
So I uninstalled/re-installed Houdini and so far with new files I am able to set the display flags on objects…but still not with my file I was having problems with.
This is very weird, and to top it off you guys are having problems on the same day as well.
I last updated my driver about 3 weeks ago.
I'm using GTX 980 with driver 358.91
Guess I will try the update of 359
Hoping I don't have to copy and paste all that code from one file to another new one and duplicate the nodes and their names.
I was doing some Python function scripting - adjusting part of an objects y translation parameter when I made a simple syntax error.
Removed the error and then not only the file seem corrupted but Houdini itself.
The main problem that developed is that I couldn't turn on and off the objects visibility.
In my file I tried adding a new object ( a sphere ) just to see if somehow my code messed up my object, but no I couldn't even turn visibility on to see the sphere and it was more than large enough and the viewport was suitable.
I decided to delete the new object sphere, then after saving the file, I closed it, and then closed Houdini.
When I opened Houdini again and then the file, the sphere I had deleted was now showing in the scene although its node was not listed in the Network Panel…so I opened the Network panel “full screen” so I could find the sphere node that should be there ( because the object was showing in the scene. ). As I just said, the node wasn't there but as soon as I collapsed the Network window to regular size to see the scene view again also, the sphere was now gone.
So this explained to me why when I was working on my Python code and had the syntax error, but corrected it…the original code I had working no longer did so…and I thought I had somehow corrupted my script code, when with further testing it appears something else is going on with the display.
I closed Houdini and opened a new file and tried with a new sphere object again and same problem ( not being visible/flagging display not having affect). So then I thought, no it's not just the one file.
So I uninstalled/re-installed Houdini and so far with new files I am able to set the display flags on objects…but still not with my file I was having problems with.
This is very weird, and to top it off you guys are having problems on the same day as well.
I last updated my driver about 3 weeks ago.
I'm using GTX 980 with driver 358.91
Guess I will try the update of 359
Hoping I don't have to copy and paste all that code from one file to another new one and duplicate the nodes and their names.
Houdini Indie and Apprentice » object not rendering beside object that does
- BabaJ
- 2042 posts
- Offline
Thank you so much tamte;
I did remember looking under the different tabs; just another example of I should have looked more carefully; If so I would have likely taken notice of that checkbox.
Funny thing is…all the while I put on hold working with the path/pathcv nodes I started working with add/polyspline nodes to get a close approximation of what I build with the path/pathcv nodes; and another slew of questions arose out of that.
But I am going to hold back on those questions for now and go back to the path/pathcv nodes and work with them for a bit now that I know can get a render with them.
Don't want to ask too many questions. I'm not paying you guys for all this advice and I really appreciate the time you take to answer questions.
Thanks again
I did remember looking under the different tabs; just another example of I should have looked more carefully; If so I would have likely taken notice of that checkbox.
Funny thing is…all the while I put on hold working with the path/pathcv nodes I started working with add/polyspline nodes to get a close approximation of what I build with the path/pathcv nodes; and another slew of questions arose out of that.
But I am going to hold back on those questions for now and go back to the path/pathcv nodes and work with them for a bit now that I know can get a render with them.
Don't want to ask too many questions. I'm not paying you guys for all this advice and I really appreciate the time you take to answer questions.
Thanks again
Houdini Indie and Apprentice » object not rendering beside object that does
- BabaJ
- 2042 posts
- Offline
Thank you for taking the time to look into this arctor.
Hope its not some silly mistake on my part.
Hope its not some silly mistake on my part.
Houdini Indie and Apprentice » object not rendering beside object that does
- BabaJ
- 2042 posts
- Offline
Hi arctor,
Thank you for the suggestion.
So I went into preferences and checked the “Change Render and Display Flags Separately” was turned off.
I also made sure the SOP was selected and the purple circle on with the surrounding blue display flag.
But still no luck.
So the chance that there might have been a bug with the file. I closed Houdini and opened a new blank file and created another object with the path/pathcv nodes. Still again, no render.
Starting to think, for some reason that the path/pathcv nodes are not meant to be used for what I am trying to do with them. It would be too bad if that is true, I really love the kinda of control they offer that I wish to work with and the potential of implementing some of my ideas easily.
Thanks again for taking the time to help.
Thank you for the suggestion.
So I went into preferences and checked the “Change Render and Display Flags Separately” was turned off.
I also made sure the SOP was selected and the purple circle on with the surrounding blue display flag.
But still no luck.
So the chance that there might have been a bug with the file. I closed Houdini and opened a new blank file and created another object with the path/pathcv nodes. Still again, no render.
Starting to think, for some reason that the path/pathcv nodes are not meant to be used for what I am trying to do with them. It would be too bad if that is true, I really love the kinda of control they offer that I wish to work with and the potential of implementing some of my ideas easily.
Thanks again for taking the time to help.
Houdini Indie and Apprentice » object not rendering beside object that does
- BabaJ
- 2042 posts
- Offline
Hello,
I have two objects sitting side by side. One is a circle the other is a “bulb” that is a revolve of a path/pathcv profile.
Both have the same material applied and the “display” tick was checked for on for the bulb but it does not display in render.
Bounding Box of camera was checked as was intensity of lighting.
I had a similar problem with the polycap of a path/pathcv not rendering in another file as well.
any help is appreciated
I have two objects sitting side by side. One is a circle the other is a “bulb” that is a revolve of a path/pathcv profile.
Both have the same material applied and the “display” tick was checked for on for the bulb but it does not display in render.
Bounding Box of camera was checked as was intensity of lighting.
I had a similar problem with the polycap of a path/pathcv not rendering in another file as well.
any help is appreciated
Houdini Learning Materials » Running Python Scripts from KeyFrame Activation
- BabaJ
- 2042 posts
- Offline
Thank you Enivob,
This works.
But then I got the idea ( for workflow and decrease clutter ) why not just keep my definitions in a separate container from where I run the functions.
In the screenshot( A ) here prefixing the function with “hou.session” does the trick whether those definitions are in another python script node as in the screenshot or in my python source editor.
But I also wanted to try and eliminate the prefix “hou.session” as in the screenshot( B ) using:
hou.expressionGlobals() = try_this
Of course this only works if I “run” the functions, in this case “try_this” in the same python script node.
I've tried doing things like including “import a_different_python_script_node”,
and also trying to reference the whole other python script node with variations of hou.expressionGlobals() like:
#hou.expressionGlobals() = “/obj/Function_Definitions”
#hou.expressionGlobals() = ‘/obj/Function_Definitions’
#hou.expressionGlobals() = /obj/Function_Definitions
..and also in conjunction with different imports like:
import ‘/obj/Function_Definitions’
..with no success
Again this is more for myself learning how I can set up my work flows and I am just exploring possibilities.
I may just be asking for too much and am ok right now with knowing how I can set things up as it is, but….
Additional input is appreciated - Thank you
This works.
But then I got the idea ( for workflow and decrease clutter ) why not just keep my definitions in a separate container from where I run the functions.
In the screenshot( A ) here prefixing the function with “hou.session” does the trick whether those definitions are in another python script node as in the screenshot or in my python source editor.
But I also wanted to try and eliminate the prefix “hou.session” as in the screenshot( B ) using:
hou.expressionGlobals() = try_this
Of course this only works if I “run” the functions, in this case “try_this” in the same python script node.
I've tried doing things like including “import a_different_python_script_node”,
and also trying to reference the whole other python script node with variations of hou.expressionGlobals() like:
#hou.expressionGlobals() = “/obj/Function_Definitions”
#hou.expressionGlobals() = ‘/obj/Function_Definitions’
#hou.expressionGlobals() = /obj/Function_Definitions
..and also in conjunction with different imports like:
import ‘/obj/Function_Definitions’
..with no success
Again this is more for myself learning how I can set up my work flows and I am just exploring possibilities.
I may just be asking for too much and am ok right now with knowing how I can set things up as it is, but….
Additional input is appreciated - Thank you
Houdini Learning Materials » Running Python Scripts from KeyFrame Activation
- BabaJ
- 2042 posts
- Offline
Hello,
So I've been successful in writing python functions in the Python Source Editor and then placing the name of the functions in the parameter edit boxes and having them run when the keyframes are played; basically the same as entering a HS script.
Part of the reason for doing this is to learn how to set up more complicated functions or rather have much more concurrent activity in my scene but wanting to have all that code more in a central place so the work flow is much easier by looking at my function at a glance to make adjustments relative to other things going on. It can get a bit tedious if I am having to do alot of clicking on nodes and going into each parameter box to adjust individual functions.
So now I feel I am on track to how I like to set up my “workflow” in regards to coding. The following code is what I started with to test how to do it. You can see I return one value with the shape() function. That function is placed in the edit box of the corresponding parameter so that when the Keyframes are played it gets the values. However, to test my intention of being able to do things “remotely”, I use a set function to apply the value to another objects parameter and as I hoped it worked. That other parameter box doesn't have any reference to the shape() function directly ie. I didn't place that function in its corresponding edit box.
So seeing it can be done “remotely” I was hoping to be able to have the functions run when the keyframes are played without having to even put the function in a single edit box.
Is there another way to get the function and or list of functions “triggered” to run when keyframes are played other than through their placement in the edit boxes?
I looked in the help files and the closest thing I came by was mentioning of Script SOP but in reference to when you cook and still didn't seem to indicate how I can do what I want.
Again this is more for how I would like to set up my work flow. Thanks for any input.
import hou
import math
mt_width = hou.parm('/obj/mt/ty')
mt_height = hou.parm('/obj/mt/tz')
mt_rx = hou.parm('/obj/mt/rx')
mt_sz = hou.parm('/obj/mt/sz')
mid_width = hou.parm('/obj/mid/ty')
mid_height = hou.parm('/obj/mid/tz')
mid_rx = hou.parm('/obj/mid/rx')
mid_sz = hou.parm('/obj/mid/sz')
mb_width = hou.parm('/obj/mb/ty')
mb_height = hou.parm('/obj/mb/tz')
mb_rx = hou.parm('/obj/mb/rx')
mb_sz = hou.parm('/obj/mb/sz')
def shape():
mt_rx = 90 * math.fabs(math.sin(math.radians( (hou.frame() + 49) ) ))
mb_rx.set( 90 * math.fabs(math.sin(math.radians( (hou.frame() + 49) ) )))
return mt_rx
So I've been successful in writing python functions in the Python Source Editor and then placing the name of the functions in the parameter edit boxes and having them run when the keyframes are played; basically the same as entering a HS script.
Part of the reason for doing this is to learn how to set up more complicated functions or rather have much more concurrent activity in my scene but wanting to have all that code more in a central place so the work flow is much easier by looking at my function at a glance to make adjustments relative to other things going on. It can get a bit tedious if I am having to do alot of clicking on nodes and going into each parameter box to adjust individual functions.
So now I feel I am on track to how I like to set up my “workflow” in regards to coding. The following code is what I started with to test how to do it. You can see I return one value with the shape() function. That function is placed in the edit box of the corresponding parameter so that when the Keyframes are played it gets the values. However, to test my intention of being able to do things “remotely”, I use a set function to apply the value to another objects parameter and as I hoped it worked. That other parameter box doesn't have any reference to the shape() function directly ie. I didn't place that function in its corresponding edit box.
So seeing it can be done “remotely” I was hoping to be able to have the functions run when the keyframes are played without having to even put the function in a single edit box.
Is there another way to get the function and or list of functions “triggered” to run when keyframes are played other than through their placement in the edit boxes?
I looked in the help files and the closest thing I came by was mentioning of Script SOP but in reference to when you cook and still didn't seem to indicate how I can do what I want.
Again this is more for how I would like to set up my work flow. Thanks for any input.
import hou
import math
mt_width = hou.parm('/obj/mt/ty')
mt_height = hou.parm('/obj/mt/tz')
mt_rx = hou.parm('/obj/mt/rx')
mt_sz = hou.parm('/obj/mt/sz')
mid_width = hou.parm('/obj/mid/ty')
mid_height = hou.parm('/obj/mid/tz')
mid_rx = hou.parm('/obj/mid/rx')
mid_sz = hou.parm('/obj/mid/sz')
mb_width = hou.parm('/obj/mb/ty')
mb_height = hou.parm('/obj/mb/tz')
mb_rx = hou.parm('/obj/mb/rx')
mb_sz = hou.parm('/obj/mb/sz')
def shape():
mt_rx = 90 * math.fabs(math.sin(math.radians( (hou.frame() + 49) ) ))
mb_rx.set( 90 * math.fabs(math.sin(math.radians( (hou.frame() + 49) ) )))
return mt_rx
Houdini Learning Materials » getting return value from hou.frame()
- BabaJ
- 2042 posts
- Offline
thanks tamte,
It works now without error but I'm not sure what I did that actually got it to work.
The reason I say this is because at first the ‘import hou’ didn't make a change in that I was still getting the error message.
So a couple times I deleted my transform node, saved the file, and closed/reopened Houdini and the file. But it still was getting the error message and not working.
So I tried changing the code just to play around:
import hou
b = hou.frame()
def new():
if b == 1:
a = 5
else:
a = 7
return a
I understand that this code would only give me an initial result because b is only getting set once and not each time new() is getting called. But in this case the error message went away and got the parameter set to 5 as expected.
So I tried the original code of:
import hou
def new():
if hou.frame() == 1:
a = 3
else:
a = 2
return a
…and this worked too. Not only that but I tried removing ‘import hou’, and it still works. I even deleted the source editor contents, accept, reload, close…and deleted the node, and saved/closed Houdini/File and restarted/opened file and typed in the code again without import hou; And it still works.
I think this is a good experience to have early on in learning Houdini because I have plans make some complex functions in the future and if I have problems running my code it shows that it may not always be my syntax or applied logic.
Thanks for your time and the suggestion.
It works now without error but I'm not sure what I did that actually got it to work.
The reason I say this is because at first the ‘import hou’ didn't make a change in that I was still getting the error message.
So a couple times I deleted my transform node, saved the file, and closed/reopened Houdini and the file. But it still was getting the error message and not working.
So I tried changing the code just to play around:
import hou
b = hou.frame()
def new():
if b == 1:
a = 5
else:
a = 7
return a
I understand that this code would only give me an initial result because b is only getting set once and not each time new() is getting called. But in this case the error message went away and got the parameter set to 5 as expected.
So I tried the original code of:
import hou
def new():
if hou.frame() == 1:
a = 3
else:
a = 2
return a
…and this worked too. Not only that but I tried removing ‘import hou’, and it still works. I even deleted the source editor contents, accept, reload, close…and deleted the node, and saved/closed Houdini/File and restarted/opened file and typed in the code again without import hou; And it still works.
I think this is a good experience to have early on in learning Houdini because I have plans make some complex functions in the future and if I have problems running my code it shows that it may not always be my syntax or applied logic.
Thanks for your time and the suggestion.
Houdini Learning Materials » getting return value from hou.frame()
- BabaJ
- 2042 posts
- Offline
Hello,
So I've went through the video tutorial on Python and thought I would try a few things to get a working feel for it.
I made a simple function in the python source editor which is called new().
I dropped that function as new() in a Transformation node parameter edit box to see if the return value of the function will get placed as a value parameter.
I get an error message though saying that global name hou not defined.
I tried just using frame() instead of hou.frame() but then it says frame() is not defined.
But if I run hou.frame() in python shell it does return whatever the current frame number is.
So I am not sure how to “define” frame() in the source editor in order that it can “see” it.
I do have expression language set for python, and integer frame values unchecked in the global animation options window.
This is the function code in case the screenshot makes it hard to see:
def new():
if hou.frame() == 1:
a = 3
else:
a = 2
return a
any feedback is appreciated, thanks.
So I've went through the video tutorial on Python and thought I would try a few things to get a working feel for it.
I made a simple function in the python source editor which is called new().
I dropped that function as new() in a Transformation node parameter edit box to see if the return value of the function will get placed as a value parameter.
I get an error message though saying that global name hou not defined.
I tried just using frame() instead of hou.frame() but then it says frame() is not defined.
But if I run hou.frame() in python shell it does return whatever the current frame number is.
So I am not sure how to “define” frame() in the source editor in order that it can “see” it.
I do have expression language set for python, and integer frame values unchecked in the global animation options window.
This is the function code in case the screenshot makes it hard to see:
def new():
if hou.frame() == 1:
a = 3
else:
a = 2
return a
any feedback is appreciated, thanks.
Houdini Indie and Apprentice » Create Bezier/NURBS curve from points?
- BabaJ
- 2042 posts
- Offline
Hi solarain…thanks for that input.
Yeah I tried something to the effect of using an ADD node connecting points and a resample, the only problem with that was when I moved one point it ‘broke’ the curve between that point and it's adjacent points; Meaning they became straight lines.
But I guess if I used the parametric equation you provided I could re-establish a curve feature with the moved point.
Although the Path and PathCV nodes does provide me with the capacity to run the curves through “points PRECISELY” and this method does allow me to implement some ideas I was hoping to do, there are still some limitations for another idea that the Path/PathCV nodes doesn't let me do.
But your suggestion may help in that regard so I will have to revisit that equation and try working with it at some point.
Thanks
Yeah I tried something to the effect of using an ADD node connecting points and a resample, the only problem with that was when I moved one point it ‘broke’ the curve between that point and it's adjacent points; Meaning they became straight lines.
But I guess if I used the parametric equation you provided I could re-establish a curve feature with the moved point.
Although the Path and PathCV nodes does provide me with the capacity to run the curves through “points PRECISELY” and this method does allow me to implement some ideas I was hoping to do, there are still some limitations for another idea that the Path/PathCV nodes doesn't let me do.
But your suggestion may help in that regard so I will have to revisit that equation and try working with it at some point.
Thanks
Houdini Indie and Apprentice » Create Bezier/NURBS curve from points?
- BabaJ
- 2042 posts
- Offline
I want to say thanks again arctor.
The reason being is that tried putting down a path tool, but I did so while in network window, so I didn't realize how or where the PathCV “nodes” can come into play.
So I was reading in the help files to how I could get more use of the path tool compared to what I was using and discovered they mention about creating the path tool while in scene view.
so by placing down points those pathCVs get created automatically and also looking at where they fit within the path node noticed how I could add PathCVs after the path is created too.
So this Path tool is really much more than I expected was possible and very easy to use.
Thanks again
The reason being is that tried putting down a path tool, but I did so while in network window, so I didn't realize how or where the PathCV “nodes” can come into play.
So I was reading in the help files to how I could get more use of the path tool compared to what I was using and discovered they mention about creating the path tool while in scene view.
so by placing down points those pathCVs get created automatically and also looking at where they fit within the path node noticed how I could add PathCVs after the path is created too.
So this Path tool is really much more than I expected was possible and very easy to use.
Thanks again
Houdini Indie and Apprentice » Create Bezier/NURBS curve from points?
- BabaJ
- 2042 posts
- Offline
-
- Quick Links