gpv3 port: create empty frames - add support for group as source
add utility function to check hide-lock state of nested items
This commit is contained in:
@@ -155,6 +155,44 @@ def gp_stroke_to_bmesh(strokes):
|
||||
### GP Drawing
|
||||
# -----------------
|
||||
|
||||
def layer_active_index(gpl):
|
||||
'''Get layer list and return index of active layer
|
||||
Can return None if no active layer found (active item can be a group)
|
||||
'''
|
||||
return next((i for i, l in enumerate(gpl) if l == gpl.active), None)
|
||||
|
||||
## Check for nested lock
|
||||
def is_locked(stack_item):
|
||||
'''Check if passed stack item (layer or group) is locked
|
||||
either itself or by parent groups'''
|
||||
if stack_item.lock:
|
||||
return True
|
||||
if stack_item.parent_group:
|
||||
return is_locked(stack_item.parent_group)
|
||||
return False
|
||||
|
||||
def is_parent_locked(stack_item):
|
||||
'''Check if passed stack item (layer or group) is locked by parent groups'''
|
||||
if stack_item.parent_group:
|
||||
return is_locked(stack_item.parent_group)
|
||||
return False
|
||||
|
||||
## Check for nested hide
|
||||
def is_hidden(stack_item):
|
||||
'''Check if passed stack item (layer or group) is hidden
|
||||
either itself or by parent groups'''
|
||||
if stack_item.hide:
|
||||
return True
|
||||
if stack_item.parent_group:
|
||||
return is_hidden(stack_item.parent_group)
|
||||
return False
|
||||
|
||||
def is_parent_hidden(stack_item):
|
||||
'''Check if passed stack item (layer or group) is hidden by parent groups'''
|
||||
if stack_item.parent_group:
|
||||
return is_hidden(stack_item.parent_group)
|
||||
return False
|
||||
|
||||
def simple_draw_gp_stroke(pts, frame, width = 2, mat_id = 0):
|
||||
'''
|
||||
draw basic stroke by passing list of point 3D coordinate
|
||||
|
||||
Reference in New Issue
Block a user