Layer actions and navigations features
1.9.0 - feat: New shortcuts: - `F2` in Paint and Edit to rename active layer - `Insert` add a new layer (same as Krita) - `Shift + Insert` add a new layer and immediately pop-up a rename box - `page up / page down` change active layer up/down with a temporary fade (settings in addon prefs) - fix: error when tweaking `gp.duplicate_send_to_layer` shortcut
This commit is contained in:
@@ -30,19 +30,14 @@ def set_matrix(gp_frame,mat):
|
||||
|
||||
# get view vector location (the 2 methods work fine)
|
||||
def get_view_origin_position():
|
||||
#method 1
|
||||
## method 1
|
||||
# from bpy_extras import view3d_utils
|
||||
# region = bpy.context.region
|
||||
# rv3d = bpy.context.region_data
|
||||
# view_loc = view3d_utils.region_2d_to_origin_3d(region, rv3d, (region.width/2.0, region.height/2.0))
|
||||
# print("view_loc1", view_loc)#Dbg
|
||||
|
||||
#method 2
|
||||
## method 2
|
||||
r3d = bpy.context.space_data.region_3d
|
||||
view_loc2 = r3d.view_matrix.inverted().translation
|
||||
# print("view_loc2", view_loc2)#Dbg
|
||||
# if view_loc != view_loc2: print('Might be an error when finding view coordinate')
|
||||
|
||||
return view_loc2
|
||||
|
||||
def location_to_region(worldcoords):
|
||||
@@ -76,6 +71,10 @@ def object_derived_get(ob, scene):
|
||||
return ob_matrix_pairs
|
||||
|
||||
|
||||
# -----------------
|
||||
### Bmesh
|
||||
# -----------------
|
||||
|
||||
def link_vert(v,ordered_vert) :
|
||||
for e in v.link_edges :
|
||||
other_vert = e.other_vert(v)
|
||||
@@ -147,7 +146,11 @@ def gp_stroke_to_bmesh(strokes):
|
||||
return strokes_info
|
||||
|
||||
|
||||
def simple_draw_gp_stroke(pts,frame,width = 2, mat_id = 0):
|
||||
# -----------------
|
||||
### GP Drawing
|
||||
# -----------------
|
||||
|
||||
def simple_draw_gp_stroke(pts, frame, width = 2, mat_id = 0):
|
||||
'''
|
||||
draw basic stroke by passing list of point 3D coordinate
|
||||
the frame to draw on and optional width parameter (default = 2)
|
||||
@@ -169,11 +172,11 @@ def simple_draw_gp_stroke(pts,frame,width = 2, mat_id = 0):
|
||||
return stroke
|
||||
|
||||
## OLD - need update
|
||||
def draw_gp_stroke(loop_info,frame,palette,width = 2) :
|
||||
def draw_gp_stroke(loop_info, frame, palette, width = 2) :
|
||||
stroke = frame.strokes.new(palette)
|
||||
|
||||
stroke.line_width = width
|
||||
stroke.display_mode = '3DSPACE'# old->draw_mode
|
||||
stroke.display_mode = '3DSPACE'# old -> draw_mode
|
||||
|
||||
for i,info in enumerate(loop_info) :
|
||||
stroke.points.add()
|
||||
@@ -894,13 +897,6 @@ def draw_kmi(km, kmi, layout):
|
||||
### linking utility
|
||||
# -----------------
|
||||
|
||||
"""
|
||||
def link_objects_in_blend(filepath, obj_name, link=True):
|
||||
'''Link an object by name from a file, if link is False, append instead of linking'''
|
||||
with bpy.data.libraries.load(filepath, link=link) as (data_from, data_to):
|
||||
data_to.objects = [o for o in data_from.objects if o == obj_name] # c.startswith(obj_name)
|
||||
return data_to.objects
|
||||
"""
|
||||
def link_objects_in_blend(filepath, obj_name_list, link=True):
|
||||
'''Link an object by name from a file, if link is False, append instead of linking'''
|
||||
if isinstance(obj_name_list, str):
|
||||
@@ -922,4 +918,37 @@ def check_objects_in_blend(filepath, avoid_camera=True):
|
||||
l = [o for o in data_from.objects if not any(x in o.lower() for x in ('camera', 'draw_cam', 'obj_cam'))]
|
||||
else:
|
||||
l = [o for o in data_from.objects]
|
||||
return l
|
||||
return l
|
||||
|
||||
|
||||
# -----------------
|
||||
### props handling
|
||||
# -----------------
|
||||
|
||||
def iterate_selector(zone, attr, state, info_attr = None, active_access='active'):
|
||||
'''Iterate with given attribute'''
|
||||
item_number = len(zone)
|
||||
if item_number <= 1:
|
||||
return
|
||||
|
||||
if getattr(zone, attr) == None:
|
||||
print('no', attr, 'in', zone)
|
||||
return
|
||||
|
||||
if state: # swap
|
||||
info = None
|
||||
bottom = None
|
||||
new_index = getattr(zone, attr) + state
|
||||
setattr(zone, attr, new_index % item_number)
|
||||
|
||||
if new_index == item_number:
|
||||
bottom = 1 # bottom reached, cycle to first
|
||||
elif new_index < 0:
|
||||
bottom = -1 # up reached, cycle to last
|
||||
|
||||
if info_attr:
|
||||
active_item = getattr(zone, active_access) # active by default
|
||||
if active_item:
|
||||
info = getattr(active_item, info_attr)
|
||||
|
||||
return info, bottom
|
||||
|
||||
Reference in New Issue
Block a user