Asset Pipeline v2 #145
@ -350,48 +350,6 @@ def import_data_from_lib(
|
||||
## DRIVERS
|
||||
|
||||
|
||||
def copy_driver(from_fcurve, target, data_path=None, index=None):
|
||||
if not data_path:
|
||||
data_path = from_fcurve.data_path
|
||||
|
||||
new_fc = None
|
||||
if index:
|
||||
new_fc = target.driver_add(data_path, index)
|
||||
else:
|
||||
new_fc = target.driver_add(data_path)
|
||||
|
||||
copy_attributes(from_fcurve, new_fc)
|
||||
copy_attributes(from_fcurve.driver, new_fc.driver)
|
||||
|
||||
# Remove default modifiers, variables, etc.
|
||||
for m in new_fc.modifiers:
|
||||
new_fc.modifiers.remove(m)
|
||||
for v in new_fc.driver.variables:
|
||||
new_fc.driver.variables.remove(v)
|
||||
|
||||
# Copy modifiers
|
||||
for m1 in from_fcurve.modifiers:
|
||||
m2 = new_fc.modifiers.new(type=m1.type)
|
||||
copy_attributes(m1, m2)
|
||||
|
||||
# Copy variables
|
||||
for v1 in from_fcurve.driver.variables:
|
||||
v2 = new_fc.driver.variables.new()
|
||||
copy_attributes(v1, v2)
|
||||
for i in range(len(v1.targets)):
|
||||
copy_attributes(v1.targets[i], v2.targets[i])
|
||||
|
||||
return new_fc
|
||||
|
||||
|
||||
def find_drivers(drivers, target_type, target_name):
|
||||
found_drivers = []
|
||||
for driver in drivers:
|
||||
if f'{target_type}["{target_name}"]' in driver.data_path:
|
||||
found_drivers.append(driver)
|
||||
return found_drivers
|
||||
|
||||
|
||||
def get_other_ids(collection): # TODO find better name
|
||||
ref_map = get_id_reference_map()
|
||||
all_ids_of_coll = get_all_referenced_ids(collection, ref_map)
|
||||
|
44
scripts-blender/addons/asset_pipeline_2/drivers.py
Normal file
44
scripts-blender/addons/asset_pipeline_2/drivers.py
Normal file
@ -0,0 +1,44 @@
|
||||
import bpy
|
||||
from rigify.utils.misc import copy_attributes
|
||||
|
||||
|
||||
def copy_driver(from_fcurve, target, data_path=None, index=None):
|
||||
if not data_path:
|
||||
data_path = from_fcurve.data_path
|
||||
|
||||
new_fc = None
|
||||
if index:
|
||||
new_fc = target.driver_add(data_path, index)
|
||||
else:
|
||||
new_fc = target.driver_add(data_path)
|
||||
|
||||
copy_attributes(from_fcurve, new_fc)
|
||||
copy_attributes(from_fcurve.driver, new_fc.driver)
|
||||
|
||||
# Remove default modifiers, variables, etc.
|
||||
for m in new_fc.modifiers:
|
||||
new_fc.modifiers.remove(m)
|
||||
for v in new_fc.driver.variables:
|
||||
new_fc.driver.variables.remove(v)
|
||||
|
||||
# Copy modifiers
|
||||
for m1 in from_fcurve.modifiers:
|
||||
m2 = new_fc.modifiers.new(type=m1.type)
|
||||
copy_attributes(m1, m2)
|
||||
|
||||
# Copy variables
|
||||
for v1 in from_fcurve.driver.variables:
|
||||
v2 = new_fc.driver.variables.new()
|
||||
copy_attributes(v1, v2)
|
||||
for i in range(len(v1.targets)):
|
||||
copy_attributes(v1.targets[i], v2.targets[i])
|
||||
|
||||
return new_fc
|
||||
|
||||
|
||||
def find_drivers(drivers, target_type, target_name):
|
||||
found_drivers = []
|
||||
for driver in drivers:
|
||||
if f'{target_type}["{target_name}"]' in driver.data_path:
|
||||
found_drivers.append(driver)
|
||||
return found_drivers
|
@ -1,7 +1,7 @@
|
||||
import bpy
|
||||
from bpy import context
|
||||
from ..asset_suffix import get_basename
|
||||
from ..core import find_drivers, copy_driver
|
||||
from ..drivers import find_drivers, copy_driver
|
||||
from . import transfer_core # TODO FIX
|
||||
from .. import constants
|
||||
import mathutils
|
||||
|
Loading…
Reference in New Issue
Block a user