Class: Sketchup::DimensionLinear

Inherits:
Dimension show all

Overview

The DimensionLinear class represents linear dimensions.

Version:

  • SketchUp 2014

Constant Summary #

Sketchup::DimensionLinear::TEXT_OUTSIDE_START
Sketchup::DimensionLinear::TEXT_CENTERED
Sketchup::DimensionLinear::TEXT_OUTSIDE_END
Sketchup::DimensionLinear::ALIGNED_TEXT_ABOVE
Sketchup::DimensionLinear::ALIGNED_TEXT_CENTER
Sketchup::DimensionLinear::ALIGNED_TEXT_OUTSIDE

Constants inherited from Dimension

Sketchup::Dimension::ARROW_CLOSED, Sketchup::Dimension::ARROW_DOT, Sketchup::Dimension::ARROW_NONE, Sketchup::Dimension::ARROW_OPEN, Sketchup::Dimension::ARROW_SLASH

Instance Method Summary # collapse

Methods inherited from Dimension

#add_observer, #arrow_type, #arrow_type=, #has_aligned_text=, #has_aligned_text?, #plane, #remove_observer, #text, #text=

Methods inherited from Drawingelement

#bounds, #casts_shadows=, #casts_shadows?, #erase!, #hidden=, #hidden?, #layer, #layer=, #material, #material=, #receives_shadows=, #receives_shadows?, #visible=, #visible?

Methods inherited from Entity

#add_observer, #attribute_dictionaries, #attribute_dictionary, #delete_attribute, #deleted?, #entityID, #get_attribute, #inspect, #model, #parent, #persistent_id, #remove_observer, #set_attribute, #to_s, #typename, #valid?

Instance Method Details

#aligned_text_positionObject

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:

  • DimensionLinear::ALIGNED_TEXT_ABOVE

  • DimensionLinear::ALIGNED_TEXT_CENTER

  • DimensionLinear::ALIGNED_TEXT_OUTSIDE

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

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:

  • DimensionLinear::ALIGNED_TEXT_ABOVE

  • DimensionLinear::ALIGNED_TEXT_CENTER

  • DimensionLinear::ALIGNED_TEXT_OUTSIDE

Examples:

dim.aligned_text_position = Sketchup::DimensionLinear::ALIGNED_TEXT_CENTER

Returns the text position that was set.

Parameters:

  • pos

    an integer specifying the text position

Returns:

  • the text position that was set.

Version:

  • SketchUp 2014

#endObject

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

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]

Returns self

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

#offset_vectorObject

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(vec) ⇒ Object

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)
# or
dim.offset_vector = [0, 0, 10]

Returns the offset vector that was set

Parameters:

  • vec

    the offset vector to be set, either a Vector3d or in array form.

Returns:

  • the offset vector that was set

Version:

  • SketchUp 2014

#startObject

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

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]

Returns self

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

#text_positionObject

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

  • DimensionLinear::TEXT_OUTSIDE_START

  • DimensionLinear::TEXT_CENTERED

  • DimensionLinear::TEXT_OUTSIDE_END

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

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

  • DimensionLinear::TEXT_OUTSIDE_START

  • DimensionLinear::TEXT_CENTERED

  • DimensionLinear::TEXT_OUTSIDE_END

Examples:

dim.text_position = Sketchup::DimensionLinear::TEXT_CENTERED

Returns the text position that was set.

Parameters:

  • pos

    an integer specifying the text position

Returns:

  • the text position that was set.

Version:

  • SketchUp 2014