I have to make a project with Python and Grease Pencil for the end of May. I encounter a main problem : to know the coordinates of each point of the curve made with GreasePencil.
Is it possible or not? If it is, can you explain it please?
This is possible (in 2.5). For an example you could take a look at the Surface sketching or Arrays sketching scripts.
The api documentation gives this page. Following the references back up, you get:
bpy.context.scene.grease_pencil.layers[0].active_frame.strokes[0].points (not tested)
Thank you for your answer. I checked the different links you proposed. I saw he used the function :
bpy.ops.gpencil.convert(type=‘CURVE’)
I tried to use it but there is a problem with :
Traceback (most recent call last):
File “<console>”, line 1, in <module>
File “C:\Users\Mathieu\DOWNLO~1\1389_W~1.blender\scripts\modules\bpy\ops.py”, line 158, in call
ret = op_call(self.idname_py(), C_dict, kw)
SystemError: Operator bpy.ops.gpencil.convert.poll() failed, context is incorrect
Do you know the reason of this problem and how can I fix it?
I have the same problem when I use :
bpy.ops.gpencil.draw(…)
with the good parameters
Moreover, I would like to know how to convert a Grease pencil stroke to a curve using python script?
I thought it was the goal of the function gpencil.convert mentioned before
mDesign: the error you encountered is caused because you’re calling the operator from an area that is not a 3d-view (you’re calling it from the text-editor). I’ve posted some solutions in the thread PKHG linked to.
Just the last part of my post over there (about filing a bug-report) doesn’t apply to your situation, as it actually makes sense for the convert() and draw() operators that they can only be called from the 3d-view (or the 3d-view, sequencer, nodes and image editor areas, in the case of draw() ).
Hi, thank your for your answer. It was really useful.
Noiw, I have another problem, I need to know the coordinate of each point of the curve made thanks the grease Pencil.