1
$\begingroup$

I have a scene with a GP object selected, and tried to run a very simple script from the script editor:

import bpy
bpy.ops.gpencil.convert(type='CURVE', timing_mode='LINEAR', use_timing_data=False)

I get an error which, looking around, seems to be due to the mouse being over the script editor when I hit Alt P,thus it lacks the context of being over the 3D view:

File "C:\Users\oscar\Downloads\blender-2.80-ae977d13f8e9-win64\blender-2.80.0-git.ae977d13f8e9-windows64\2.80\scripts\modules\bpy\ops.py", line 200, in __call__
RuntimeError: Operator bpy.ops.gpencil.convert.poll() failed, context is incorrect
Error: Python script failed, check the message in the system console

I tried to solve this by setting the context to the 3D view, but then blender crashes. Do I need to just manually parse the verts from the selected GP object into a new curve object? How do I run 3D view bpy.ops actions without hovering over the 3D view?

$\endgroup$
1

0

Browse other questions tagged .