Asset Pipeline v2 #145
@ -641,12 +641,15 @@ class ASSETPIPE_OT_batch_ownership_change(bpy.types.Operator):
|
|||||||
]
|
]
|
||||||
return transfer_data_items_to_update
|
return transfer_data_items_to_update
|
||||||
|
|
||||||
def _get_object_to_update(self, context):
|
def _get_objects(self, context):
|
||||||
objs = (
|
asset_objs = context.scene.asset_pipeline.asset_collection.all_objects
|
||||||
context.selected_objects
|
selected_asset_objs = [
|
||||||
if self.data_source == "SELECT"
|
obj for obj in asset_objs if obj in context.selected_objects
|
||||||
else context.scene.objects
|
]
|
||||||
)
|
return asset_objs if self.data_source == "ALL" else selected_asset_objs
|
||||||
|
|
||||||
|
def _get_filtered_objects(self, context):
|
||||||
|
objs = self._get_objects(context)
|
||||||
if self.filter_owners == "LOCAL" and self.data_type == "OBJECT":
|
if self.filter_owners == "LOCAL" and self.data_type == "OBJECT":
|
||||||
return [
|
return [
|
||||||
item
|
item
|
||||||
@ -709,14 +712,12 @@ class ASSETPIPE_OT_batch_ownership_change(bpy.types.Operator):
|
|||||||
if self.data_type == "TRANSFER_DATA":
|
if self.data_type == "TRANSFER_DATA":
|
||||||
box.prop(self, "surrender_selection", expand=True)
|
box.prop(self, "surrender_selection", expand=True)
|
||||||
|
|
||||||
objs = self._get_object_to_update(context)
|
objs = self._get_filtered_objects(context)
|
||||||
if self.data_type == "OBJECT":
|
if self.data_type == "OBJECT":
|
||||||
data_type_name = "Object(s)"
|
data_type_name = "Object(s)"
|
||||||
length = len(objs) if objs else 0
|
length = len(objs) if objs else 0
|
||||||
else:
|
else:
|
||||||
transfer_data_items_to_update = self._get_transfer_data_to_update(
|
transfer_data_items_to_update = self._get_transfer_data_to_update(context)
|
||||||
context, objs
|
|
||||||
)
|
|
||||||
data_type_name = "Transfer Data Item(s)"
|
data_type_name = "Transfer Data Item(s)"
|
||||||
length = (
|
length = (
|
||||||
len(transfer_data_items_to_update)
|
len(transfer_data_items_to_update)
|
||||||
@ -727,15 +728,13 @@ class ASSETPIPE_OT_batch_ownership_change(bpy.types.Operator):
|
|||||||
layout.label(text=f"Change Ownership on {length} {data_type_name}")
|
layout.label(text=f"Change Ownership on {length} {data_type_name}")
|
||||||
|
|
||||||
def execute(self, context: bpy.types.Context):
|
def execute(self, context: bpy.types.Context):
|
||||||
objs = self._get_object_to_update(context)
|
objs = self._get_filtered_objects(context)
|
||||||
|
|
||||||
if self.data_type == "OBJECT":
|
if self.data_type == "OBJECT":
|
||||||
for obj in objs:
|
for obj in objs:
|
||||||
obj.asset_id_owner = self.owner_selection
|
obj.asset_id_owner = self.owner_selection
|
||||||
else:
|
else:
|
||||||
transfer_data_items_to_update = self._get_transfer_data_to_update(
|
transfer_data_items_to_update = self._get_transfer_data_to_update(context)
|
||||||
context, objs
|
|
||||||
)
|
|
||||||
|
|
||||||
for transfer_data_item_to_update in transfer_data_items_to_update:
|
for transfer_data_item_to_update in transfer_data_items_to_update:
|
||||||
if self.surrender_selection:
|
if self.surrender_selection:
|
||||||
|
Loading…
Reference in New Issue
Block a user