Page 1 of 1

How to use "bpy.ops.gpencil.draw()" ?

Posted: Wed May 23, 2012 8:12 pm
by PyroEvil
Hi !

I already post it on blenderartist forum but no buddy answer me. I give a try here :)

I try to draw line with grease_pensil and python. I now understand how to set a area but it's give me a different error now:

Code: Select all

import bpy

original_type = bpy.context.area.type
bpy.context.area.type = "VIEW_3D"
bpy.ops.gpencil.draw(mode='DRAW_POLY', stroke=[{"name":"", "pen_flip":False, "is_start":True, "location":(0, 0, 0), "mouse":(333, 335), "pressure":1, "time":0}, {"name":"", "pen_flip":False, "is_start":True, "location":(0, 0, 0), "mouse":(469, 259), "pressure":1, "time":0}, {"name":"", "pen_flip":False, "is_start":False, "location":(0, 0, 0), "mouse":(469, 259), "pressure":1, "time":0}])
bpy.context.area.type = original_type
And I get this error:

Code: Select all

Traceback (most recent call last):
  File "\Text", line 5, in <module>
  File "D:\stuff\blender-2.63-release-windows64\2.63\scripts\modules\bpy\", line 180, in __call__
    ret = op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.gpencil.draw.poll() Active region not set
Somebody have a idea how to set the region to make this example code work?

thanks !