0
$\begingroup$

I am trying to run bpy.ops.transform.shrink_fatten(value=0.3) while I have a point on a grease pencil stroke selected (in edit mode), but I am getting the error: "Operator bpy.ops.transform.shrink_fatten.poll() failed, context is incorrect"

Is there no way to shrink_fatten a grease pencil point with Python? Or am I missing something?

$\endgroup$

1 Answer 1

0
$\begingroup$

Your have a context issue because you might be running your script from text editor while shrink_fatten.poll method checks if you're in the 3D view.

Overriding context can be painful especially in edit mode, so you should avoid using ops whenever you can.

About the shrink_fatten ops, i noticed that it simply change the pressure value of each point. So i would try :

#set frame as the current active frame
frame = bpy.context.object.data.layers.active.active_frame

#set amount of pressure to add or remove
amount = 0.3 

#apply this to selected points
for stroke in frame.strokes :
    for point in stroke.points :
        if point.select :
            point.pressure += amount
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .