Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- import os
- import datetime
- #shortcuts
- context = bpy.context
- scene = context.scene
- A = context.object
- S = bpy.context.selected_objects
- #Date name and .blend name
- time = datetime.datetime.now()
- date= time.strftime("__%Y-%m-%d_%HH%MM%S")
- datecol= time.strftime("%m-%d_%HH%MM%S")
- blend = bpy.path.basename(bpy.data.filepath)[:-6]
- #Collection Copies
- def find_collection(context, item):
- collections = item.users_collection
- if len(collections) > 0:
- return collections[0]
- return context.scene.collection
- def make_collection(collection_name, parent_collection):
- if collection_name in bpy.data.collections:
- return bpy.data.collections[collection_name]
- else:
- new_collection = bpy.data.collections.new(collection_name)
- parent_collection.children.link(new_collection)
- return new_collection
- name = "Copies"
- #Collection Date
- def make_collection(collection_namme, parent_collection):
- if collection_namme in bpy.data.collections:
- return bpy.data.collections[collection_namme]
- else:
- new_collection = bpy.data.collections.new(collection_namme)
- parent_collection.children.link(new_collection)
- return new_collection
- namme = datecol
- #Dupplicate selection and move it to scene master collection
- bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={"linked":False, "mode":'TRANSLATION'})
- bpy.ops.object.move_to_collection(collection_index=0)
- #move every object to new collection
- for C in bpy.context.selected_objects:
- C.name = C.name + " Copy"
- C_collection = find_collection(bpy.context, C)
- new_collection = make_collection(name , C_collection)
- new_collection.objects.link(C)
- C_collection.objects.unlink(C)
- bpy.data.collections["Copies"].hide_select = True
- bpy.data.collections["Copies"].hide_render = True
- bpy.data.collections["Copies"].hide_viewport = True
- C_collection = find_collection(bpy.context, C)
- new_collection = make_collection(namme , C_collection)
- new_collection.objects.link(C)
- C_collection.objects.unlink(C)
- bpy.data.collections[datecol].hide_select = True
- bpy.data.collections[datecol].hide_render = True
- bpy.data.collections[datecol].hide_viewport = True
- bpy.context.view_layer.objects.active = A
- for ob in S:
- ob.select_set(state=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement