Login | Register 
FEATURES
APPLICATIONS
DOWNLOADS
EDUCATION
BLOG
WIKI
FORUM
STORE

scriptSOP - bezier feature

Still a little green? Ask your beginner's questions here

scriptSOP - bezier feature

Postby django » Mon Jun 11, 2018 12:43 pm

Hi there,

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)


Cheers, David
django
 
Posts: 131
Joined: Fri Aug 30, 2013 3:26 am
Location: Switzerland

Re: scriptSOP - bezier feature

Postby rob » Wed Jun 13, 2018 3:27 pm

Hi David.

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?
User avatar
rob
Staff
 
Posts: 1526
Joined: Tue Nov 13, 2007 1:14 am

Re: scriptSOP - bezier feature

Postby django » Thu Jun 14, 2018 5:10 am

Thank you Rob, this clears it up for me.

I was trying to create something like in the screenshot, but I was successful now, knowing that I cannot attach a bezier to a polygon.

Cheers!
Attachments
bezier.PNG
bezier.PNG (148.34 KiB) Viewed 767 times
django
 
Posts: 131
Joined: Fri Aug 30, 2013 3:26 am
Location: Switzerland

Re: scriptSOP - bezier feature

Postby DavidBraun » Fri Sep 28, 2018 6:12 pm

Is it possible to modify the color or uv of vertices on a bezier from within the script sop? How about custom attributes?
DavidBraun
 
Posts: 308
Joined: Wed Feb 25, 2015 1:35 pm
Location: Chicago

Re: scriptSOP - bezier feature

Postby rob » Mon Oct 01, 2018 8:01 am

Hi.

You can add, remove, destroy any attribute from within a script:

https://docs.derivative.ca/Attributes_Class

n = scriptOp.pointAttribs.create('N')
scriptOp.points[0].N[0] = 0.3 #set X component of first point's Normal attribute.

We'll update the documentation with more complete examples.
User avatar
rob
Staff
 
Posts: 1526
Joined: Tue Nov 13, 2007 1:14 am

Re: scriptSOP - bezier feature

Postby DavidBraun » Wed Oct 03, 2018 11:57 pm

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.
DavidBraun
 
Posts: 308
Joined: Wed Feb 25, 2015 1:35 pm
Location: Chicago

Re: scriptSOP - bezier feature

Postby greg » Thu Oct 04, 2018 2:09 am

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?
User avatar
greg
Staff
 
Posts: 529
Joined: Tue Nov 13, 2007 1:08 am

Re: scriptSOP - bezier feature

Postby DavidBraun » Thu Oct 04, 2018 10:44 am

Sorry I really should have posted the file with the post yesterday.
I had been doing this:
Code: Select all
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 :oops:
Code: Select all
   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)
Attachments
bezier_op_snippet.tox
(1.34 KiB) Downloaded 8 times
DavidBraun
 
Posts: 308
Joined: Wed Feb 25, 2015 1:35 pm
Location: Chicago


Return to Beginners

Who is online

Users browsing this forum: No registered users and 3 guests