Collection Utilities

by Duarte Ramos in Scripts and Addons

Installation

To install download the file named Addon_DPFR_CollectionUtilites_#_##.py and save it to a convenient location.


Under Blender got to the Edit menu and open Preferences > Addons, then press the button on top that reads Install.

Browse to the downloaded file, double-click to install it, then enable it in the check box to the left. If you don't have Autosave Preferences enabled press the Save Preferences button on the bottom left if you want the addon to be available for future sessions by default as well.

Usage

Transfer Names

Transfer Names is a scene organization tool for people who want to keep their data neatly named, helping by transferring names between datablocks

It allows copying names between say object to objectdata, from collections to objects, or collection instance to object.

To use it select a bunch of objects you wish to rename and go to the 3D VIew header menu under Object > Make Links > Transfer Name.


Source parameter dropdown lets you pick where names will be copied from. When picking Collections a new parameter Index will be shown. It can be:

  1. Object - Name of the object
  2. Objectdata - Name of the objectdata associated with the object like a mesh or camera
  3. Collection - One of the collections the object belongs to
  4. Instance - For Empties only, the name of the instanced collection found under the Properties Window > Object > Instance > Instanced Collection.


When set for Collection an additional parameter will be shown called Index. An object may be placed inside several collections simultaneously, when copying to/from collections Blender may pick the wrong one by default. Since these are not saved in any particular order the one picked may seem arbitrary to you. Cycling through the Index will allow you to specify which one to copy the name from. These are pre-sorted alphabetically for more predictable results.

The Copy to parameter defines which targets will be receiving the names selected above, The destination is selected separately with the Copy Name to checkboxes, to allow picking several destinations at the same time.

Likewise when picking collections to be named the optional parameter Index will be used. An object may be placed inside several collections simultaneously, when copying to/from collections Blender may pick the wrong one by default. Since these are not saved in any particular order the one picked may seem arbitrary to you. Cycling through the Index will allow you to specify which one to copy the name to. These are pre-sorted alphabetically for more predictable results.

Optional prefixes and suffixes may be added in the fields bellow.

Set Collection Instance Offset

Set Collection Instance Offset allows defining the Collection Instance Offset parameter for several collection instances at the same time and conveniently from several origin options beyond the default 3D Cursor provided by Blender.

Collection instance offset is a coordinate in 3D space used to define the center of an instanced asset when duplicated using an empty through Add > Collection Instance. The center will be the point placed at the Empty object origin.

These are often neglected, displaced when moving objects or undefined by default for newly created collections.

When creating instances there is often one "main" or "parent"" object which is already placed at the correct position with a desired center coordinate. This operator sets the collection offset directly from the selected object coordinates, avoiding the chore of manually placing the 3D Cursor for each individual collection which quickly grows unmanageable if you have dozens or even hundreds of them.

Most common usecase is selecting a bunch of objects belonging to different collections and whose origins represent the desired collections centers, then go to Object > Collections > Set Offset.

For each axis you have four mutually exclusive options

  1. Leave - Leaves the desired axis coordinate unchanged if it already has the desired coordinate.
  2. Object - Copies coordinates from the selected objects. If multiple are selected the last one is probably used.
  3. Cursor - Same as builtin Blender behavior from the properties window.
  4. Zero - World axis zero, when you want a certain component to remain zero, like for example keeping the center (of a table top instance) on the ground (Z = 0) despite the object being at a height.
  5. Optional manual offset distance for each axis


An additional courtesy operator has been added to the collections context menu in the Properties Window > Object > Collections for convenience of access directly for a single object.

Creation Collections From Objects

Batch collection creation allows you to quickly create collections ready for instancing directly from a bunch of selected objects whose origins already represent the desired collections centers

Go to Object > Collections > Create Collections From Objects and one collection named after the object name will be created for each selected object, and the center set for the position of said object.

This saves tremendous time when you have a lot of instances to setup.

The Mode parameter controls whether the objects are moved to the new collections (and thus removed from current collections they are in) or linked (current collections are kept in addition to the new one), belonging to multiple when the operation finished. This is useful when you already have your scene organized in a certain fashion, and objects already belong to relevant categories you do not wish to lose.

Since a collection is created for each selected object and centers are automatically set from coordinates of selected objects, it is a good practice to only select one object per desired instance collection this object should be the "main body" or "parent" representing the instance center.

Having them all selected would lead to undesirable parasitic collections being  created, and risk that Instance Offset centers being misplaced.

But the whole point of instances is having multiple objects anyway, this defeats the hole purpose. How would I include several objects in the collection?

Ideally these secondary objects would be parented to this "main body" of the collection, and left unselected for the addon to deal with. You can also manually link them later with Ctrl + L > Make Links > Collections

This leads us to the second parameter Child. This allows controlling what happens to unselected child objects parented to the "main" being use for collection creation.

They can also be moved, linked, or left unchanged.

Root controls where news collections will be created. Options for Active Collection or Scene Root are available.

Optional Prefixes and Suffixes can be added to new names