parent
da86da59ce
commit
266079410a
|
@ -17,7 +17,7 @@ Activate / deactivate all masks using MA layers
|
|||
0.6.8
|
||||
|
||||
- feat: New multi-scene viewlayer inspection button
|
||||
- fix: revert back export json crop to use GP names when available
|
||||
- fix: revert back export json crop to use GP names when available with better check
|
||||
|
||||
0.6.7
|
||||
|
||||
|
|
36
fn.py
36
fn.py
|
@ -786,6 +786,23 @@ def get_bbox_3d(ob):
|
|||
bbox_coords = ob.bound_box
|
||||
return [ob.matrix_world @ Vector(b) for b in bbox_coords]
|
||||
|
||||
def is_render_included(o, scn):
|
||||
'''return True if object is in at least one non-excluded collection
|
||||
in all passed scene viewlayer
|
||||
'''
|
||||
|
||||
if o.hide_render:
|
||||
return False
|
||||
for vl in scn.view_layers:
|
||||
all_cols = get_collection_childs_recursive(vl.layer_collection)
|
||||
for c in all_cols:
|
||||
print(c.name)
|
||||
if o in c.collection.objects[:]:
|
||||
if not c.exclude:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def get_crop_pixel_coord(scn):
|
||||
# width height probably not needed. might need
|
||||
px_width = (scn.render.border_max_x - scn.render.border_min_x) * scn.render.resolution_x
|
||||
|
@ -828,8 +845,8 @@ def export_crop_to_json():
|
|||
## Only scn name (meaning only one name to refer if multiple GP)
|
||||
# coord_dic[scn.name] = scn_border
|
||||
|
||||
## use name of first found GP :
|
||||
gps = [o for o in scn.objects if o.type == 'GPENCIL']
|
||||
## use name of first found visible GP (scene name if no visible GP)
|
||||
gps = [o for o in scn.objects if o.type == 'GPENCIL' if is_render_included(o, scn)] # o.visible_get() < only work on active window
|
||||
if gps:
|
||||
for ob in gps:
|
||||
coord_dic[ob.name] = scn_border
|
||||
|
@ -1026,18 +1043,24 @@ def set_box_from_selected_objects(scn=None, cam=None, export_json=False):
|
|||
_bbox_px = set_border_region_from_coord(coords, margin=30, scn=scn, export_json=export_json)
|
||||
|
||||
|
||||
def get_collection_childs_recursive(col, cols=[]):
|
||||
def get_collection_childs_recursive(col, cols=[], include_root=True):
|
||||
'''return a list of all the sub-collections in passed col'''
|
||||
# force start from fresh list (otherwise same cols list is used at next call)
|
||||
cols = cols or []
|
||||
|
||||
for sub in col.children:
|
||||
if sub not in cols:
|
||||
cols.append(sub)
|
||||
if len(sub.children):
|
||||
cols = get_collection_childs_recursive(sub, cols)
|
||||
|
||||
if include_root and col not in cols: # add root col
|
||||
cols.append(col)
|
||||
|
||||
return cols
|
||||
|
||||
def unlink_objects_from_scene(oblist, scn):
|
||||
all_col = [scn.collection]
|
||||
all_col += get_collection_childs_recursive(scn.collection)
|
||||
all_col = get_collection_childs_recursive(scn.collection)
|
||||
for col in all_col:
|
||||
for ob in reversed(col.objects):
|
||||
if ob in oblist:
|
||||
|
@ -1075,8 +1098,7 @@ def split_object_to_scene():
|
|||
# new.render.filepath = f'/tmp/'
|
||||
|
||||
## unlink unwanted objects from collection
|
||||
all_col = [new.collection]
|
||||
all_col += get_collection_childs_recursive(new.collection)
|
||||
all_col = get_collection_childs_recursive(new.collection)
|
||||
for col in all_col:
|
||||
for sob in reversed(col.objects):
|
||||
if sob.type in ('CAMERA', 'LIGHT'):
|
||||
|
|
Loading…
Reference in New Issue