123456789_123456789_123456789_123456789_123456789_

Class: Sketchup::DimensionLinear

Relationships
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Sketchup::Dimension

Overview

The DimensionLinear class represents linear dimensions.

Version:

  • SketchUp 2014

Constant Summary

Dimension - Inherited

ARROW_CLOSED, ARROW_DOT, ARROW_NONE, ARROW_OPEN, ARROW_SLASH

Instance Attribute Summary

Dimension - Inherited

#arrow_type

The arrow_type method retrieves the current arrow type of the dimension.

#arrow_type=

The arrow_type= method sets the arrow type of the dimension.

#has_aligned_text=

The has_aligned_text= method accepts true or false indicating whether the dimension’s text is aligned to the dimension or to the screen.

#has_aligned_text?

The has_aligned_text method is used to determine whether the dimension’s text is aligned to the dimension or to the screen.

#text

The text method is used to retrieve the dimension text.

#text=

The text= method is used to set an override on the dimension text.

Drawingelement - Inherited

#casts_shadows=

The casts_shadows= method is used to set the Drawingelement to cast shadows.

#casts_shadows?

The casts_shadows? method is used to determine if the Drawingelement is casting shadows.

#hidden=

The hidden= method is used to set the hidden status for an element.

#hidden?

The hidden? method is used to determine if the element is hidden.

#layer

The layer method is used to retrieve the Layer object of the drawing element.

#layer=

The layer= method is used to set the layer for the drawing element.

#material

The material method is used to retrieve the material for the drawing element.

#material=

The material= method is used to set the material for the drawing element.

#receives_shadows=

The receive_shadows= method is used to set the Drawingelement to receive shadows.

#receives_shadows?

The receive_shadows? method is used to determine if the Drawingelement is receiving shadows.

#visible=

The visible= method is used to set the visible status for an element.

#visible?

The visible? method is used to get the visible status for an element.

Entity - Inherited

#deleted?

The deleted? method is used to determine if your entity is still valid (not deleted by another script, for example.).

#valid?

The #valid? method is used to determine if your entity is still valid (not deleted by another script, for example).

Instance Method Summary

Dimension - Inherited

#add_observer

The add_observer method is used to add a DimensionObserver to the dimension.

#plane

The plane method is used to retrieve the plane of the dimension.

#remove_observer

The remove_observer method is used to remove a DimensionObserver from the dimension.

Drawingelement - Inherited

#bounds

The #bounds method is used to retrieve the ::Geom::BoundingBox bounding a Drawingelement.

#erase!

The #erase! method is used to erase an element from the model.

Entity - Inherited

#add_observer

The add_observer method is used to add an observer to the current object.

#attribute_dictionaries

The attribute_dictionaries method is used to retrieve the AttributeDictionaries collection attached to the entity.

#attribute_dictionary

The attribute_dictionary method is used to retrieve an attribute dictionary with a given name that is attached to an Entity.

#delete_attribute

The #delete_attribute method is used to delete an attribute from an entity.

#entityID

The entityID method is used to retrieve a unique ID assigned to an entity.

#get_attribute

The #get_attribute method is used to retrieve the value of an attribute in the entity’s attribute dictionary.

#inspect

The #inspect method is used to retrieve the string representation of the entity.

#model

The model method is used to retrieve the model for the entity.

#parent

The parent method is used to retrieve the parent of the entity.

#persistent_id

The #persistent_id method is used to retrieve a unique persistent id assigned to an entity.

#remove_observer

The remove_observer method is used to remove an observer from the current object.

#set_attribute

The set attribute is used to set the value of an attribute in an attribute dictionary with the given name.

#to_s

The #to_s method is used to retrieve the string representation of the entity.

#typename

The typename method retrieves the type of the entity, which will be a string such as “Face”, “Edge”, or “Group”.

Instance Attribute Details

#aligned_text_positionObject (rw)

The aligned_text_position method returns the text position for dimensions with aligned text (i.e. has_aligned_text? returns true). Valid values are class constants:

Examples:

pos = dim.aligned_text_position
if pos == Sketchup::DimensionLinear::ALIGNED_TEXT_ABOVE
  puts 'Text is above'
elsif pos == Sketchup::DimensionLinear::ALIGNED_TEXT_CENTER
  puts 'Text is centered'
elsif pos == Sketchup::DimensionLinear::ALIGNED_TEXT_OUTSIDE
  puts 'Text is outside'
end

Returns:

  • an integer specifying the text position

Version:

  • SketchUp 2014

#aligned_text_position=(pos) ⇒ Object (rw)

The aligned_text_position= method is used to set the text position for dimensions with aligned text (i.e. has_aligned_text? returns true). Valid values are class constants:

Examples:

dim.aligned_text_position = Sketchup::DimensionLinear::ALIGNED_TEXT_CENTER

Parameters:

  • pos

    an integer specifying the text position

Returns:

  • the text position that was set.

Version:

  • SketchUp 2014

#endObject (rw)

The end method returns the point or entity the dimension is referencing at its end.

Examples:

arr = dim.end
if arr[0].nil?
  puts "No attached entity. Point is #{arr[1]}"
else
  puts "Attached entity: #{arr[0]}, at point #{arr[1]}"
end

Returns:

  • ::Array - An array of size 2:

    • Entity being referenced or nil if not associated.

    • Point3d that contains the referenced location.

Version:

  • SketchUp 2014

#end=(pt_or_entity) ⇒ Object (rw)

The end= method is used to set the end point of the dimension and/or the entity it is referencing.

Examples:

# Reference a point
dim.end = [50, 10, 0]
# Reference end vertex of an edge
dim.end = edge.end
# Attach to an edge's midpoint
p0 = edge.start.position
p1 = edge.end.position
mp = Geom::Point3d.new((p0.x+p1.x)/2.0, (p0.y+p1.y)/2.0, (p0.z+p1.z)/2.0)
dim.end = [edge, mp]

Parameters:

  • pt_or_entity

    This parameter can take several forms:

    • an InputPoint

    • a Point3d

    • a Vertex

    • a ConstructionPoint

    • an array of size 2: [Edge, Point3d along the edge]

    • an array of size 2: [ConstructionLine, Point3d along the line]

Returns:

  • self

Version:

  • SketchUp 2014

#end_attached_toArray(Sketchup::InstancePath, Geom::Point3d)? (rw)

The #end_attached_to method will return the attached end point via an array containing the InstancePath and ::Geom::Point3d.

Examples:

# Assuming you have a valid dimension selected that is attached to a
# component instance
dim = Sketchup.active_model.selection[0]
dim.end_attached_to

Version:

  • SketchUp 2019

#end_attached_to=(path) (rw)

The #end_attached_to= method will attach the ending point to the InstancePath and ::Geom::Point3d.

Examples:

# Assuming you have a valid dimension selected that is attached to a
# component instance
dim = Sketchup.active_model.selection[0]
# get the path (instance_path, point)
path = dim.end_attached_to
instance_path = path[0]
instance = instance_path.to_a[0]
point1 = Geom::Point3d.new(0, 0, 0)
point2 = Geom::Point3d.new(20, 20, 20)
instance.definition.entities.add_edges(point1, point2)
edge = instance.definition.entities.grep(Sketchup::Edge).first
new_instance_path = Sketchup::InstancePath.new([instance, edge])
point2 = point2.transform(new_instance_path.transformation.inverse)
dim.end_attached_to = [new_instance_path, point2]

Parameters:

Version:

  • SketchUp 2019

#offset_vectorObject (rw)

The offset_vector method returns the parallel offset vector from the reference line to the dimension line measured from the ‘start’ reference point.

Examples:

vec = dim.offset_vector
puts "Offset vector is #{vec.to_s}"

Returns:

  • offset vector as a Vector3d

Version:

  • SketchUp 2014

#offset_vector=(offset_vector) (rw)

The offset_vector= method is used to set the parallel offset vector from the reference line to the dimension line measured from the ‘start’ reference point.

Examples:

dim.offset_vector = Geom::Vector3d.new(0, 0, 10)

Parameters:

Version:

  • SketchUp 2014

#startObject (rw)

The start method returns the point or entity the dimension is referencing at its start.

Examples:

arr = dim.start
if arr[0].nil?
  puts "No attached entity. Point is #{arr[1]}"
else
  puts "Attached entity: #{arr[0]}, at point #{arr[1]}"
end

Returns:

  • ::Array - An array of size 2:

    • Entity being referenced or nil if not associated.

    • Point3d that contains the referenced location.

Version:

  • SketchUp 2014

#start=(pt_or_entity) ⇒ Object (rw)

The start= method is used to set the start point of the dimension and/or the entity it is referencing.

Examples:

# Reference a point
dim.start = [50, 10, 0]
# Reference end vertex of an edge
dim.start = edge.end
# Attach to an edge's midpoint
p0 = edge.start.position
p1 = edge.end.position
mp = Geom::Point3d.new((p0.x+p1.x)/2.0, (p0.y+p1.y)/2.0, (p0.z+p1.z)/2.0)
dim.start = [edge, mp]

Parameters:

  • pt_or_entity

    This parameter can take several forms:

    • an InputPoint

    • a Point3d

    • a Vertex

    • a ConstructionPoint

    • an array of size 2: [Edge, Point3d along the edge]

    • an array of size 2: [ConstructionLine, Point3d along the line]

Returns:

  • self

Version:

  • SketchUp 2014

#start_attached_toArray(Sketchup::InstancePath, Geom::Point3d)? (rw)

The #start_attached_to method will return the attached start point via an array containing the InstancePath and ::Geom::Point3d.

Examples:

# Assuming you have a valid dimension selected that is attached to a
# component instance
dim = Sketchup.active_model.selection[0]
dim.start_attached_to

Version:

  • SketchUp 2019

#start_attached_to=(path) (rw)

The #start_attached_to= method will attach the starting point to the InstancePath and ::Geom::Point3d.

Examples:

# Assuming you have a valid dimension selected that is attached to a
# component instance
dim = Sketchup.active_model.selection[0]
# get the path (instance_path, point)
path = dim.start_attached_to
instance_path = path[0]
instance = instance_path.to_a[0]
point1 = Geom::Point3d.new(0, 0, 0)
point2 = Geom::Point3d.new(20, 20, 20)
instance.definition.entities.add_edges(point1, point2)
edge = instance.definition.entities.grep(Sketchup::Edge).first
new_instance_path = Sketchup::InstancePath.new([instance, edge])
point2 = point2.transform(new_instance_path.transformation.inverse)
dim.start_attached_to = [new_instance_path, point2]

Parameters:

Version:

  • SketchUp 2019

#text_positionObject (rw)

The text_position method returns the position of the text along the dimension line. Valid values are class constants:

Examples:

pos = dim.text_position
if pos == Sketchup::DimensionLinear::TEXT_OUTSIDE_START
  puts 'Text position is Outside start'
elsif pos == Sketchup::DimensionLinear::TEXT_CENTERED
  puts 'Text position is Centered'
elsif pos == Sketchup::DimensionLinear::TEXT_OUTSIDE_END
  puts 'Text position is Outside end'
end

Returns:

  • an integer specifying the text position

Version:

  • SketchUp 2014

#text_position=(pos) ⇒ Object (rw)

The text_position= method is used to set the position of the text along the dimension line. Valid values are class constants:

Examples:

dim.text_position = Sketchup::DimensionLinear::TEXT_CENTERED

Parameters:

  • pos

    an integer specifying the text position

Returns:

  • the text position that was set.

Version:

  • SketchUp 2014