|
@@ -114,6 +114,8 @@ def append_objects(productInfo, index):
|
|
|
|
|
|
# replace_switch_materials(shotInfo, productInfo["ActiveMaterials"])
|
|
|
|
|
|
+ link_collection_to_collection("01_Products", bpy.data.collections[collectionName])
|
|
|
+
|
|
|
|
|
|
def append_active_layers(newCollectionName, product_info):
|
|
|
utility_collections = ["MaterialLibrary", "Animation_Controller", "Animation_Rig"]
|
|
@@ -144,10 +146,10 @@ def append_active_layers(newCollectionName, product_info):
|
|
|
|
|
|
# link appended colections to newCollection
|
|
|
for collection in data_to.collections:
|
|
|
- try:
|
|
|
- bpy.context.scene.collection.children.link(collection)
|
|
|
- except:
|
|
|
- print(collection)
|
|
|
+ # try:
|
|
|
+ # bpy.context.scene.collection.children.link(collection)
|
|
|
+ # except:
|
|
|
+ # print(collection)
|
|
|
link_collection_to_collection(newCollectionName, collection)
|
|
|
|
|
|
# hide utility collections
|
|
@@ -223,9 +225,26 @@ def get_subcollection_names(collection):
|
|
|
return subcollection_names
|
|
|
|
|
|
|
|
|
-# link collection to collection
|
|
|
def link_collection_to_collection(parentCollectionName, childCollection):
|
|
|
|
|
|
+ if bpy.context.scene.collection.children:
|
|
|
+ parentCollection = bpy.context.scene.collection.children.get(
|
|
|
+ parentCollectionName
|
|
|
+ )
|
|
|
+ # Add it to the main collection
|
|
|
+
|
|
|
+ # childCollection = bpy.context.scene.collection.children.get(childCollection)
|
|
|
+
|
|
|
+ parentCollection.children.link(childCollection)
|
|
|
+ # if child collection is in scene collection unlink it
|
|
|
+ if bpy.context.scene.collection.children.get(childCollection.name):
|
|
|
+ bpy.context.scene.collection.children.unlink(childCollection)
|
|
|
+ # bpy.context.scene.collection.children.unlink(childCollection)
|
|
|
+
|
|
|
+
|
|
|
+# link collection to collection
|
|
|
+def link_collection_to_collection_old(parentCollectionName, childCollection):
|
|
|
+
|
|
|
if bpy.context.scene.collection.children:
|
|
|
parentCollection = bpy.context.scene.collection.children.get(
|
|
|
parentCollectionName
|