Asset Pipeline v2 #145
@ -346,15 +346,15 @@ def import_data_from_lib(
|
|||||||
## DRIVERS
|
## DRIVERS
|
||||||
|
|
||||||
|
|
||||||
def copy_driver(from_fcurve, obj, data_path=None, index=None):
|
def copy_driver(from_fcurve, target, data_path=None, index=None):
|
||||||
if not data_path:
|
if not data_path:
|
||||||
data_path = from_fcurve.data_path
|
data_path = from_fcurve.data_path
|
||||||
|
|
||||||
new_fc = None
|
new_fc = None
|
||||||
if index:
|
if index:
|
||||||
new_fc = obj.driver_add(data_path, index)
|
new_fc = target.driver_add(data_path, index)
|
||||||
else:
|
else:
|
||||||
new_fc = obj.driver_add(data_path)
|
new_fc = target.driver_add(data_path)
|
||||||
|
|
||||||
copy_attributes(from_fcurve, new_fc)
|
copy_attributes(from_fcurve, new_fc)
|
||||||
copy_attributes(from_fcurve.driver, new_fc.driver)
|
copy_attributes(from_fcurve.driver, new_fc.driver)
|
||||||
@ -380,15 +380,9 @@ def copy_driver(from_fcurve, obj, data_path=None, index=None):
|
|||||||
return new_fc
|
return new_fc
|
||||||
|
|
||||||
|
|
||||||
def find_drivers(obj, target_type, target_name):
|
def find_drivers(drivers, target_type, target_name):
|
||||||
drivers = []
|
found_drivers = []
|
||||||
for driver in obj.animation_data.drivers:
|
for driver in drivers:
|
||||||
if f'{target_type}["{target_name}"]' in driver.data_path:
|
if f'{target_type}["{target_name}"]' in driver.data_path:
|
||||||
drivers.append(driver)
|
found_drivers.append(driver)
|
||||||
return drivers
|
return found_drivers
|
||||||
|
|
||||||
|
|
||||||
def copy_all_drivers(source_obj, target_obj, driver_target_type, driver_target_name):
|
|
||||||
fcurves = find_drivers(source_obj, driver_target_type, driver_target_name)
|
|
||||||
for fcurve in fcurves:
|
|
||||||
copy_driver(from_fcurve=fcurve, obj=target_obj)
|
|
||||||
|
@ -224,7 +224,11 @@ def transfer_modifier(modifier_name, target_obj, source_obj):
|
|||||||
{"object": target_obj, "active_object": target_obj},
|
{"object": target_obj, "active_object": target_obj},
|
||||||
modifier=mod.name,
|
modifier=mod.name,
|
||||||
)
|
)
|
||||||
core.copy_all_drivers(source_obj, target_obj, 'modifiers', modifier_name)
|
fcurves = core.find_drivers(
|
||||||
|
source_obj.animation_data.drivers, 'modifiers', modifier_name
|
||||||
|
)
|
||||||
|
for fcurve in fcurves:
|
||||||
|
core.copy_driver(from_fcurve=fcurve, target=target_obj)
|
||||||
|
|
||||||
|
|
||||||
# CONSTRAINTS
|
# CONSTRAINTS
|
||||||
|
Loading…
Reference in New Issue
Block a user