I'm just starting learning Python in Houdini and trying the python scripts in document to get the geometry of a node, it looks simple and straightforward but I got the error saying ‘Node’ object has no attribute ‘geometry’. Please see the output from the Python Shell window:
>>> node = hou.pwd()
>>> geo = node.geometry()
Traceback (most recent call last):
File “<console>”, line 1, in <module>
AttributeError: ‘Node’ object has no attribute ‘geometry’
>>>
What I'm I doing wrong here, and how can I fix it?
'Node' object has no attribute 'geometry'
6386 5 0-
- quchen
- Member
- 75 posts
- Joined: Oct. 2018
- Offline
-
- jsmack
- Member
- 8170 posts
- Joined: Sept. 2011
- Online
-
- quchen
- Member
- 75 posts
- Joined: Oct. 2018
- Offline
I was trying the code samples from C:\Program Files\Side Effects Software\Houdini 17.5.173\houdini\PythonScripts.txt.
Here are part of it:
# Python SOP
Sop/pythonscript/python
Default Script
node = hou.pwd()
geo = node.geometry()
# Add code to modify contents of geo.
# Use drop down menu to select examples.
Sop/pythonscript/python
Move Points Up
node = hou.pwd()
geo = node.geometry()
# Add code to modify contents of geo.
for point in geo.points():
pos = point.position()
pos += hou.Vector3(0, 1, 0)
point.setPosition(pos)
So yeah you're right @jsmack only Sop nodes have geometry, thank you! And indeed I want to create a Sop node for my usd file, with usd plugin installed of course. I could use hou.Geometry.loadFromFile to load the my usd successfully but I don't know how to create a sop node for it. Sorry for the newbie question, and any help is welcome!
Here are part of it:
# Python SOP
Sop/pythonscript/python
Default Script
node = hou.pwd()
geo = node.geometry()
# Add code to modify contents of geo.
# Use drop down menu to select examples.
Sop/pythonscript/python
Move Points Up
node = hou.pwd()
geo = node.geometry()
# Add code to modify contents of geo.
for point in geo.points():
pos = point.position()
pos += hou.Vector3(0, 1, 0)
point.setPosition(pos)
So yeah you're right @jsmack only Sop nodes have geometry, thank you! And indeed I want to create a Sop node for my usd file, with usd plugin installed of course. I could use hou.Geometry.loadFromFile to load the my usd successfully but I don't know how to create a sop node for it. Sorry for the newbie question, and any help is welcome!
-
- tamte
- Member
- 9236 posts
- Joined: July 2007
- Online
-
- jsmack
- Member
- 8170 posts
- Joined: Sept. 2011
- Online
I think what you want to do is more or less this:
create an object
create a file sop
tell the file sop to load a file
You don't do any of that with the geometry module, which is for directly editing geometry.
In python that would be something like:
create an object
create a file sop
tell the file sop to load a file
You don't do any of that with the geometry module, which is for directly editing geometry.
In python that would be something like:
myfile = "/path/to/foo.usd" fname = "foo" geo = hou.node("/obj").createNode("geo", fname) fi = geo.createNode('file') fi.parm('file').set(myfile)
-
- quchen
- Member
- 75 posts
- Joined: Oct. 2018
- Offline
-
- Quick Links