node = hou.node('/obj/surface/file')
geo = node.geometry()
geo.addAttrib(hou.attribType.Global,“test”,1)
this gives me
return _hou.Geometry_addAttrib(*args)
GeometryPermissionError: Geometry is read-only
And the error code is not much helpful.
thanks
How do i create an attribute inside Python Sop?
19012 4 0- veritasone
- Member
- 12 posts
- Joined: Sept. 2016
- Offline
- tamte
- Member
- 8525 posts
- Joined: July 2007
- Offline
in Python SOP you can only modify current geometry, it doesn't have permissions to change geometry of other nodes like in your example
so you can only do this:
and connect your /obj/surface/file as a first input of Python SOP
so you can only do this:
node = hou.pwd() geo = node.geometry() geo.addAttrib(hou.attribType.Global, "test", 1)
and connect your /obj/surface/file as a first input of Python SOP
Edited by tamte - Sept. 25, 2016 14:34:23
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
- veritasone
- Member
- 12 posts
- Joined: Sept. 2016
- Offline
@tamte
Thanks, that makes perfect sense and your solution works. However I have couple issues with adding attr in Python .
- It also creates “varmap” along with what I am trying to create. I understand that this must be the local vairable name but why does not create with the name I gave it? How do I access that “varmap” to change the name.
- It also does not set the value I give in the command, if the given value is a text entry (the entry in the spreadsheet is empty. For instance
I have to add another command to modify the value for the actual thing with this
Not a big deal but I wonder if it is a bug or the initial command parsing cant decide on the type of the variable (unlike what the doc says about it)
Thanks, that makes perfect sense and your solution works. However I have couple issues with adding attr in Python .
- It also creates “varmap” along with what I am trying to create. I understand that this must be the local vairable name but why does not create with the name I gave it? How do I access that “varmap” to change the name.
- It also does not set the value I give in the command, if the given value is a text entry (the entry in the spreadsheet is empty. For instance
geo.addAttrib(hou.attribType.Global, "test", "string test")
I have to add another command to modify the value for the actual thing with this
geo.setGlobalAttribValue("test", "string test")
Not a big deal but I wonder if it is a bug or the initial command parsing cant decide on the type of the variable (unlike what the doc says about it)
tamte
in Python SOP you can only modify current geometry, it doesn't have permissions to change geometry of other nodes like in your example
so you can only do this:node = hou.pwd() geo = node.geometry() geo.addAttrib(hou.attribType.Global, "test", 1)
and connect your /obj/surface/file as a first input of Python SOP
Edited by veritasone - Sept. 25, 2016 18:41:39
- Stiggie
- Member
- 1 posts
- Joined: Jan. 2010
- Offline
I am also trying to add an attribute using the python node.
Eventually I want to load in some values via Json, and set them to the "Cd" values for the primitives of my geo.
But first I thought I'd simply try adding an attribute via the python node.
I have:
node = hou.pwd()
geo = node.geometry()
geo.addAttrib(hou.attribType.Prim, "Cd", hou.Vector3(1.0,0.0,0.0))
But it does nothing, I have a geometry spreadsheet open but I don't see any attributes appearing underneath the primitives tab or any other.
I am not getting an error, so it seems to be evaluating the code fine, but nothing happens.
Any idea? The geometry is connected to the first input.
Eventually I want to load in some values via Json, and set them to the "Cd" values for the primitives of my geo.
But first I thought I'd simply try adding an attribute via the python node.
I have:
node = hou.pwd()
geo = node.geometry()
geo.addAttrib(hou.attribType.Prim, "Cd", hou.Vector3(1.0,0.0,0.0))
But it does nothing, I have a geometry spreadsheet open but I don't see any attributes appearing underneath the primitives tab or any other.
I am not getting an error, so it seems to be evaluating the code fine, but nothing happens.
Any idea? The geometry is connected to the first input.
- Enivob
- Member
- 2528 posts
- Joined: June 2008
- Offline
-
- Quick Links