Skip to content

kant/smorgasbord

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Buy me a coffee

This repository contains various Blender operators to assist with the simplification, skinning, and material assignment of CAD-derived meshes. It is implemented in pure Python and therefore not always fast in handling high-polygonal meshes. It is also under development, so beware of bugs!

  1. Installation
  2. Operators
    2.1 Replace by Primitive
    2.2 Align Bounds
    2.3 Select Loose by Size
    2.4 Select Similar
    2.5 Transfer Materials
    2.6 Select Concave Parts
    2.7 Lerp Weights
    2.8 Set Parent Advanced
    2.9 Apply Name
    2.10 Select All by Name
    2.11 Replace Duplicate Materials
    2.12 Prepare Export to Unity
    2.13 Vertex Color to Group
    2.14 Remove Empty Vertex Groups
    2.15 Remove Similar UV Maps
    2.16 Force Apply Transform
    2.17 Force Apply Modifier

Installation

Clone the repository to the addons directory in your script path with the command git clone --recurse-submodules https://github.com/D4KU/smorgasbord.git. You can type bpy.utils.script_path_user() into Blender's Python Console to find the path. The existence of submodules makes it unfortunately not possible to obtain the add-on as zip download.

In Blender, navigate to Edit > Preferences > Add-ons and hit the Install button. Navigate to the cloned folder and select the __init__.py file. Make sure to also tick the add-on in the list and save your preferences. Enjoy!

Operators

Replace by Primitive

[Object mode] Object > Transform > Replace by Primitive
[Edit mode] Mesh > Transform > Replace by Primitive

Replace selected objects or vertices by a chosen geometric primitive. This primitive is transformed so its bounding box fits the bounding box of the corresponding selected object or vertex selection as closely as possible. Because this method only compares bounding boxes and does not use a full-blown registration method, an object's apparent rotation can only be matched if it is still accessible via the object's properties and wasn't already applied directly to the mesh data.

Align Bounds

[Object mode] Object > Transform > Align Bounds
[Edit mode] Mesh > Transform > Align Bounds

In Object mode, align any number of selected objects to the active one. As in the Replace by Primitive function, only the object's bounding boxes are aligned, so the same restrictions regarding rotations apply.

In Edit mode this function aligns the bounds around the vertex selection of each individual object to the vertex selection of the active object.

The method ignores pivot points and instead matches the bounding box centers of all meshes/vertex selections. This, and the fact that also rotation and scale are aligned, distinguishes this method from the built-in Align Objects Blender function.

Select Loose by Size

[Edit mode] Select > Select Loose by Size

Select loose parts in the currently edited meshes whose bounding box volume (or diagonal) is greater than a given minimum threshold and less or equal than a given maximum threshold.

Select Similar

[Object mode] Select > Select Similar

This in an implementation of Osada et al.'s paper Matching 3D Models with Shape Distributions. By selecting an object and choosing similarity measure limits, one can find objects with a similar shape in the scene. The method is scale- and rotation-invariant, but it is pretty simple, without any usage of Machine Learning, so similarities between strongly deformed or complex objects can't be reliably detected.

Transfer Materials

[Object mode] Object > Relations > Transfer materials

This operator only exists to compensate the fact that the Data Transfer modifier can't transfer material slots. In every selected target mesh, it finds the closest polygon in the active source mesh and copies over the assigned material.

Select Concave Parts

[Edit mode] Select > Select Concave Parts

By comparing normals of adjacent faces, this operator is able to select concave mesh parts. It defines a concave patch as a set of connected polygons in which at least two polygons face each other by a given angle. The border to neighboring patches is set along edges whose adjacent polygons face away from each other.

Lerp Weights

[Weight Paint mode] Weights > Lerp Weights

By selecting two bones in an armature and vertices in a mesh, this operator is able to linearly interpolate the bones' weights based on the distance between them.

Set Parent Advanced

[Object mode] Object > Parent > Set Parent Advanced

Adds more options to parent one object to another:

  • No Inverse, Keep Transform: Keep no inverse parent correction (the child's origin is the parent's position), but recalculate the transform values so that the child keeps it's world transform.

  • No Inverse, Keep Basis: Keep no inverse parent correction, but keep the transform values set in the property panel. The child object moves.

  • World to Local Origin: The inverse Parent correction is set so that the child's world position before re-parenting becomes its new origin.

Apply Name

[Object mode] Object > Apply > Apply Name

Set the name of an selected object's data block equal to the object name. If several objects link to the same data block, its name is set to the one of the last linked object in the scene hierarchy.

Select All by Name

[Object mode] Select > Select All by Name

Select all objects in the scene whose name either contains, equals, starts with, or ends with a given phrase.

Replace Duplicate Materials

Material Properties > Material Context Menu (v-shape under minus-sign)

For every selected object's material slot, try to replace all assigned duplicate materials with their original by comparing their names. A regular expression, which can be passed to the function as input, specifies how material names are matched. The default expression, .*(?=\.[0-9]+), replaces a material with a suffix containing a dot and a number by the corresponding material without such a suffix, if such a material exists. For example, Plastic_black.001 would be replaced by Plastic_black, if existent.

Prepare Export to Unity

[Object mode] Object > Transform > Prepare Export to Unity

Applies a rotation to every selected object so that when imported to Unity, the Y and Z axis are swapped and no unwanted transformations are applied. The result from applying this operator twice is the same as not applying it at all.

Vertex Color to Group

[Object mode] Object Data Properties > Vertex Group Context Menu

For every selected object, convert the active vertex color layer into a eponymous vertex group. To convert from RGB values to scalar weights either all channels are averaged or only individual ones are passed through.

Remove Empty Vertex Groups

[Object mode] Object Data Properties > Vertex Group Context Menu

For every vertex group of every selected object, delete all groups not containing any weights above a given threshold.

Remove Similar UV Maps

[Object mode] Search

For every active UV map of every selected object, calculate the similarity to other maps and remove them if they fall under a given threshold. Similarity is computed by summing the absolute distances between each pair of UV coordinates in both compared maps.

Force Apply Transform

[Object mode] Object > Apply

Circumvents the restriction that an object's transform can't be applied to its mesh if that mesh is shared with other objects. After applying the active object's transform to the mesh, the local transform of other instances is updated so that they stay in place. If other objects are selected besides the active one, this compensation transformation is only applied to instances within the selection.

Instead of setting the pivot point to the world origin, it can alternatively be set to the cursor. This results in the same behaviour as the built-in Set origin to 3D cursor operator, with the distinction that other instances are updated so that they don't jump around.

Force Apply Modifier

[Object mode] Object > Apply

Circumvents the restriction that modifiers can't be applied to linked data. The data block is copied, the given modifier applied to it, and then the original data block is overwritten with the copy for every selected object. If no object is selected in addition to the active one, all objects in the scene are considered selected.

About

Blender operators to make your life happier. Tasty like a smorgas.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%