script to copy physics property (mass, physics type, collision compound)

Hello,
Ive been posting on several forum category but I found nothing to fix a little problem. :S

I’m doing a huge dominoes animation/simulation but the problem is I didn’t set my first cube that I copied as rigid which make all the others static or unselected.

The problem is there’s like 100 cubes +. I could change them manuel but I feel like a script or any other solution could be really useful.

Is there any script for that? (copying physics property ( masses, collission compound, physics type ) from an object to other objects )

thanks in advance!

hi, when you right click on a property copy the data path, then fill this script with your values and add your properties… run it on selected objects and watch console for info on any errors


import bpy
for obj in bpy.context.selected_objects:
    obj.game.physics_type = 'RIGID_BODY'
    obj.game.use_collision_bounds = True
    obj.game.collision_bounds_type = 'BOX'
    obj.game.collision_margin = 0.025
    obj.game.use_material_physics_fh = True

it seems complex!
How do I do that :$?
I’m a big beginner :S
I don’t know what is data path so I just oppened the python console. Selected all cubes and then past the scripts it says syntax error invalide

thanks for the script :smiley:

Hey, liero, uh, thanks?
It seems a very simple and elegant script. Makes me wish I’d paid more attention in Computer Science class.
Thanks for taking the time to post it. Great answer to a question. Gold star for you!

Any explaination :open_mouth: :S?

@franatieu
give me (us) a ‘small’ (say 10 domino) .blend file, than I will try to build that script into it …
It looks like that you have to use ‘Scripting’ building a file (in Blender) put the example script into it and somewhere the game-engine has to
be instructed to use that script at the very first time …

In an old version of Blender I did ‘domino’ game too :evilgrin:
see: http://petertregarg.host22.com/pmwiki/pmwiki.php/Domino/Domino

EDIT:
Nice French tutorial (Bl 2.49 too) http://fractales.3d.free.fr/blender/didacticiels/anim_ge_ipo.htm

Will try how it is now in Bl2.59!!!

EDIT EDIT
(Bl 2.59) if you use Shift D, all properties of the domino are copied (e.g. that they are rigid, after the firs one is made rigid!)

See my example :wink:

Attachments

domino1.blend (61.6 KB)

Thx a lot !

Ill post an example .blend wgen I get home around 5 pm :smiley:
Thx again

example-dominos.blend (404 KB)
hello :stuck_out_tongue:

Yea I know about the shift+D and thow to do an animation, thats what I did but the first cube I duplicated wasn’t set as rigid :S.

Here’s above the .blend you wanted.

Do you think this script would work ? I dont kow how to use it :/. I dont even know what is a data path. lol
import bpy for obj in bpy.context.selected_objects: obj.game.physics_type = ‘RIGID_BODY’ obj.game.use_collision_bounds = True obj.game.collision_bounds_type = ‘BOX’ obj.game.collision_margin = 0.025 obj.game.use_material_physics_fh = True

hi there, just remebered dingto had a simple post on this… give it a read and try again with the script

you are a genious!

thanks a lot! It works :stuck_out_tongue:
I copyed the script into python console and there was an error but when I copy it into the text editor and click run script it actually works!
Thanks again!
I knew you guys would have a solution :smiley:

I tried the (part of the script) in a python console of you blend (after selecting!!! two inbetween cubes)
and it works!
>>> for obj in bpy.context.selected_objects:
… obj.game.physics_type = ‘RIGID_BODY’
… obj.game.use_collision_bounds = True
… obj.game.collision_bounds_type = ‘BOX’
… obj.game.collision_margin = 0.025
… obj.game.use_material_physics_fh = True

>>>

You have to look in the good view, seeing three of the blocks falling down ;-), after pressing a P.