How can I change the same parameter on multiple objects efficiently in Blender?

Starting with one cube, I changed some properties (material, color, reflection attributes), and then duplicated the object in a dozen cubes, placing them in the scene. After rendering, I would like to change the color of all of them. How to do it efficiently?

I have already found several ways:

  • In object mode, select all objects ( B , then select the rectangle), connect the ctrl-j grids, change the color, tab in edit mode, P to separate the objects again. This is quite possible, since the grids of all my objects do not touch. Key Documents
  • Someone wrote a Python script to create similar material, here

Number 1 is error prone and too tedious for regular use. Number 2 is more specialized and much worse. Simple selection of several objects and changing the value do not work, because the choice of properties applies only to the active object, which is only one of the selected ones.

Since this is a common use case, I probably skipped the easy way. What is it?

+6
source share
4 answers

While I did not find a very preferred simple button or gui solution, it turned out that hacking native Python code in Blender is easier than you might think.

The cubes I work with are more like domino stones. Subsequently, all objects that look like dominoes have a name starting with "Domino". It is very easy to change all the objects in the scene based on their name:

 for o in bpy.data.objects: if not "Domino" in o.name: continue o.rigid_body.mass = 500 o.rigid_body.friction = 0.4 o.rigid_body.restitution = 0.95 o.rigid_body.angular_damping = 0.2 o.rigid_body.linear_damping = 0.05 

To use this code, I simply opened a new window (drag the upper right triangle icon into any existing Blender window), changed the window type to "Python Console" (lower left window type selection icon), and then paste above the code into it.

The code can be edited in an external text editor. You can also open a text editor window inside Blender. After saving the scene, both the Python console and the internal text editor are saved along the 3D model, which provides a very good workflow.

Finding the right object names, such as bpy.data.objects["Domino.033"].rigid_body.mass , is very simple because Blender displays them when you hover over any form input field. If you have identified the object, use the Python dir() function to get a list of all known methods and attributes of the object. Maybe more than gui allows you to modify or use.

It was a lot easier than I thought. This probably explains why you might think of some complex manipulations for which there is no gui element - it is easier to handle in code. I will probably use this to duplicate and position objects along lines, circles, spirals instead of using the attributes of my own Blender attribute. This will simplify subsequent position adjustments.

+9
source

If you just want to change one parameter for several objects, click RMB on the control (for example, a text box) and select Copy to Selected .

Activate the 3D view: Copy Attributes menu in User Preferences and name it ctrl + c if you want to copy modifiers or such

http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/3D_interaction/Copy_Attributes_Menu

+10
source

Here's the Blender 3D Tip: to work with a bunch of objects at a time, enable the Copy Attributes plugin that comes with Blender, but it’s not enabled by default: open User Preferences, click Add-ons, then find Copy Attributes to find the plugin "3D View: Copy Attributes". Turn on the plugin, then close the settings.

To use :, in the 3D view, select one or more TARGET objects, then finally select the SOURCE object. Press "Ctrl-C" on your keyboard and browse through the menu for each type of attribute that you can copy. Click one (for example, scale), and you will see that the scale of the source object will be applied to previously selected objects.

Here's the manual entry http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/3D_interaction/Copy_Attributes_Menu

This is in response to:

http://obasandbox.wordpress.com/2011/10/23/cg-blender-setting-properties-on-multiple-objects/

+2
source

I am curious why you could not just customize the material. Blender makes it easy to reuse object elements. You can have 100 objects sharing one grid. You can have 100 cells that share a set of 4 materials.

I assume that the domino set will have 21 cells (for all combinations 1-6 x 1-6). These nets would have 2 or 3 materials (one for pips and one or two for the body). If you knit correctly, you can change the color on all the pips by changing one material used by all the grids.

Using python to bulk modify an object is very powerful and applicable to many problems, but sometimes the solution is simpler.

+1
source

Source: https://habr.com/ru/post/945325/


All Articles