Class: ModraUp::Face
- Inherits:
-
ModraUp::Drawingelement
- Object
- ModraUp::Entity
- ModraUp::Drawingelement
- ModraUp::Face
Overview
A planar polygon. Access its front material through the inherited ModraUp::Drawingelement#material and ModraUp::Drawingelement#material= methods. Use ModraUp::Face#back_material and ModraUp::Face#back_material= for the back.
Constants # collapse
- ModraUp::Face::PointUnknown
Face#classify_point cannot be determined.
- ModraUp::Face::PointInside
Point inside the face (not on an edge or vertex).
- ModraUp::Face::PointOnVertex
The point lies on a face vertex.
- ModraUp::Face::PointOnEdge
The point lies on the edge of the face.
- ModraUp::Face::PointOnFace
Point on Face (preserve constant; current category is PointInside / boundary constant).
- ModraUp::Face::PointOutside
Point lies on the face plane but is outside (including within holes).
- ModraUp::Face::PointNotOnPlane
The point is not on the plane of the face.
Instance Method Summary # collapse
-
#pushpull(distance, copy = false) ⇒ nil
Push-pull along the face normal. The isolated face remains in the starting plane; the default push-pull moves the vertices of the solid surface, and copy set to true retains the starting face.
-
#material ⇒ ModraUp::Material, nil
Front material. Inherits from Drawingelement#material. Back face material is seen at Face#back_material.
-
#material=(material) ⇒ ModraUp::Material, String, ModraUp::Color, nil
Set the face material. Inherited from Drawingelement#material=. nil clears the material. No need to open the group/component.
-
#back_material ⇒ ModraUp::Material, nil
Back material. Only ModraUp::Face has this method. If not assigned, it is nil.
-
#back_material=(material) ⇒ ModraUp::Material, String, ModraUp::Color, nil
Sets the back material. Only ModraUp::Face has this method. nil clears it. No need to open the group/component.
-
#all_connected ⇒ Array<ModraUp::Face, ModraUp::Edge>
Returns the faces and edges connected by edges to this face, including the face itself.
-
#area ⇒ Float
Area (in square inches). An optional transformation can be used to calculate the scaled 'visual' area.
-
#classify_point(point) ⇒ Integer
Determine the position of the point relative to the face. Compare it with constants like PointInside instead of hardcoding integers.
-
#coplanar_with?(other_face) ⇒ Boolean
Whether two faces are coplanar.
-
#edges ⇒ Array<ModraUp::Edge>
Edges surrounding the face (outer ring followed by inner rings, with duplicates removed).
-
#followme(edges) ⇒ Boolean
Section plane sweeps along the edge chain. Failure does not modify the model.
-
#loops ⇒ Array<ModraUp::Loop>
The outer loop comes first, followed by the holes.
-
#normal ⇒ Geom::Vector3d
Normal to the face.
-
#outer_loop ⇒ ModraUp::Loop
Outer loop.
-
#plane ⇒ Array<Float>
Plane [A, B, C, D] (Ax + By + Cz + D = 0).
-
#reverse! ⇒ ModraUp::Face, false
Flip the face. Go through a model transaction.
-
#vertices ⇒ Array<ModraUp::Vertex>
Vertices surrounding the face (outer ring followed by inner rings, with duplicates removed).
-
#mesh ⇒ Geom::PolygonMesh
Triangulate the face into a mesh. flags can be bitwise combined: 1 front UVQ, 2 back UVQ, 4 normal. Omitting flags results in points and triangles; hidden edge point numbers are negative.
-
#get_UVHelper ⇒ ModraUp::UVHelper
Returns the helper object for the current UV transformation of the face. When the face has been ModraUp::TextureWriter#loaded by a ModraUp::TextureWriter, it uses the cached UVs (consistent with the viewport tessellation).
-
#position_material(material, points, front) ⇒ ModraUp::Face, false
Pins the material using world and UV point pairs. Supply 2, 4, 6, or 8 Geom::Point3d values in points, alternating between world and UV coordinates.
-
#clear_texture_position(front) ⇒ nil
Clear the texture position and projection for the specified face, restoring the default texture position.
-
#clear_texture_projection(front) ⇒ nil
Clears the projection flag and retains the texture positioning.
-
#get_texture_projection(front) ⇒ Geom::Vector3d, nil
Returns the texture projection direction; returns nil if there is no texture projection.
-
#texture_projected?(front) ⇒ Boolean
Returns whether the specified face has a projected texture.
-
#texture_positioned?(front) ⇒ Boolean
Determines whether the texture on the specified face is explicitly positioned.
-
#set_texture_projection(vector, front) ⇒ Object
This deprecated interface throws NotImplementedError starting with SketchUp 2021.1; please use the projection parameter of the position_material method.
-
#get_glued_instances ⇒ Array<ModraUp::ComponentInstance, ModraUp::Group>
Returns the instances and groups glued to this face in the same drawing context.
-
#uv_tile_at(position, front) ⇒ Array<Geom::Point3d>, nil
Returns the four corners of the texture brick surrounding the reference point, alternately in model points and UV points, which can be used for position_material; returns nil if there is no texture.
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.
-
#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.
-
#add_observer(observer) ⇒ Boolean
Register a ModraUp::EntityObserver. Adding the same object a second time returns false. Locking, property, and material changes will dispatch an onChangeEntity event.
-
#remove_observer(observer) ⇒ Boolean
Remove the entity observer.
-
#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
face.pushpull(distance, copy = false) ⇒ nil
Push-pull along the face normal. The isolated face remains in the starting plane; the default push-pull moves the vertices of the solid surface, and copy set to true retains the starting face.
face.material ⇒ ModraUp::Material, nil
Front material. Inherits from Drawingelement#material. Back face material is seen at Face#back_material.
face.material=(material) ⇒ material
Set the face material. Inherited from Drawingelement#material=. nil clears the material. No need to open the group/component.
face.back_material ⇒ ModraUp::Material, nil
Back material. Only ModraUp::Face has this method. If not assigned, it is nil.
face.back_material=(material) ⇒ material
Sets the back material. Only ModraUp::Face has this method. nil clears it. No need to open the group/component.
face.all_connected ⇒ Array
Returns the faces and edges connected by edges to this face, including the face itself.
face.area ⇒ Floatface.area(transform) ⇒ Float
Area (in square inches). An optional transformation can be used to calculate the scaled 'visual' area.
face.classify_point(point) ⇒ Integer
Determine the position of the point relative to the face. Compare it with constants like PointInside instead of hardcoding integers.
face.coplanar_with?(other_face) ⇒ Boolean
Whether two faces are coplanar.
face.edges ⇒ Array<ModraUp::Edge>
Edges surrounding the face (outer ring followed by inner rings, with duplicates removed).
face.followme(edges) ⇒ Booleanface.followme(edge) ⇒ Boolean
Section plane sweeps along the edge chain. Failure does not modify the model.
face.loops ⇒ Array<ModraUp::Loop>
The outer loop comes first, followed by the holes.
face.normal ⇒ Geom::Vector3d
Normal to the face.
face.outer_loop ⇒ ModraUp::Loop
Outer loop.
face.plane ⇒ Array
Plane [A, B, C, D] (Ax + By + Cz + D = 0).
face.reverse! ⇒ ModraUp::Face, false
Flip the face. Go through a model transaction.
face.vertices ⇒ Array<ModraUp::Vertex>
Vertices surrounding the face (outer ring followed by inner rings, with duplicates removed).
face.mesh ⇒ Geom::PolygonMeshface.mesh(flags) ⇒ Geom::PolygonMesh
Triangulate the face into a mesh. flags can be bitwise combined: 1 front UVQ, 2 back UVQ, 4 normal. Omitting flags results in points and triangles; hidden edge point numbers are negative.
face.get_UVHelper ⇒ ModraUp::UVHelperface.get_UVHelper(front, back) ⇒ ModraUp::UVHelperface.get_UVHelper(front, back, texture_writer) ⇒ ModraUp::UVHelper
Returns the helper object for the current UV transformation of the face. When the face has been ModraUp::TextureWriter#loaded by a ModraUp::TextureWriter, it uses the cached UVs (consistent with the viewport tessellation).
face.position_material(material, points, front) ⇒ ModraUp::Face, falseface.position_material(material, points, front, projection) ⇒ ModraUp::Face, false
Pins the material using world and UV point pairs. Supply 2, 4, 6, or 8 Geom::Point3d values in points, alternating between world and UV coordinates.
face.clear_texture_position(front) ⇒ nil
Clear the texture position and projection for the specified face, restoring the default texture position.
face.clear_texture_projection(front) ⇒ nil
Clears the projection flag and retains the texture positioning.
face.get_texture_projection(front) ⇒ Geom::Vector3d, nil
Returns the texture projection direction; returns nil if there is no texture projection.
face.texture_projected?(front) ⇒ Boolean
Returns whether the specified face has a projected texture.
face.texture_positioned?(front) ⇒ Boolean
Determines whether the texture on the specified face is explicitly positioned.
face.set_texture_projection(vector, front)
This deprecated interface throws NotImplementedError starting with SketchUp 2021.1; please use the projection parameter of the position_material method.
face.get_glued_instances ⇒ Array<ModraUp::ComponentInstance, ModraUp::Group>
Returns the instances and groups glued to this face in the same drawing context.
face.uv_tile_at(position, front) ⇒ Array<Geom::Point3d>, nil
Returns the four corners of the texture brick surrounding the reference point, alternately in model points and UV points, which can be used for position_material; returns nil if there is no texture.