ModraUp Ruby API Documentation Ruby API Reference

Class: ModraUp::Loop

Inherits:
ModraUp::Entity show all

Overview

An ordered loop of edges bounding a face. Each face has one outer loop and one inner loop for each hole. ModraUp::Loop#edgeuses returns the ModraUp::EdgeUse objects around the loop. Inherits from ModraUp::Entity.

Examples:

loop = ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).outer_loop
loop.outer? && loop.convex?

Instance Method Summary # collapse

Inherited from ModraUp::Entity

Instance Method Details

loop.typename ⇒ String

typename + "Loop".

Returns:

  • (String)

Examples:

ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).outer_loop.typename
  #=> "Loop"

loop.entityID ⇒ Integer

The loop entity ID within the current session.

Returns:

  • (Integer)

Examples:

ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).outer_loop.entityID

loop.persistent_id ⇒ Integer

Loops do not have persistent IDs and always have 0 (consistent with SketchUp).

Returns:

  • (Integer)

Examples:

ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).outer_loop.persistent_id

loop.parent ⇒ ModraUp::Model, ModraUp::ComponentDefinition

The owner in the drawing context.

Returns:

  • (ModraUp::Model, ModraUp::ComponentDefinition)

Examples:

ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).outer_loop.parent

loop.valid? ⇒ Boolean

Returns true if the face still exists.

Returns:

  • (Boolean)

Examples:

ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).outer_loop.valid?

loop.deleted? ⇒ Boolean

Opposite of #valid?.

Returns:

  • (Boolean)

Examples:

ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).outer_loop.deleted?
  #=> false

loop.attribute_dictionaries ⇒ nil

Loops do not have attribute dictionaries.

Returns:

  • (nil)

Examples:

ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).outer_loop.attribute_dictionaries
  #=> nil

loop.attribute_dictionary(name) ⇒ nilloop.attribute_dictionary(name, create) ⇒ nil

Loops cannot have attribute dictionaries.

Parameters:

  • name (String)
  • create (Boolean)

Returns:

  • (nil)

Examples:

ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).outer_loop.attribute_dictionary("d")

loop.set_attribute(dict_name, key, value) ⇒ value

Loops do not support attribute dictionaries.

Parameters:

  • dict_name (String)
  • key (String)
  • value (Object)

Raises:

  • [RuntimeError]

Examples:

begin
  ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).outer_loop.set_attribute("d", "k", "v")
rescue RuntimeError
end

loop.get_attribute(dict_name, key) ⇒ nilloop.get_attribute(dict_name, key, default) ⇒ Object

The loop does not have any attributes, so it returns the default value.

Parameters:

  • dict_name (String)
  • key (String)
  • default (Object)

Returns:

  • (Object, nil)

Examples:

ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).outer_loop.get_attribute("d", "k", 1)
  #=> 1

loop.delete_attribute(dict_name) ⇒ nilloop.delete_attribute(dict_name, key) ⇒ nil

Edges have no attributes to delete.

Parameters:

  • dict_name (String)
  • key (String)

Returns:

  • (nil)

Examples:

ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).outer_loop.delete_attribute("d")

loop.convex? ⇒ Boolean

Checks if the loop is convex.

Returns:

  • (Boolean)

Examples:

ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).outer_loop.convex?

loop.edges ⇒ Array<ModraUp::Edge>

Edges in the order of the loop.

Returns:

  • (Array<ModraUp::Edge>)

Examples:

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

loop.face ⇒ ModraUp::Face

The face to which the loop belongs.

Returns:

  • (ModraUp::Face)

Examples:

f = ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0])
f.outer_loop.face == f

loop.outer? ⇒ Boolean

Returns true if the loop is an outer loop.

Returns:

  • (Boolean)

Examples:

ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).outer_loop.outer?

loop.vertices ⇒ Array<ModraUp::Vertex>

Vertices in the order of the loop.

Returns:

  • (Array<ModraUp::Vertex>)

Examples:

ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).outer_loop.vertices.length
  #=> 4

loop.edgeuses ⇒ Array<ModraUp::EdgeUse>

Edge uses in the order of the loop.

Returns:

  • (Array<ModraUp::EdgeUse>)

Raises:

  • [RuntimeError] The loop has been deleted.

Examples:

loop = ModraUp.active_model.entities.add_face([0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]).outer_loop
uses = loop.edgeuses
uses.length == 4 && uses[0].is_a?(ModraUp::EdgeUse)