Sillouette Scripting make shape

The scripting guide is vague and pretty hard to navigate, can someone give me an example of how to make a shape with the scripting window?


is says you can in the scripting guide " Shapes can be created with Shape([type, label=None)"

But there is no detail or example how to implement this

I’ll pass this on to our resident scripting expert, but he is out of the office this coming week.

Thank you Marco :slight_smile:

Look in the Silhouette resources/scripts/gui folder. There are scripts in there that implement some shape editing operations for the Reshape tool that create new shapes.

yes I have looked at it, but it used a getShape method to duplicate and then add points to existing, not the createShape method.

I’m sorry I can’t be more specific at this time -I’m on vacation this week and don’t have the source in front of me.
But the process for creating new shapes is to create the shape and pass in the type. Then you create one or more ShapePath objects and set their ‘points’ attribute, then call setValue() on the shape’s ‘path’ property to set the keyframes.

I think I get it but I am still struggling, sorry I am new to scripting in silhouette.

is there a set amount of parameters that the shape needs to operate? I am having trouble getting this to work.

A scripting example would really help.

Katie Morris, who is a Silhouette power user has a scripting resource found here:

Here is how to create an X-spline shape with a key at the current frame:

from fx import *

s = Shape(Shape.Xspline)
p ="path")
path = s.createPath()
path.closed = True
path.points = [(Point3D(0.241183,-0.21378), 0.25), (Point3D(0.315301,-0.228309), 0.25), (Point3D(0.458229,-0.194391), 0.25), (Point3D(0.550311,-0.110752), 0.25), (Point3D(0.568583,-0.0257705), 0.25), (Point3D(0.55459,0.057137), 0.25), (Point3D(0.434833,0.0720153), 0.25), (Point3D(0.289837,0.0639271), 0.25), (Point3D(0.149813,0.00356161), 0.25), (Point3D(0.129617,-0.0910426), 0.25), (Point3D(0.158576,-0.180277), 0.25)]
p.setValue(path, player.frame)

beginUndo("Make Shape")

1 Like

Thanks Paul that seems to work, however I am little confused about the format the path points take, when I pass in my own points as a list it doesn’t like it, and when I pass in my own points as a tuple it doesn’t like it, also as a list of tuples it seems unhappy.

Am I missing something?

The point list description is documented here:

Yes, although that description is a little confusing because it is a little missleading as to how it is actually required.

But non the less, I keep getting a ValueError: point list tuple must contain 2 items (Point, float)

Not really sure how to reconcile this

okay so nearest I can tell, the Point format requires that format exactly eg: (Point3D(0.158576,-0.180277), 0.25)

And I can write my own points into that positon without having them exactly like that.

What I am attempting to do is something akin to this

S = (my point positon)
F = (s,)
X = (Point3D(F))

For X-splines, the format takes the control point position and the smoothness value.
For Beziers, the format takes the main control point and then the incoming tangent and outgoing tangent.

Are you also trying to set feather too?

Yes I get that, the format works fine on its own, but if I try and create a shape by storing the point position in a variable it doesn’t work (the second method).

I get the error message: TypeError: must be Point3D, not tuple

Is it possible to create a point position or can it only be stated in the editor.

Yes, the ‘points’ value is a list of tuples of Point3D and float values, depending on the shape type.

Can I see your code that builds/sets the points?

for objects in L:
T = str(objects)
P = “,”.join(T.split(",", 3)[:-1])[8:]
G = (P+", 0.25")
H = (G.split(","))

point_tup = tuple(H)
point_one = (point_tup[0],)
point_two = (point_tup[1],)
Point3D(point_one, point_two)

This is my latest atempt at getting it to play ball, but I cant seem to present it in a way that point3d can read it, dispite recognizing its type and being index-able when printing.

its give me this: TypeError: function takes exactly 1 argument (2 given)

P.S objects in L is a list of tracker objects. The intention is to append these into a list and build the shape with it.

P.P.S when I add the third value it gives me syntax error

What types are “point_one” and “point_two”? They should be floats, since the constructor for Point3D() is:
Point3D(x, y, z=0)
Sounds like you’re not passing it two floats, so it’s falling back to check for a single Point3D instance, and that’s why you’re getting the error.