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

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

PyroEvil
Posts: 1
Joined: Wed May 23, 2012 8:07 pm

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

Postby PyroEvil » Wed May 23, 2012 8:12 pm

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\ops.py", 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 !

Return to “Python”

Who is online

Users browsing this forum: No registered users and 2 guests