0
$\begingroup$

So the issue im trying to solve is how would you copy all modifier settings or attributes (like Collisions) from an active object to other selected objects? I have many objects I need to copy settings across all of them.

I have already tried "Copy from Active", but that just copies ridge body settings. I tried to use the "Copy Attributes", but that just copies the modifier and not the settings. Is there a way to write a script that will do that? The ultimate way would be to link it to a button in the UI.

I have little knowledge of python. I was able to write a script to make a button make a simple operator..so I get the basic idea, but i don't know how to write an operator to do what i would like.

Any answers would be appreciated.

$\endgroup$

1 Answer 1

1
$\begingroup$

Copy collision settings

use dir(x) to get list of attribute

import bpy

def try_set_attr(ob_from, ob_to, attr):
    try:
        setattr(ob_to, attr, getattr(ob_from, attr))
    except:
        pass

def copy_collision():
    active_obj      = bpy.context.object
    selected_objs   = bpy.context.selected_objects

    for md_act in active_obj.modifiers:
        if md_act.type == 'COLLISION':
            for obj in selected_objs:
                if obj == active_obj:   continue
                if obj.type != "MESH":  continue
                coll_md = None
                for md in obj.modifiers:
                    if md.type == 'COLLISION':
                        coll_md = md
                        break
                
                if coll_md is None:
                    coll_md = obj.modifiers.new(type='COLLISION', name='Collision')

                for attr in dir(coll_md):
                    try_set_attr(md_act, coll_md, attr)

                setting_from    = md_act.settings
                setting_to      = coll_md.settings
                
                for attr in dir(setting_to):
                    try_set_attr(setting_from, setting_to, attr)
            break

copy_collision()
$\endgroup$
2
  • $\begingroup$ Thank you very much. I will try this im my project. $\endgroup$
    – M Burns
    May 4, 2022 at 19:49
  • $\begingroup$ It works like a charm. exactly what i needed. Thanks you again! $\endgroup$
    – M Burns
    May 4, 2022 at 20:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .