ModraUp Ruby API Documentation Ruby API Reference

Class: Layout::RadialDimension

Inherits:
Layout::Entity show all

Overview

Radial dimensions for arcs or circles: The dimension line passes through the center of the circle or arc and points to the text, with a prefix of R for radius or Ø for diameter.

Note: ModraUp extension. LayOut does not have this feature.

Examples:

r = Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2), Geom::Point2d.new(3.5, 1.5))
d = Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2), nil, true)

Class Method Summary # collapse

Instance Method Summary # collapse

Inherited from Layout::Entity

Class Method Details

Layout::RadialDimension.new(center_point, circle_point, text_point = nil, diameter = false) ⇒ Layout::RadialDimension

Create a radial (or diameter) dimension. The radius is the distance from the circle_point to the center; the dimension line points towards the text_point (defaults to circle_point), with the number placed at text_point not overlapping the arrow.

Parameters:

  • center_point (Geom::Point2d) inch on the drawing sheet
  • circle_point (Geom::Point2d) A point on the circle
  • text_point (Geom::Point2d, nil)
  • diameter (Boolean) true set diameter dimension

Returns:

  • (Layout::RadialDimension)

Raises:

  • [ArgumentError] Point on the circle coincides with the center

Examples:

Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2), Geom::Point2d.new(3.5, 1.5))

Instance Method Details

dimension.center_point ⇒ Geom::Point2d

Center.

Returns:

  • (Geom::Point2d)

Examples:

Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2)).center_point

dimension.circle_point ⇒ Geom::Point2d

The intersection point of the dimension line with the circle (at the arrow).

Returns:

  • (Geom::Point2d)

Examples:

Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2)).circle_point

dimension.text_point ⇒ Geom::Point2d

Position of the text point.

Returns:

  • (Geom::Point2d)

Examples:

Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2), Geom::Point2d.new(3.5, 1.5)).text_point

dimension.text_point = point

Move the digit one step at a time; the dimension line rotates around the center while the radius remains unchanged (similar to dragging within the interface).

Parameters:

  • point (Geom::Point2d)

Returns:

  • (Geom::Point2d)

Examples:

d = Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2))
d.text_point = Geom::Point2d.new(1, 1)

dimension.radius ⇒ Length

Radial dimension on the plane (independent of #diameter?).

Returns:

  • (Length)

Examples:

Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2)).radius  #=> 1.0

dimension.diameter? ⇒ Boolean

Indicates whether the dimension is a diameter.

Returns:

  • (Boolean)

Examples:

Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2), nil, true).diameter?  #=> true

dimension.diameter = diameter

Switch between radius and diameter in one step. Undo the change.

Parameters:

  • diameter (Boolean)

Returns:

  • (Boolean)

Examples:

d = Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2))
d.diameter = true

dimension.text ⇒ Layout::FormattedText

Display the copied text (e.g., R25).

Returns:

  • (Layout::FormattedText)

Examples:

Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2)).text.plain_text

dimension.text = formatted_text

Customize the text, <> represents prefixed numerical values, and perform one step of undo.

Parameters:

  • formatted_text (Layout::FormattedText, String)

Returns:

  • (Layout::FormattedText, String)

Examples:

d = Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2))
d.text = "<> through hole"

dimension.custom_text? ⇒ Boolean

Whether to use custom text.

Returns:

  • (Boolean)

Examples:

Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2)).custom_text?  #=> false

dimension.custom_text = custom

Set false to restore the display of the measurement value.

Parameters:

  • custom (Boolean)

Returns:

  • (Boolean)

Examples:

Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2)).custom_text = false

dimension.scale ⇒ Float

Scale factor (ratio), same as Layout::LinearDimension#scale.

Returns:

  • (Float)

Examples:

Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2)).scale  #=> 1.0

dimension.scale = ratio

Set the scale factor for the radial dimension, and perform an undo step.

Parameters:

  • ratio (Numeric)

Returns:

  • (Numeric)

Raises:

  • [ArgumentError] must be a positive number

Examples:

1:20

d = Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2))
d.scale = 1.0 / 20

dimension.precision ⇒ Integer

Decimal places; -1 follows the model's setting.

Returns:

  • (Integer)

Examples:

Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2)).precision  #=> -1

dimension.precision = digits

Set the decimal precision, with one step in undo.

Parameters:

  • digits (Integer) -1 or 0~3

Returns:

  • (Integer)

Raises:

  • [ArgumentError] Out of range

Examples:

d = Layout::RadialDimension.new(Geom::Point2d.new(2, 2), Geom::Point2d.new(3, 2))
d.precision = 1