Class: ModraUp::Group
- Inherits:
-
ModraUp::Drawingelement
- Object
- ModraUp::Entity
- ModraUp::Drawingelement
- ModraUp::Group
Overview
Group instances.
Instance Method Summary # collapse
-
#definition ⇒ ModraUp::ComponentDefinition
The definition corresponding to the group.
-
#name ⇒ String
Group name. An empty string if unnamed.
-
#name=(name) ⇒ String
Set the name of the group.
-
#entities ⇒ ModraUp::Entities
Returns the group's drawing context. Editing geometry here first calls #make_unique, so other copies retain the shared definition. Editing through ModraUp::ComponentDefinition#entities changes all instances of that definition.
-
#transformation ⇒ Geom::Transformation
Transformation of a group within its parent drawing context.
-
#transformation=(transformation) ⇒ Geom::Transformation
Sets the transformation of the group within its parent drawing context.
-
#transform!(transformation) ⇒ ModraUp::Group
Apply the transformation by left multiplication.
-
#explode ⇒ Array<ModraUp::Entity>, false
Explodes the group into its parent drawing context. The parent can be an unclosed group or a definition. Returns false on failure.
-
#make_unique ⇒ ModraUp::Group
If any other group shares the same definition, make a unique copy of the definition and point only this group to it. If it is already unique, perform no operation.
-
#to_component ⇒ ModraUp::ComponentInstance, nil
Convert this group into a component instance. Other copies sharing the definition remain groups. The group object is then #deleted?. The parent context does not need to be the active drawing context (groups or definitions not in use can be converted, consistent with SketchUp).
-
#copy ⇒ ModraUp::Group
Copy this group within the same parent context. The new group has its own definition with identical geometry and instance properties as the source group.
-
#scaled_size ⇒ Array<Numeric>
Apply the scaled group definition bounding box size.
-
#local_bounds ⇒ Geom::BoundingBox
Define the group's local bounding box without including the group's transform.
-
#add_observer(observer) ⇒ Boolean
Register a ModraUp::InstanceObserver. Adding the same object a second time returns false.
-
#remove_observer(observer) ⇒ Boolean
Remove the previously registered instance observer.
-
#description ⇒ String
Description of the group definition.
-
#description=(text) ⇒ String
Set the description text for the group definition (same as ModraUp::ComponentDefinition#description=).
-
#guid ⇒ String
Base64 unique ID for the group placement. Will be an empty string if not imported.
-
#manifold? ⇒ Boolean
Deprecated: Same as ModraUp::ComponentDefinition#manifold?.
-
#volume ⇒ Float
Returns the volume in cubic inches. The value is positive for a manifold solid and negative for non-manifold geometry.
-
#move!(transformation) ⇒ ModraUp::Group, nil
Set the transformation without recording it in the undo stack.
-
#subtract(other) ⇒ ModraUp::Group, nil
Subtract this group from other (result is other - this group). The result is a new group in the parent context (geometry baked into the parent space, transformed to the identity matrix). Both must be manifold shells in the same parent ModraUp::Entities. On success, both are deleted. Returns nil if either is not a manifold shell, the result is empty, one is locked, deleted, or not in the same parent context, with no model change.
-
#trim(other) ⇒ ModraUp::Group, nil
Cut the other group with this group. The group remains unchanged; other is replaced by other minus this group, with the result returned as a new group in the same parent context. Failure conditions are the same as for #subtract, returning nil without modifying the model.
-
#union(other) ⇒ ModraUp::Group, nil
The union of this group with other, resulting in a new group in the parent context. Both sides are deleted upon success. Failure conditions are the same as for ##subtract.
-
#intersect(other) ⇒ ModraUp::Group, nil
The intersection volume between this group and other. The result is a new group in the parent context (geometry baked into the parent space). Both entities must be manifold shells in the same parent ModraUp::Entities. If successful, both entities are deleted. If they do not intersect, are non-manifold, locked, deleted, or not in the same parent context, it returns nil, with the model unchanged.
-
#outer_shell(other) ⇒ ModraUp::Group, nil
The outer surface of two manifold shells (volume union, internal faces removed). The result is a new group in the parent context. Both are deleted if successful. Solids do not need to intersect: if they are completely separate, both shells remain in the resulting group; if one completely encloses the other, only the outer shell remains. Failure conditions are the same as for #intersect.
-
#split(other) ⇒ Array(ModraUp::Group, ModraUp::Group, ModraUp::Group), nil
Splits two manifold solids at their intersection. Returns three new groups on Layer0 in this order: the part of other outside the receiver (Difference2), the part of the receiver outside other (Difference1), and their shared volume (Intersection). The operation removes the original objects. If the volumes do not overlap, the intersection group is empty and the difference groups contain the original solids. For a non-manifold input or a failed operation, returns nil and leaves the model unchanged.
-
#show_differences(other) ⇒ Boolean
Compares the volumes of two manifold solids in their shared parent space. Returns true for equal volumes in the same location, otherwise false. Both containers move to Layer0. Coincident faces and edges go on a layer ending in _same and remaining geometry on a layer ending in _diff. The prefix is the group instance name (or its definition name if empty), or the component definition name. With verbose enabled, the console lists the centers of differing faces. A non-manifold, locked, deleted, or differently parented input returns false without changing the model. Shared definitions are made unique first, preserving other instances.
-
#hatch_pattern ⇒ ModraUp::HatchPattern, nil
Read the hatch pattern of this group/component itself. It also applies to nested groups and components, taking precedence over material patterns.
-
#hatch_pattern=(hatch_pattern) ⇒ ModraUp::HatchPattern, nil
Sets the hatch pattern for this group/component itself, no material assignment needed; nil removes the pattern.
Inherited from ModraUp::Drawingelement
-
#layer ⇒ ModraUp::Layer
Layer it belongs to (Tag). Defaults to Layer0 if not specified.
-
#layer=(layer) ⇒ ModraUp::Layer, String
Set the layer. The string must be an existing layer name, otherwise an error is thrown.
-
#bounds ⇒ Geom::BoundingBox
Axis-aligned bounding box.
-
#locked? ⇒ Boolean
Locked. Locked faces/edges cannot be erased.
-
#locked=(value) ⇒ Boolean
Set the lock. Begin a model transaction (if an existing start_operation is present, incorporate it into this operation).
-
#casts_shadows? ⇒ Boolean
Casts shadows. Defaults to true. Viewport shadows are not yet enabled.
-
#casts_shadows=(value) ⇒ Boolean
Sets whether the drawing element casts shadows.
-
#receives_shadows? ⇒ Boolean
Returns whether the drawing element receives shadows. Defaults to true. Viewport shadows are not enabled yet.
-
#receives_shadows=(value) ⇒ Boolean
Sets whether the drawing element receives shadows.
-
#material ⇒ ModraUp::Material, nil
Materials. If unspecified, it defaults to nil. ModraUp::Edge, ModraUp::Face (front), ModraUp::Group, ModraUp::ComponentInstance, ModraUp::Image, ModraUp::Text, ModraUp::Dimension, ModraUp::ConstructionLine, ModraUp::ConstructionPoint, and ModraUp::SectionPlane all inherit this method. The back of a ModraUp::Face uses Face#back_material.
-
#material=(material) ⇒ ModraUp::Material, String, ModraUp::Color, nil
Set the material. nil clears it. The string is first interpreted as a material name, then as a CSS/X11 color name. Subclasses inherit this method;
-
#hidden? ⇒ Boolean
Returns whether the element itself is hidden. Layer hiding is not considered.
-
#hidden=(hidden) ⇒ Boolean
Sets itself to hidden. Transacts the model (if an existing start_operation is present, it is included in that operation).
-
#visible? ⇒ Boolean
Returns true if the element is not hidden (opposite of #hidden?). The layer may still hide it.
-
#visible=(visibility) ⇒ Boolean
Opposite of #hidden=.
-
#erase! ⇒ nil
Delete this face, edge, group, component instance, or linear dimension. The containing set does not have to be the active drawing context.
Inherited from ModraUp::Entity
-
#typename ⇒ String
Type name (e.g., Face / Edge / Group).
-
#entityID ⇒ Integer
Entity ID within the current session: A small integer starting from 1 that increments and remains constant for the lifetime of the entity, unchanged by undo/redo operations. This ID is not preserved when saving the file; it will be renumbered upon reopening the model. For cross-session identification, use #persistent_id. Copied entities will receive new IDs.
-
#persistent_id ⇒ Integer
Number assigned with the model: A unique, incrementing small integer starting from 1 that persists across model saves and reloads, independent of #entityID. Copied entities receive new numbers, and deleted entities do not reuse their numbers. Edges, faces, vertices, curves, groups, component instances/definitions, dimensions, leader lines/points, section planes, materials, layers, layer folders, and drawing sheets have assigned numbers; all others (rings, EdgeUses, attribute dictionaries, line types, sets, etc.) return 0.
-
#parent ⇒ ModraUp::Model, ModraUp::ComponentDefinition
Returns the owner of this drawing context. At the root this is the model. Inside a definition it is the definition itself.
-
#model ⇒ ModraUp::Model
The model it belongs to.
-
#to_s ⇒ String
String form. Returns "#<Deleted Entity>” when the entity has been deleted.
-
#inspect ⇒ String
Same as #to_s.
-
#attribute_dictionaries ⇒ ModraUp::AttributeDictionaries, nil
Collection of attribute dictionaries. Returns nil (evaluates to false) if there are no dictionaries.
-
#attribute_dictionary(name) ⇒ ModraUp::AttributeDictionary, nil
Retrieve an attribute dictionary by name. If none exists, return nil; if create is true, create an empty dictionary. ModraUp::Loop / ModraUp::EdgeUse / ModraUp::Curve always return nil.
-
#valid? ⇒ Boolean
Returns true if the entity is valid, meaning it has not been deleted from the model. Revoked entities are false; even if new geometry is drawn occupying its original position, this object remains an invalid entity (still false). Repeating the action to restore it makes it valid again.
-
#deleted? ⇒ Boolean
Opposite of #valid?.
-
#set_attribute(dict_name, key, value) ⇒ Object
Write attribute values. Materials, groups, component instances, faces, and edges are supported. When dict_name and key are Symbols, they are converted to strings. The type of data written is the same type that will be read back.
-
#get_attribute(dict_name, key, default = nil) ⇒ Object
Read the attribute. If dict_name and key are Symbols, convert them to strings (similar to SketchUp). If the dictionary or key does not exist, return default. The return value type is the same as what is written by #set_attribute.
-
#delete_attribute(dict_name) ⇒ Boolean
Delete a key, or delete the entire dictionary when the key is omitted.
Instance Method Details
group.definition ⇒ ModraUp::ComponentDefinition
The definition corresponding to the group.
group.name ⇒ String
Group name. An empty string if unnamed.
group.name=(name) ⇒ String
Set the name of the group.
group.entities ⇒ ModraUp::Entities
Returns the group's drawing context. Editing geometry here first calls #make_unique, so other copies retain the shared definition. Editing through ModraUp::ComponentDefinition#entities changes all instances of that definition.
group.transformation ⇒ Geom::Transformation
Transformation of a group within its parent drawing context.
group.transformation=(transformation) ⇒ Geom::Transformation
Sets the transformation of the group within its parent drawing context.
group.transform!(transformation) ⇒ self
Apply the transformation by left multiplication.
group.explode ⇒ Array<ModraUp::Entity>, false
Explodes the group into its parent drawing context. The parent can be an unclosed group or a definition. Returns false on failure.
group.make_unique ⇒ ModraUp::Group
If any other group shares the same definition, make a unique copy of the definition and point only this group to it. If it is already unique, perform no operation.
group.to_component ⇒ ModraUp::ComponentInstance
Convert this group into a component instance. Other copies sharing the definition remain groups. The group object is then #deleted?. The parent context does not need to be the active drawing context (groups or definitions not in use can be converted, consistent with SketchUp).
group.copy ⇒ ModraUp::Group
Copy this group within the same parent context. The new group has its own definition with identical geometry and instance properties as the source group.
group.scaled_size ⇒ Array<Numeric>
Apply the scaled group definition bounding box size.
group.local_bounds ⇒ Geom::BoundingBox
Define the group's local bounding box without including the group's transform.
group.add_observer(observer) ⇒ Boolean
Register a ModraUp::InstanceObserver. Adding the same object a second time returns false.
group.remove_observer(observer) ⇒ Boolean
Remove the previously registered instance observer.
group.description ⇒ String
Description of the group definition.
group.description=(text) ⇒ String
Set the description text for the group definition (same as ModraUp::ComponentDefinition#description=).
group.guid ⇒ String
Base64 unique ID for the group placement. Will be an empty string if not imported.
group.manifold? ⇒ Boolean
Deprecated: Same as ModraUp::ComponentDefinition#manifold?.
group.volume ⇒ Float
Returns the volume in cubic inches. The value is positive for a manifold solid and negative for non-manifold geometry.
group.move!(transformation) ⇒ ModraUp::Group, nil
Set the transformation without recording it in the undo stack.
group.subtract(other) ⇒ ModraUp::Group, nil
Subtract this group from other (result is other - this group). The result is a new group in the parent context (geometry baked into the parent space, transformed to the identity matrix). Both must be manifold shells in the same parent ModraUp::Entities. On success, both are deleted. Returns nil if either is not a manifold shell, the result is empty, one is locked, deleted, or not in the same parent context, with no model change.
group.trim(other) ⇒ ModraUp::Group, nil
Cut the other group with this group. The group remains unchanged; other is replaced by other minus this group, with the result returned as a new group in the same parent context. Failure conditions are the same as for #subtract, returning nil without modifying the model.
group.union(other) ⇒ ModraUp::Group, nil
The union of this group with other, resulting in a new group in the parent context. Both sides are deleted upon success. Failure conditions are the same as for ##subtract.
group.intersect(other) ⇒ ModraUp::Group, nil
The intersection volume between this group and other. The result is a new group in the parent context (geometry baked into the parent space). Both entities must be manifold shells in the same parent ModraUp::Entities. If successful, both entities are deleted. If they do not intersect, are non-manifold, locked, deleted, or not in the same parent context, it returns nil, with the model unchanged.
group.outer_shell(other) ⇒ ModraUp::Group, nil
The outer surface of two manifold shells (volume union, internal faces removed). The result is a new group in the parent context. Both are deleted if successful. Solids do not need to intersect: if they are completely separate, both shells remain in the resulting group; if one completely encloses the other, only the outer shell remains. Failure conditions are the same as for #intersect.
group.split(other) ⇒ Array(ModraUp::Group, ModraUp::Group, ModraUp::Group), nil
Splits two manifold solids at their intersection. Returns three new groups on Layer0 in this order: the part of other outside the receiver (Difference2), the part of the receiver outside other (Difference1), and their shared volume (Intersection). The operation removes the original objects. If the volumes do not overlap, the intersection group is empty and the difference groups contain the original solids. For a non-manifold input or a failed operation, returns nil and leaves the model unchanged.
group.show_differences(other) ⇒ Booleangroup.show_differences(other, verbose) ⇒ Boolean
Compares the volumes of two manifold solids in their shared parent space. Returns true for equal volumes in the same location, otherwise false. Both containers move to Layer0. Coincident faces and edges go on a layer ending in _same and remaining geometry on a layer ending in _diff. The prefix is the group instance name (or its definition name if empty), or the component definition name. With verbose enabled, the console lists the centers of differing faces. A non-manifold, locked, deleted, or differently parented input returns false without changing the model. Shared definitions are made unique first, preserving other instances.
#hatch_pattern ⇒ ModraUp::HatchPattern, nil
Read the hatch pattern of this group/component itself. It also applies to nested groups and components, taking precedence over material patterns.
#hatch_pattern=(hatch_pattern) ⇒ ModraUp::HatchPattern, nil
Sets the hatch pattern for this group/component itself, no material assignment needed; nil removes the pattern.