0
$\begingroup$

I am trying have 400 flower petals to float and fall delicately to the ground. After getting unsatisfactory results with particles and so I am trying with soft bodies. I cannot find a way to copy all the settings from a master pestle to the other pestles. I also want to add a force field to each pestle which I also cannot not copy to the other pestles.

I have tried the copy addon but it only copies certain modifier settings and not force fields settings etc. I have no idea how to write a python script and to be honest, it strikes me that a simple thing like copying settings should be a basic tool. On the other hand, maybe my method is all wrong and i can do it another way.

When I look at the tools in the physics panel, they work very seperately and I presume that under hood they are very seperate. This is a real shame as it limits dramatically what can be done beyond quite simple effects. I wonder if anyone has looked into moving the physics panel to a nodal based system (only a neophyte like me can suggest such an idea). Also the outliner is really limited in managing elements. it would great to be able to delete modifiers from multiple objects in one go. For the moment I cannot find a way to do that either.

Any thoughts are most welcome.

$\endgroup$
1
$\begingroup$

Despite the settings being presented as a unified collection, there is some inconsistency within the physics settings. The force field, collision and rigid body settings adjust object properties, while the others are modifier properties. While the distinction may seem small it alters the location of settings when trying to access them from python.

If we set obj = bpy.context.active_object then

# force field settings -
obj.field.strength = 1.4
# collision settings
obj.collision.stickiness = 0.4

While modifier properties belong inside the modifier settings data -

# cloth
obj.modifiers["Cloth"].settings.mass = 0.4
# soft body
obj.modifiers["Softbody"].settings.friction = 0.6

We can create a short script to copy the soft body settings from the active object to selected objects.

import bpy

"""
Copy soft body settings from active object to selected objects
"""

srcSoftBody = bpy.context.active_object.modifiers['Softbody']

def mod_copy(source, target):
    for attr in dir(source):
        if attr == 'effector_weights':
            mod_copy(source.effector_weights,target.effector_weights)
        elif not attr.startswith('__'):
            try:
                setattr(target, attr, getattr(source, attr))
            except:
                pass

for obj in bpy.context.selected_objects:
    if obj is not srcobj:
        mod_copy(srcSoftBody.settings,obj.modifiers['Softbody'].settings)

With some small adjustment this could be adapted to be used for other physics settings. While fluid and cloth should work with adjusting the modifier name, smoke and dynamic paint have settings in multiple groups, eg instead of settings smoke uses domain_settings, flow_settings, and coll_settings

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.