parent
b9dd1196ca
commit
6d43064f0b
|
@ -325,14 +325,14 @@ def unregister_keymaps():
|
||||||
### --- REGISTER ---
|
### --- REGISTER ---
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
if not bpy.app.background:
|
# if not bpy.app.background:
|
||||||
bpy.utils.register_class(OBJ_OT_breakdown_obj_anim)
|
bpy.utils.register_class(OBJ_OT_breakdown_obj_anim)
|
||||||
register_keymaps()
|
register_keymaps()
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
if not bpy.app.background:
|
# if not bpy.app.background:
|
||||||
unregister_keymaps()
|
unregister_keymaps()
|
||||||
bpy.utils.unregister_class(OBJ_OT_breakdown_obj_anim)
|
bpy.utils.unregister_class(OBJ_OT_breakdown_obj_anim)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -316,7 +316,7 @@ def copy_all_strokes_in_frame(frame=None, layers=None, obj=None):
|
||||||
#print(stroke_list)
|
#print(stroke_list)
|
||||||
return stroke_list
|
return stroke_list
|
||||||
|
|
||||||
def add_stroke(s, frame, layer, obj):
|
def add_stroke(s, frame, layer, obj, select=False):
|
||||||
'''add stroke on a given frame, (layer is for parentage setting)'''
|
'''add stroke on a given frame, (layer is for parentage setting)'''
|
||||||
# print(3*'-',s)
|
# print(3*'-',s)
|
||||||
ns = frame.strokes.new()
|
ns = frame.strokes.new()
|
||||||
|
@ -343,6 +343,9 @@ def add_stroke(s, frame, layer, obj):
|
||||||
ns.points[i].co = ob_mat_inv @ mat @ ns.points[i].co# invert of object * invert of layer * coordinate
|
ns.points[i].co = ob_mat_inv @ mat @ ns.points[i].co# invert of object * invert of layer * coordinate
|
||||||
else:
|
else:
|
||||||
setattr(ns.points[i], k, v)
|
setattr(ns.points[i], k, v)
|
||||||
|
if select:
|
||||||
|
ns.points[i].select = True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for i, pt in enumerate(s['points']):
|
for i, pt in enumerate(s['points']):
|
||||||
for k, v in pt.items():
|
for k, v in pt.items():
|
||||||
|
@ -351,18 +354,21 @@ def add_stroke(s, frame, layer, obj):
|
||||||
ns.points[i].co = ob_mat_inv @ ns.points[i].co# invert of object * coordinate
|
ns.points[i].co = ob_mat_inv @ ns.points[i].co# invert of object * coordinate
|
||||||
else:
|
else:
|
||||||
setattr(ns.points[i], k, v)
|
setattr(ns.points[i], k, v)
|
||||||
|
if select:
|
||||||
|
ns.points[i].select = True
|
||||||
|
|
||||||
## trigger updapte (in 2.93 fix some drawing problem with fills and UVs)
|
## trigger updapte (in 2.93 fix some drawing problem with fills and UVs)
|
||||||
ns.points.update()
|
ns.points.update()
|
||||||
|
|
||||||
## patch pressure 2
|
## patch pressure 2
|
||||||
# ns.points.foreach_set('pressure', pressure_flat_list)
|
# ns.points.foreach_set('pressure', pressure_flat_list)
|
||||||
|
|
||||||
def add_multiple_strokes(stroke_list, layer=None, use_current_frame=True):
|
def add_multiple_strokes(stroke_list, layer=None, use_current_frame=True, select=False):
|
||||||
'''
|
'''
|
||||||
add a list of strokes to active frame of given layer
|
add a list of strokes to active frame of given layer
|
||||||
if no layer specified, active layer is used
|
if no layer specified, active layer is used
|
||||||
if use_current_frame is True, a new frame will be created only if needed
|
if use_current_frame is True, a new frame will be created only if needed
|
||||||
|
if select is True, newly added strokes are selected
|
||||||
'''
|
'''
|
||||||
scene = bpy.context.scene
|
scene = bpy.context.scene
|
||||||
obj = bpy.context.object
|
obj = bpy.context.object
|
||||||
|
@ -388,7 +394,7 @@ def add_multiple_strokes(stroke_list, layer=None, use_current_frame=True):
|
||||||
#or active exists but not aligned scene.current with use_current_frame disabled
|
#or active exists but not aligned scene.current with use_current_frame disabled
|
||||||
target_frame = layer.frames.new(fnum)
|
target_frame = layer.frames.new(fnum)
|
||||||
|
|
||||||
add_stroke(s, target_frame, layer, obj)
|
add_stroke(s, target_frame, layer, obj, select=select)
|
||||||
'''
|
'''
|
||||||
for s in stroke_data:
|
for s in stroke_data:
|
||||||
add_stroke(s, target_frame)
|
add_stroke(s, target_frame)
|
||||||
|
@ -478,7 +484,7 @@ class GPCLIP_OT_paste_strokes(bpy.types.Operator):
|
||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
|
|
||||||
print('data loaded', time() - t0)
|
print('data loaded', time() - t0)
|
||||||
add_multiple_strokes(data, use_current_frame=True)
|
add_multiple_strokes(data, use_current_frame=True, select=True)
|
||||||
print('total_time', time() - t0)
|
print('total_time', time() - t0)
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
|
@ -112,6 +112,9 @@ Panel in sidebar : 3D view > sidebar 'N' > Gpencil
|
||||||
|
|
||||||
## Changelog:
|
## Changelog:
|
||||||
|
|
||||||
|
1.0.5:
|
||||||
|
|
||||||
|
- GP copy-paste : Pasted stroke are now selected (allow to use it to quickly rip/split strokes with cut/paste on the same layer)
|
||||||
|
|
||||||
1.0.4:
|
1.0.4:
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ bl_info = {
|
||||||
"name": "GP toolbox",
|
"name": "GP toolbox",
|
||||||
"description": "Set of tools for Grease Pencil in animation production",
|
"description": "Set of tools for Grease Pencil in animation production",
|
||||||
"author": "Samuel Bernou",
|
"author": "Samuel Bernou",
|
||||||
"version": (1, 0, 4),
|
"version": (1, 0, 5),
|
||||||
"blender": (2, 91, 0),
|
"blender": (2, 91, 0),
|
||||||
"location": "sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
|
"location": "sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
|
||||||
"warning": "",
|
"warning": "",
|
||||||
|
|
Loading…
Reference in New Issue