-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollection.py
43 lines (31 loc) · 1.1 KB
/
collection.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import bpy
from . registration import get_addon
def get_groups_collection(scene):
mcol = scene.collection
gpcol = bpy.data.collections.get("Groups")
if gpcol:
if gpcol.name not in mcol.children:
mcol.children.link(gpcol)
else:
gpcol = bpy.data.collections.new(name="Groups")
mcol.children.link(gpcol)
return gpcol
def get_scene_collections(scene, ignore_decals=True):
decalmachine, _, _, _ = get_addon("DECALmachine")
mcol = scene.collection
scenecols = []
seen = list(mcol.children)
while seen:
col = seen.pop(0)
if col not in scenecols:
if not (ignore_decals and decalmachine and (col.DM.isdecaltypecol or col.DM.isdecalparentcol)):
scenecols.append(col)
seen.extend(list(col.children))
return scenecols
def get_collection_depth(self, collections, depth=0, init=False):
if init or depth > self.depth:
self.depth = depth
for col in collections:
if col.children:
get_collection_depth(self, col.children, depth + 1, init=False)
return self.depth