[Bf-funboard] Feature request: Accessing painted brush strokes from Python

Jacob Merrill blueprintrandom1 at gmail.com
Thu Feb 25 00:41:22 CET 2016


"

up vote2down vote

You get the area and the region from the context
<http://www.blender.org/documentation/blender_python_api_2_71_0/bpy.types.Context.html#bpy.types.Context>
argument
(passed to the invoke / execute / poll method of the operator).

Use the operator's poll
<http://www.blender.org/documentation/blender_python_api_2_71_0/bpy.types.Operator.html?highlight=bpy.types.operator#bpy.types.Operator.poll>
method
to check for the right context. I.e:

@classmethoddef poll(cls, context):
    return context.area.type   == 'VIEW_3D' and \
           context.region.type == 'WINDOW'

Just want to add:

   -

   The event class
   <http://www.blender.org/documentation/blender_python_api_2_71_0/bpy.types.Event.html#module-bpy.types>
also
   provides the attributes mouse_region_x
   <http://www.blender.org/documentation/blender_python_api_2_71_0/bpy.types.Event.html#bpy.types.Event.mouse_region_x>
    and mouse_region_y
   <http://www.blender.org/documentation/blender_python_api_2_71_0/bpy.types.Event.html#bpy.types.Event.mouse_region_y>
   -

   The view2d class
   <http://www.blender.org/documentation/blender_python_api_2_71_0/bpy.types.View2D.html#bpy.types.View2D>
provides
   methods to convert mouse coordinates from region coordinates to view
   coordinates
   -

   The bpy_extras.view3d_utils
   <http://www.blender.org/documentation/blender_python_api_2_71_0/bpy_extras.view3d_utils.html#module-bpy_extras.view3d_utils>
module
   provides methods to deal with 3d-coordinates"


On Wed, Feb 24, 2016 at 3:40 PM, Jacob Merrill <blueprintrandom1 at gmail.com>
wrote:

> use the mouse position, the screen res and camera location * I think *
>
> On Wed, Feb 24, 2016 at 3:38 PM, Jacob Merrill <blueprintrandom1 at gmail.com
> > wrote:
>
>>
>> http://blender.stackexchange.com/questions/13450/how-to-get-mouse-position-in-a-window-with-python
>>
>> On Wed, Feb 24, 2016 at 2:10 PM, Lubos Lenco <lubos.lenco at gmail.com>
>> wrote:
>>
>>> Hm, how to calculate ray start since I am not able to get mouse
>>> position? Is there a workaround for this?
>>>
>>> > On 24 Feb 2016, at 23:00, Jacob Merrill <blueprintrandom1 at gmail.com>
>>> wrote:
>>> >
>>> > Bvtree, cast ray from mouse  at mesh, get hitFace and hitpoint, use
>>> > vertex.uv and hitpoint to get UV
>>> > On Feb 24, 2016 1:52 PM, "Lubos Lenco" <lubos.lenco at gmail.com> wrote:
>>> >
>>> >> Hello,
>>> >>
>>> >> I am looking for ability to paint to multiple paint slots at once,
>>> using
>>> >> the same strokes user performs but with different brush texture. This
>>> would
>>> >> be handy to create several textures on the fly, while the user only
>>> paints
>>> >> to single one.
>>> >>
>>> >> The easiest way that comes to mind is exposing last painted strokes by
>>> >> user. The painting to other slots can then be performed using
>>> >> ops.paint.image_paint() operator as usual. There should probably be a
>>> >> switch and only store strokes if it is enabled.
>>> >>
>>> >> The other way I tried was to log mouse coords and construct strokes
>>> >> myself, unfortunately the modals are blocked while user is painting
>>> and I
>>> >> could not find any other way to access mouse positions apart from
>>> modal
>>> >> events.
>>> >>
>>> >> I had a brief look around and could try to implement this, however I
>>> would
>>> >> be thankful if anyone could point me to the right direction, possibly
>>> with
>>> >> as much detail.
>>> >> _______________________________________________
>>> >> Bf-funboard mailing list
>>> >> Bf-funboard at blender.org
>>> >> http://lists.blender.org/mailman/listinfo/bf-funboard
>>> >>
>>> > _______________________________________________
>>> > Bf-funboard mailing list
>>> > Bf-funboard at blender.org
>>> > http://lists.blender.org/mailman/listinfo/bf-funboard
>>>
>>> _______________________________________________
>>> Bf-funboard mailing list
>>> Bf-funboard at blender.org
>>> http://lists.blender.org/mailman/listinfo/bf-funboard
>>>
>>
>>
>


More information about the Bf-funboard mailing list