API reference · 04
Primitive union
A primitiveUnion presents multiple primitives as one ordered collection.
A primitive union object is often created under the scene using mesh.addPrimitiveUnion. We normally never construct a primitive union explicitly from the constructor.
vertices = model.addPrimitiveUnion("vertices", [fixed_vertices, moving_vertices])
addAttribute
addAttribute(name, computed_attribute=None, rows=0, cols=0)Expose one attribute across every member of the primitive union, or bind a computed attribute to the union.
| Parameter | Type | Default | Description |
|---|---|---|---|
name |
str |
required | Attribute name stored on the primitive union. |
computed_attribute |
attribute or None |
None |
Computed expression whose correspondence is this primitive union. |
rows |
int |
0 |
Per-instance row count when explicitly creating union-level data. |
cols |
int |
0 |
Per-instance column count when explicitly creating union-level data. |
Example
# Every member already has "position" with the same shape.
position = vertices.addAttribute("position")
inertia_energy = vertices.addAttribute("inertia_energy", computed_attribute=inertia_expression)
When computed_attribute is omitted and rows and cols remain 0, every member must already contain an attribute with the requested name and shape. The returned attribute stacks those child values in member order.
Returns: attribute.
Raises: ValueError for a duplicate name, a missing child attribute, mismatched child shapes, or a computed attribute that belongs to another correspondence.
__getitem__
primitive_union[key]Retrieve a named primitive union attribute.
| Key | Result |
|---|---|
str |
The named attribute. |
Example
position = vertices["position"]
Raises: KeyError when the attribute is missing or the key is not a string.
Properties
| Property | Type | Description |
|---|---|---|
name |
str |
Primitive union identifier supplied to mesh.addPrimitiveUnion. |
mesh |
mesh | Mesh that owns this primitive union. |
scene |
scene | Scene reached through the owning mesh. |
primitiveUnion |
primitive union | This primitive union itself. |
type |
str |
Always "primitiveUnion". |
numInstances |
int |
Sum of the current instance counts of all members. |
attributes |
dict[str, attribute] |
Named attributes exposed or bound on the primitive union. |
attributesNames |
list[str] |
Names currently stored in attributes. |
fullName |
str |
Scene- and mesh-qualified primitive union identifier. |