Refactoring this post to simplify the request:
I need to draw a straight line/continuous Stroke in Python with Texture Paint. Unfortunately it is currently only placing a single dot at either end of the stroke.
Desired Outcome:
Current Code does this:
Tried:
- Using "location" & "mouse_event" instead of mouse
- Making "name" unique
- Using different Stroke settings in Texture Paint (like Line)
- UV unwrapping
- Every combination of "is_start" for each stroke
I've seen multiple posts about this with no solutions, is bpy.ops.paint.image_paint just broken?
Code:
import bpy
x1 = 500
x2 = 800
# the line should be horizontal, ie 500-800px
strokes = [{"name": "",
"is_start": True,
"location": (0,0,0),
"mouse":(x1, 500),
"mouse_event":(0,0),
"pen_flip":False,
"pressure":1.0,
"size":10,
"time":0,
"x_tilt":0.0,
"y_tilt":0.0},
{"name": "",
"is_start": False,
"location": (0,0,0),
"mouse":(x2, 500),
"mouse_event":(0,0),
"pen_flip":False,
"pressure":1.0,
"size":10,
"time":0,
"x_tilt":0.0,
"y_tilt":0.0}]
bpy.ops.object.mode_set(mode='TEXTURE_PAINT')
areas = [area for area in bpy.context.window.screen.areas if area.type == 'VIEW_3D']
with bpy.context.temp_override(
window=bpy.context.window,
area=areas[0],
region=[region for region in areas[0].regions if region.type == 'WINDOW'][0],
screen=bpy.context.window.screen
):
bpy.ops.paint.brush_select(vertex_tool="DRAW", toggle=False)
bpy.ops.paint.image_paint(stroke=strokes)
bpy.ops
statement will even error out as poll context fail. so i updated it to be executed in the right context. it runs without errors now but nothing happens. Not even a dot gets painted. $\endgroup$