Found 250 posts.
Search results Show results as topic list.
Technical Discussion » Python exercises in Houdini ?
- Lewul
- 250 posts
- Offline
Technical Discussion » Python exercises in Houdini ?
- Lewul
- 250 posts
- Offline
Yes, I see !
“One more thing to the previous post. This behavior that you accept in viewport is common for all shelf tools in Houdini. Shelf tools shouldn't accept while you are in network view.”
Indeed, I wasn't realizing when scripting…
One more question :
why the return alone in this case ? :
def DisableOrEnableNodes_Tool():
“”“ Disables or enables node(s) of specified type in selected OBJ geo nodes ”“”
#select geometry
geoNodes = SelectGeoNodes()
if geoNodes == (None, None):
return
#specify node type to find
state, nodeType = SpecifyNodeTypeAndState()
if nodeType == None:
return
#find specified nodes
nodes = FindSpecifiedNodes(geoNodes, nodeType)
if nodes == None:
return
#set nodes state
if state != 2:
DisableOrEnableNodes(nodes, state)
“One more thing to the previous post. This behavior that you accept in viewport is common for all shelf tools in Houdini. Shelf tools shouldn't accept while you are in network view.”
Indeed, I wasn't realizing when scripting…
One more question :
why the return alone in this case ? :
def DisableOrEnableNodes_Tool():
“”“ Disables or enables node(s) of specified type in selected OBJ geo nodes ”“”
#select geometry
geoNodes = SelectGeoNodes()
if geoNodes == (None, None):
return
#specify node type to find
state, nodeType = SpecifyNodeTypeAndState()
if nodeType == None:
return
#find specified nodes
nodes = FindSpecifiedNodes(geoNodes, nodeType)
if nodes == None:
return
#set nodes state
if state != 2:
DisableOrEnableNodes(nodes, state)
Technical Discussion » Python exercises in Houdini ?
- Lewul
- 250 posts
- Offline
Oh, right…
The code is working now, but, you did all the work here. But it helped me a lot, I start to understand how the return works. I will try to add another function, as you suggested.
The code is working now, but, you did all the work here. But it helped me a lot, I start to understand how the return works. I will try to add another function, as you suggested.
Technical Discussion » Python exercises in Houdini ?
- Lewul
- 250 posts
- Offline
I'm only starting, but it seems that the hou.SceneViewer() function allow me to only select in the scene view, but what if all my objects are already bypass ? Then I can't “non” bypass them, because there nothing to select. I there the same in the newtork view ? But only at object level of course.
EDIT : And I think that I'm doing wrong in the main function, DisableOrEnableNodes_Tool(), I don't really know how to use the variables that I returned for starting or not the other functions… I always have "global name ‘blabla’ is not defined', even if it seems to defined.
For example “state”, it's return by the SpecifyNodeTypeAndState() function, but if I'm calling it in the main function, DisableOrEnableNodes_Tool(), for continuing or not the tool, it's telling me that it's not defined.
EDIT 2 : COME ON I'm such a dick, I read your message at least three times and I'm not even capable of reading it correcly. Forget the last edit I think I got my answer.
EDIT : And I think that I'm doing wrong in the main function, DisableOrEnableNodes_Tool(), I don't really know how to use the variables that I returned for starting or not the other functions… I always have "global name ‘blabla’ is not defined', even if it seems to defined.
For example “state”, it's return by the SpecifyNodeTypeAndState() function, but if I'm calling it in the main function, DisableOrEnableNodes_Tool(), for continuing or not the tool, it's telling me that it's not defined.
EDIT 2 : COME ON I'm such a dick, I read your message at least three times and I'm not even capable of reading it correcly. Forget the last edit I think I got my answer.
Technical Discussion » Keep only looping edges
- Lewul
- 250 posts
- Offline
My file is actually a entire tree, and each branch is in a ForEach SOP, maybe it's coming from here (I gave you only one branch).
Technical Discussion » Keep only looping edges
- Lewul
- 250 posts
- Offline
Ah, got it !
Unfortunately, this was nos working for both of your solutions on my geometry (maybe it works on Adam's one). I converted it into a NURBS Curve, and then fused it (the fuse was not working at all until my geo was converted).
Thanks !
EDIT : working only with the fuse now, strange
Unfortunately, this was nos working for both of your solutions on my geometry (maybe it works on Adam's one). I converted it into a NURBS Curve, and then fused it (the fuse was not working at all until my geo was converted).
Thanks !
EDIT : working only with the fuse now, strange
Technical Discussion » Maximize Pane problem
- Lewul
- 250 posts
- Offline
I,
I had the same problem once : http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=29251&highlight=Lewul [sidefx.com]
I had the same problem once : http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=29251&highlight=Lewul [sidefx.com]
Technical Discussion » Keep only looping edges
- Lewul
- 250 posts
- Offline
Nice ! Thanks Adam.
One more question, it's seems that the points are not connected anymore… For example with a Connectivity SOP they are all independent from each other. How can I correct it ? I need each circle to be one geometry.
One more question, it's seems that the points are not connected anymore… For example with a Connectivity SOP they are all independent from each other. How can I correct it ? I need each circle to be one geometry.
Technical Discussion » Python exercises in Houdini ?
- Lewul
- 250 posts
- Offline
Hi Mantragora,
Thanks, I'll study all of this tonight !
“Hopefully” don't give up on me please I know that I'm a bit slow haha :'(
Thanks, I'll study all of this tonight !
“Hopefully” don't give up on me please I know that I'm a bit slow haha :'(
Technical Discussion » Keep only looping edges
- Lewul
- 250 posts
- Offline
Hi everyone,
I'm stuck on something that looks so simple… I have this mesh, which is made with a lot of looping edges, and my goal is to only keep these edges (I don't want the one that goes on the Y axis, but don't refer to that axis because I have some mesh that are not oriented this way).
Do you have a simple solution ?
Thanks,
Tom.
I'm stuck on something that looks so simple… I have this mesh, which is made with a lot of looping edges, and my goal is to only keep these edges (I don't want the one that goes on the Y axis, but don't refer to that axis because I have some mesh that are not oriented this way).
Do you have a simple solution ?
Thanks,
Tom.
Technical Discussion » Python exercises in Houdini ?
- Lewul
- 250 posts
- Offline
Technical Discussion » Python exercises in Houdini ?
- Lewul
- 250 posts
- Offline
I'm stuck, I don't know how to replace my “global”, I'm confused…
So I think that everything is working fine now (I hope), but I don't understand how to return my variables through other functions without the global. Do you have an example that can lead me to a solution ? I understand it in your links, but I'm confusing with the arguments in my script, the variables that should be global, etc. I also checked about multiple values in a return, but still I don't know how to apply it in this script.
I really don't want to take bad habits like with the “global”.
So I think that everything is working fine now (I hope), but I don't understand how to return my variables through other functions without the global. Do you have an example that can lead me to a solution ? I understand it in your links, but I'm confusing with the arguments in my script, the variables that should be global, etc. I also checked about multiple values in a return, but still I don't know how to apply it in this script.
I really don't want to take bad habits like with the “global”.
Technical Discussion » FLIP render problem
- Lewul
- 250 posts
- Offline
Technical Discussion » Python exercises in Houdini ?
- Lewul
- 250 posts
- Offline
Yes sorry, I was somewhere else when I was correcting (= thinking about something else, I don't know if we can say it in english), I wanted to ask one of my teacher about return (he's in the same room actually, but he is busy).
Thanks for the link.
Thanks for the link.
Technical Discussion » FLIP render problem
- Lewul
- 250 posts
- Offline
Technical Discussion » Python exercises in Houdini ?
- Lewul
- 250 posts
- Offline
Okay so I corrected it.
It's strange because if I add a list with the result of findAllChildNodesOfType() (which contains more than one object in general), it can't find the attribute path that is contain in the result (with a for loop in the list I mean, so checking for each child one by one). But if the result of findAllChildNodesOfType() is only one value, then it finds the path… So I wasn't able to store all the children node type in one list and use it later for findind each path.
So I had to kill my bypass function and add it in the function where I find do the findAllChildNodesOfType().
And it allow me to correct some mystakes.
It's strange because if I add a list with the result of findAllChildNodesOfType() (which contains more than one object in general), it can't find the attribute path that is contain in the result (with a for loop in the list I mean, so checking for each child one by one). But if the result of findAllChildNodesOfType() is only one value, then it finds the path… So I wasn't able to store all the children node type in one list and use it later for findind each path.
So I had to kill my bypass function and add it in the function where I find do the findAllChildNodesOfType().
And it allow me to correct some mystakes.
Technical Discussion » Python exercises in Houdini ?
- Lewul
- 250 posts
- Offline
Technical Discussion » Python exercises in Houdini ?
- Lewul
- 250 posts
- Offline
Thanks ! So I will learn this.
EDIT : I don't want to bother you, and maybe that my code is not finished here, but do you think that you will be able to give me another exercice ? I know that my level is very low, but I want to learn, and it's the only way to progress I think.
EDIT : I don't want to bother you, and maybe that my code is not finished here, but do you think that you will be able to give me another exercice ? I know that my level is very low, but I want to learn, and it's the only way to progress I think.
Technical Discussion » Python exercises in Houdini ?
- Lewul
- 250 posts
- Offline
import toolutils
import hou
### Functions:
def SelectGeoNodes():
global geoSelected
hou.ui.setStatusMessage('Select one or more Geometry node', severity=hou.severityType.ImportantMessage)
if selection == (): # if selection is empty
hou.ui.setStatusMessage('Select at least one Geometry node', severity=hou.severityType.ImportantMessage)
print('Select at least one Geometry node')
geoSelected = 0
else:
print('Your selection :') # print the selection and go to the next function
for n in hou.selectedNodes():
print n.path()
geoSelected = 1
def SpecifyNodeTypeAndState():
global buttons
global listText
global textFieldUser
# creation of the ui
textFieldUser = hou.ui.readInput('Bypass :', , title='Bypass',
close_choice=2, initial_contents= ‘<Node(s) type>’)
# variable for the user's text
n = textFieldUser
str(n)
listText = n.split(' ')
# messages to print when press buttons
if textFieldUser == 0:
print('ON')
buttons = 1
elif textFieldUser == 1:
print('OFF')
buttons = 1
elif textFieldUser == 2:
print('CANCEL')
buttons = 0
def FindSpecifiedNodes(selection, listText):
global bypass
global childNodes
global lenChild
if listText == :
hou.ui.setStatusMessage('Textfield empty', severity=hou.severityType.ImportantMessage)
print('Textfield empty')
bypass = 0
else:
for n in selection:
for x in listText:
pathSel = n.path() # path of selected nodes
childNodes = toolutils.findAllChildNodesOfType(hou.node('{0}'.format(pathSel)), ‘{0}’.format(x),
dorecurse=True) # finding children of selection
if childNodes != : # if the name exist
lenChild = len(childNodes) # the lenght of the children contain the objects selected,
# an object may contain more than one type of the same node
# for example
else: # if the word(s) doesn't exist
hou.ui.setStatusMessage('Cannot find {0} in {1}'.format(x, pathSel))
print('Cannot find {0} in {1}'.format(x, pathSel))
bypass = 1
def DisableOrEnableNodes(childNodes, textFieldUser):
for j in range(lenChild):
pathChild = childNodes.path() # the path of each child
toBypass = hou.node('{0}'.format(pathChild))
if textFieldUser == 0: # if user press ON
toBypass.bypass(0)
elif textFieldUser == 1: # if user press OFF
toBypass.bypass(1)
def DisableOrEnableNodes_Tool():
SelectGeoNodes()
if geoSelected == 1: # if nothing is selected
SpecifyNodeTypeAndState()
if buttons == 1: # if buttons are ON or OFF
FindSpecifiedNodes(selection, listText)
if bypass == 1: # if the textfield is not empty, then the bypass function is launched
DisableOrEnableNodes(childNodes, textFieldUser)
### Selection and function starting:
selection = hou.selectedNodes() # Objects selected
DisableOrEnableNodes_Tool() # main function
### Questions:
# - In DisableOrEnableNodes_Tool() function, is it the good way to call the others functions?
# By putting some variables in others functions and calling them back in the main… ?
# - In this specific case I don't know why I have to put argument in some of my functions…
# - I may be wrong with all the “global” thing in my functions, I'm a bit confuse about it (I need to check more of it)
So I followed what you told me, about Python 3, functions, etc.
import hou
### Functions:
def SelectGeoNodes():
global geoSelected
hou.ui.setStatusMessage('Select one or more Geometry node', severity=hou.severityType.ImportantMessage)
if selection == (): # if selection is empty
hou.ui.setStatusMessage('Select at least one Geometry node', severity=hou.severityType.ImportantMessage)
print('Select at least one Geometry node')
geoSelected = 0
else:
print('Your selection :') # print the selection and go to the next function
for n in hou.selectedNodes():
print n.path()
geoSelected = 1
def SpecifyNodeTypeAndState():
global buttons
global listText
global textFieldUser
# creation of the ui
textFieldUser = hou.ui.readInput('Bypass :', , title='Bypass',
close_choice=2, initial_contents= ‘<Node(s) type>’)
# variable for the user's text
n = textFieldUser
str(n)
listText = n.split(' ')
# messages to print when press buttons
if textFieldUser == 0:
print('ON')
buttons = 1
elif textFieldUser == 1:
print('OFF')
buttons = 1
elif textFieldUser == 2:
print('CANCEL')
buttons = 0
def FindSpecifiedNodes(selection, listText):
global bypass
global childNodes
global lenChild
if listText == :
hou.ui.setStatusMessage('Textfield empty', severity=hou.severityType.ImportantMessage)
print('Textfield empty')
bypass = 0
else:
for n in selection:
for x in listText:
pathSel = n.path() # path of selected nodes
childNodes = toolutils.findAllChildNodesOfType(hou.node('{0}'.format(pathSel)), ‘{0}’.format(x),
dorecurse=True) # finding children of selection
if childNodes != : # if the name exist
lenChild = len(childNodes) # the lenght of the children contain the objects selected,
# an object may contain more than one type of the same node
# for example
else: # if the word(s) doesn't exist
hou.ui.setStatusMessage('Cannot find {0} in {1}'.format(x, pathSel))
print('Cannot find {0} in {1}'.format(x, pathSel))
bypass = 1
def DisableOrEnableNodes(childNodes, textFieldUser):
for j in range(lenChild):
pathChild = childNodes.path() # the path of each child
toBypass = hou.node('{0}'.format(pathChild))
if textFieldUser == 0: # if user press ON
toBypass.bypass(0)
elif textFieldUser == 1: # if user press OFF
toBypass.bypass(1)
def DisableOrEnableNodes_Tool():
SelectGeoNodes()
if geoSelected == 1: # if nothing is selected
SpecifyNodeTypeAndState()
if buttons == 1: # if buttons are ON or OFF
FindSpecifiedNodes(selection, listText)
if bypass == 1: # if the textfield is not empty, then the bypass function is launched
DisableOrEnableNodes(childNodes, textFieldUser)
### Selection and function starting:
selection = hou.selectedNodes() # Objects selected
DisableOrEnableNodes_Tool() # main function
### Questions:
# - In DisableOrEnableNodes_Tool() function, is it the good way to call the others functions?
# By putting some variables in others functions and calling them back in the main… ?
# - In this specific case I don't know why I have to put argument in some of my functions…
# - I may be wrong with all the “global” thing in my functions, I'm a bit confuse about it (I need to check more of it)
So I followed what you told me, about Python 3, functions, etc.
Technical Discussion » Python exercises in Houdini ?
- Lewul
- 250 posts
- Offline
Thanks Mantragora, I will study it tomorrow. And I'll try to finish it also.
Just one question, is Houdini using Python 3 ? Nuke and Maya are using Python 2.7 I think, is it really important to learn 3 ? (I'm not saying that I don't want to learn it, it's just for information)
Just one question, is Houdini using Python 3 ? Nuke and Maya are using Python 2.7 I think, is it really important to learn 3 ? (I'm not saying that I don't want to learn it, it's just for information)
-
- Quick Links