ModraUp Ruby API Documentation Ruby API Reference

Class: ModraUp::Edge

Overview

An edge. Inspect its soft and smooth flags, its owning ModraUp::Curve, and its connections to adjacent geometry. Use ModraUp::Edge#find_faces to form faces and ModraUp::Edge#split to split the edge.

Examples:

ModraUp.active_model.entities.add_line([0, 0, 0], [1, 0, 0])

Instance Method Summary # collapse

Inherited from ModraUp::Drawingelement

Inherited from ModraUp::Entity

Instance Method Details

edge.soft? ⇒ Boolean

Soft Edge (hides geometry, selects faces as surfaces).

Returns:

  • (Boolean)

Examples:

ModraUp.active_model.entities.add_line([0, 0, 0], [1, 0, 0]).soft?

edge.soft=(value) ⇒ Boolean

Set the soft edge. Begin a model transaction (if an existing start_operation is provided, include it in the operation).

Parameters:

  • value (Boolean)

Returns:

  • (Boolean)

Examples:

edge = ModraUp.active_model.entities.add_line([0, 0, 0], [1, 0, 0])
edge.soft = true

edge.smooth? ⇒ Boolean

Smooth Edge (adjacent face shading transition).

Returns:

  • (Boolean)

Examples:

ModraUp.active_model.entities.add_line([0, 0, 0], [1, 0, 0]).smooth?

edge.smooth=(value) ⇒ Boolean

Set the edge to smooth. Go through a model transaction.

Parameters:

  • value (Boolean)

Returns:

  • (Boolean)

Examples:

edge = ModraUp.active_model.entities.add_line([0, 0, 0], [1, 0, 0])
edge.smooth = true

edge.start ⇒ ModraUp::Vertex

The start point of an edge.

Returns:

  • (ModraUp::Vertex)

Examples:

ModraUp.active_model.entities.add_line([0, 0, 0], [1, 0, 0]).start.position.to_a
  #=> [0.0, 0.0, 0.0]

edge.end ⇒ ModraUp::Vertex

The endpoint of an edge.

Returns:

  • (ModraUp::Vertex)

Examples:

ModraUp.active_model.entities.add_line([0, 0, 0], [1, 0, 0]).end.position.to_a
  #=> [1.0, 0.0, 0.0]

edge.curve ⇒ ModraUp::Curve, nil

Belongs to a curve, edge, circle, or arc. An independent edge is nil.

Returns:

  • (ModraUp::Curve, nil)

Examples:

ModraUp.active_model.entities.add_circle([0, 0, 0], [0, 0, 1], 5)[0].curve

edge.all_connected ⇒ Array

Returns the faces and edges connected to this edge, including the edge itself.

Returns:

  • (Array<ModraUp::Face, ModraUp::Edge>)

Examples:

ModraUp.active_model.entities.add_line([0, 0, 0], [1, 0, 0]).all_connected.length >= 1

edge.common_face(edge2) ⇒ ModraUp::Face, nil

The face common to two edges.

Parameters:

  • edge2 (ModraUp::Edge)

Returns:

  • (ModraUp::Face, nil)

Examples:

face = ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0])
face.edges[0].common_face(face.edges[1]) == face

edge.explode_curve ⇒ ModraUp::Edge

Remove the associated circle or arc; the edge remains. If not a curve, return it unchanged.

Returns:

  • (ModraUp::Edge)

Examples:

e = ModraUp.active_model.entities.add_circle([0, 0, 0], [0, 0, 1], 5)[0]
e.explode_curve.curve  #=> nil

edge.faces ⇒ Array<ModraUp::Face>

Return the faces that use this edge.

Returns:

  • (Array<ModraUp::Face>)

Examples:

ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).edges[0].faces.length
  #=> 1

edge.find_faces ⇒ Integer

Create all faces that can be formed using this edge, return the count of new faces created. Operates within a model transaction.

Returns:

  • (Integer)

Examples:

ents = ModraUp.active_model.entities
e0 = ents.add_line([0, 0, 0], [1, 0, 0])
ents.add_line([1, 0, 0], [1, 1, 0])
ents.add_line([1, 1, 0], [0, 0, 0])
e0.find_faces >= 1

edge.length ⇒ Lengthedge.length(transform) ⇒ Length

Length (in inches Length). An optional transformation can be applied to calculate the scaled length.

Parameters:

  • transform (Geom::Transformation)

Returns:

  • (Length)

Examples:

ModraUp.active_model.entities.add_line([0, 0, 0], [10, 0, 0]).length == 10

edge.line ⇒ Array(Geom::Point3d, Geom::Vector3d)

Geometric Line: Start Point Plus Direction.

Returns:

  • (Array(Geom::Point3d, Geom::Vector3d))

Examples:

ModraUp.active_model.entities.add_line([0, 0, 0], [1, 0, 0]).line[1].parallel?(X_AXIS)

edge.other_vertex(vertex) ⇒ ModraUp::Vertex

Given one endpoint, return the other endpoint.

Parameters:

  • vertex (ModraUp::Vertex)

Returns:

  • (ModraUp::Vertex)

Examples:

e = ModraUp.active_model.entities.add_line([0, 0, 0], [1, 0, 0])
e.other_vertex(e.start) == e.end

edge.reversed_in?(face) ⇒ Boolean, nil

Does the edge run in the opposite direction of start→end within the face ring? Returns nil if not adjacent.

Parameters:

  • face (ModraUp::Face)

Returns:

  • (Boolean, nil)

Examples:

face = ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0])
face.edges[0].reversed_in?(face).nil? == false

edge.split(position) ⇒ ModraUp::Edge, nil

Split an edge into new edges. The position is a point on the edge or a parameter (between 0 and 1) along the edge, starting from @link #start. The original edge remains from the start to the split point; a new edge is returned from the split point to the end.

Parameters:

  • position (Geom::Point3d, Numeric)

Returns:

  • (ModraUp::Edge, nil)

Examples:

e = ModraUp.active_model.entities.add_line([0, 0, 0], [10, 0, 0])
n = e.split(0.5)
n.end.position.to_a  #=> [10.0, 0.0, 0.0]

edge.used_by?(element) ⇒ Boolean

Does the edge use a given vertex or face.

Parameters:

  • element (ModraUp::Vertex, ModraUp::Face)

Returns:

  • (Boolean)

Examples:

e = ModraUp.active_model.entities.add_line([0, 0, 0], [1, 0, 0])
e.used_by?(e.start)

edge.vertices ⇒ Array<ModraUp::Vertex>

Start and end points.

Returns:

  • (Array<ModraUp::Vertex>)

Examples:

ModraUp.active_model.entities.add_line([0, 0, 0], [1, 0, 0]).vertices.length  #=> 2