I want to use the new bezier feature in the scriptSOP, but I cannot figure out how I can attach a bezier to a polygon.
In the manual it says:
addPoints - (Keyword, Optional) If True, a new point will be attached to each vertex, otherwise the vertex point references will need to be manually set afterwards. Use this option when creating polygons with shared vertices.
But my script always throws an error (“Invalid Prim object”) as soon as I do this:
scriptOp.appendBezier(4, addPoints=False)
There’s a typo in the addPoints description.
It should actually read: Use this option when creating Beziers with shared vertices.
That is, Bezier and Polygon primitives will always be unique primitives within any SOP.
In your example, if you don’t addPoints, you’ll need to set them before manipulating them.
I see this isn’t producing a valid Primitive, so we’ll fix that next.
Can I ask what type of Bezier you’re trying to build?
Thanks! I wasn’t able to add any attributes inside the script sop that creates the bezier. I ended up putting a convert SOP after it and then another script sop that copies the copy sop. In this second script sop I was able to add the UV attribute.
I’ll attach an example soon. It’s mainly from the bezier script sop example in the op snippets and trying to add attributes to it.
There is a basic example in the OP Snippets for the Script SOP called “bezier curve”. Does it help? If not, can someone suggest what examples we need to add to make it more useful?
Sorry I really should have posted the file with the post yesterday.
I had been doing this:
b = scriptOp.appendBezier(7) #open, cubic, 7 vertices, or 2 spans
n = b.pointAttribs.create('N') # Normal attribute, default implied.
which caused this error
td.Bezier object has no attribute pointAttribs
The correct way is to call appendBezier on a scriptOp not the bezier object
b = scriptOp.appendBezier(7) #open, cubic, 7 vertices, or 2 spans
uv = scriptOp.vertexAttribs.create('uv')
for i in range(7):
b[i].uv = (i/(7-1),0.5) bezier_op_snippet.tox (1.34 KB)