sketchup-api-stubs 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/SketchUp/Geom/BoundingBox.rb +335 -0
- data/SketchUp/Geom/LatLong.rb +123 -0
- data/SketchUp/Geom/Point3d.rb +643 -0
- data/SketchUp/Geom/PolygonMesh.rb +478 -0
- data/SketchUp/Geom/Transformation.rb +476 -0
- data/SketchUp/Geom/UTM.rb +135 -0
- data/SketchUp/Geom/Vector3d.rb +684 -0
- data/SketchUp/Sketchup/Animation.rb +137 -0
- data/SketchUp/Sketchup/AppObserver.rb +157 -0
- data/SketchUp/Sketchup/ArcCurve.rb +209 -0
- data/SketchUp/Sketchup/AttributeDictionaries.rb +146 -0
- data/SketchUp/Sketchup/AttributeDictionary.rb +280 -0
- data/SketchUp/Sketchup/Axes.rb +149 -0
- data/SketchUp/Sketchup/Behavior.rb +338 -0
- data/SketchUp/Sketchup/Camera.rb +594 -0
- data/SketchUp/Sketchup/ClassificationSchema.rb +63 -0
- data/SketchUp/Sketchup/Classifications.rb +118 -0
- data/SketchUp/Sketchup/Color.rb +291 -0
- data/SketchUp/Sketchup/ComponentDefinition.rb +562 -0
- data/SketchUp/Sketchup/ComponentInstance.rb +597 -0
- data/SketchUp/Sketchup/Console.rb +78 -0
- data/SketchUp/Sketchup/ConstructionLine.rb +257 -0
- data/SketchUp/Sketchup/ConstructionPoint.rb +32 -0
- data/SketchUp/Sketchup/Curve.rb +196 -0
- data/SketchUp/Sketchup/DefinitionList.rb +312 -0
- data/SketchUp/Sketchup/DefinitionObserver.rb +73 -0
- data/SketchUp/Sketchup/DefinitionsObserver.rb +102 -0
- data/SketchUp/Sketchup/Dimension.rb +167 -0
- data/SketchUp/Sketchup/DimensionLinear.rb +232 -0
- data/SketchUp/Sketchup/DimensionObserver.rb +38 -0
- data/SketchUp/Sketchup/DimensionRadial.rb +87 -0
- data/SketchUp/Sketchup/Drawingelement.rb +400 -0
- data/SketchUp/Sketchup/Edge.rb +517 -0
- data/SketchUp/Sketchup/EdgeUse.rb +213 -0
- data/SketchUp/Sketchup/Entities.rb +1011 -0
- data/SketchUp/Sketchup/EntitiesObserver.rb +125 -0
- data/SketchUp/Sketchup/Entity.rb +522 -0
- data/SketchUp/Sketchup/EntityObserver.rb +59 -0
- data/SketchUp/Sketchup/ExtensionsManager.rb +129 -0
- data/SketchUp/Sketchup/Face.rb +737 -0
- data/SketchUp/Sketchup/FrameChangeObserver.rb +104 -0
- data/SketchUp/Sketchup/Group.rb +705 -0
- data/SketchUp/Sketchup/Http.rb +27 -0
- data/SketchUp/Sketchup/Http/Request.rb +285 -0
- data/SketchUp/Sketchup/Http/Response.rb +62 -0
- data/SketchUp/Sketchup/Image.rb +393 -0
- data/SketchUp/Sketchup/Importer.rb +192 -0
- data/SketchUp/Sketchup/InputPoint.rb +393 -0
- data/SketchUp/Sketchup/InstanceObserver.rb +82 -0
- data/SketchUp/Sketchup/InstancePath.rb +297 -0
- data/SketchUp/Sketchup/Layer.rb +240 -0
- data/SketchUp/Sketchup/Layers.rb +235 -0
- data/SketchUp/Sketchup/LayersObserver.rb +136 -0
- data/SketchUp/Sketchup/Licensing.rb +47 -0
- data/SketchUp/Sketchup/Licensing/ExtensionLicense.rb +88 -0
- data/SketchUp/Sketchup/Loop.rb +141 -0
- data/SketchUp/Sketchup/Material.rb +384 -0
- data/SketchUp/Sketchup/Materials.rb +283 -0
- data/SketchUp/Sketchup/MaterialsObserver.rb +141 -0
- data/SketchUp/Sketchup/Menu.rb +97 -0
- data/SketchUp/Sketchup/Model.rb +1459 -0
- data/SketchUp/Sketchup/ModelObserver.rb +356 -0
- data/SketchUp/Sketchup/OptionsManager.rb +135 -0
- data/SketchUp/Sketchup/OptionsProvider.rb +277 -0
- data/SketchUp/Sketchup/OptionsProviderObserver.rb +58 -0
- data/SketchUp/Sketchup/Page.rb +636 -0
- data/SketchUp/Sketchup/Pages.rb +349 -0
- data/SketchUp/Sketchup/PagesObserver.rb +76 -0
- data/SketchUp/Sketchup/PickHelper.rb +457 -0
- data/SketchUp/Sketchup/RegionalSettings.rb +43 -0
- data/SketchUp/Sketchup/RenderingOptions.rb +337 -0
- data/SketchUp/Sketchup/RenderingOptionsObserver.rb +44 -0
- data/SketchUp/Sketchup/SectionPlane.rb +88 -0
- data/SketchUp/Sketchup/Selection.rb +470 -0
- data/SketchUp/Sketchup/SelectionObserver.rb +115 -0
- data/SketchUp/Sketchup/Set.rb +253 -0
- data/SketchUp/Sketchup/ShadowInfo.rb +257 -0
- data/SketchUp/Sketchup/ShadowInfoObserver.rb +57 -0
- data/SketchUp/Sketchup/Style.rb +77 -0
- data/SketchUp/Sketchup/Styles.rb +204 -0
- data/SketchUp/Sketchup/Text.rb +241 -0
- data/SketchUp/Sketchup/Texture.rb +211 -0
- data/SketchUp/Sketchup/TextureWriter.rb +237 -0
- data/SketchUp/Sketchup/Tool.rb +808 -0
- data/SketchUp/Sketchup/Tools.rb +120 -0
- data/SketchUp/Sketchup/ToolsObserver.rb +154 -0
- data/SketchUp/Sketchup/UVHelper.rb +61 -0
- data/SketchUp/Sketchup/Vertex.rb +143 -0
- data/SketchUp/Sketchup/View.rb +965 -0
- data/SketchUp/Sketchup/ViewObserver.rb +40 -0
- data/SketchUp/UI/Command.rb +307 -0
- data/SketchUp/UI/HtmlDialog.rb +346 -0
- data/SketchUp/UI/Notification.rb +229 -0
- data/SketchUp/UI/Toolbar.rb +243 -0
- data/SketchUp/UI/WebDialog.rb +623 -0
- data/SketchUp/_top_level.rb +193 -0
- data/SketchUp/array.rb +593 -0
- data/SketchUp/geom.rb +231 -0
- data/SketchUp/languagehandler.rb +92 -0
- data/SketchUp/length.rb +210 -0
- data/SketchUp/numeric.rb +249 -0
- data/SketchUp/sketchup.rb +1290 -0
- data/SketchUp/sketchupextension.rb +355 -0
- data/SketchUp/string.rb +24 -0
- data/SketchUp/ui.rb +637 -0
- metadata +176 -0
data/SketchUp/geom.rb
ADDED
@@ -0,0 +1,231 @@
|
|
1
|
+
# Copyright:: Copyright 2017 Trimble Inc.
|
2
|
+
# License:: The MIT License (MIT)
|
3
|
+
|
4
|
+
# The Geom module defines a number of Module methods that let you perform
|
5
|
+
# different geometric operations.
|
6
|
+
#
|
7
|
+
# The methods in this module take lines
|
8
|
+
# and planes as arguments. There is no special class for representing lines or
|
9
|
+
# planes. Arrays are used for both.
|
10
|
+
#
|
11
|
+
# A line can be represented as either an Array of a point and a
|
12
|
+
# vector, or as an Array of two points.
|
13
|
+
# line1 = [Geom::Point3d.new(0, 0, 0), Geom::Vector3d.new(0, 0, 1)]
|
14
|
+
# line2 = [Geom::Point3d.new(0, 0, 0), Geom::Point3d.new(0, 0, 100)]
|
15
|
+
#
|
16
|
+
# A plane can be represented as either an Array
|
17
|
+
# of a point and a vector, or as an Array of 4 numbers that give the
|
18
|
+
# coefficients of a plane equation.
|
19
|
+
# plane1 = [Geom::Point3d.new(0, 0, 0), Geom::Vector3d.new(0, 0, 1)]
|
20
|
+
# plane2 = [0, 0, 1, 0]
|
21
|
+
#
|
22
|
+
# There are several good books on 3D math if you are new to
|
23
|
+
# the concepts of a line, plane, and vector.
|
24
|
+
#
|
25
|
+
# @note Lines and Planes are infinite.
|
26
|
+
#
|
27
|
+
# @version SketchUp 6.0
|
28
|
+
module Geom
|
29
|
+
|
30
|
+
# Class Methods
|
31
|
+
|
32
|
+
# The {.closest_points} method is used to compute the closest points on two
|
33
|
+
# lines.
|
34
|
+
#
|
35
|
+
# @example
|
36
|
+
# line1 = [Geom::Point3d.new(0, 2, 0), Geom::Vector3d.new(1, 0, 0)]
|
37
|
+
# line2 = [Geom::Point3d.new(3, 0, 0), Geom::Vector3d.new(0, 1, 0)]
|
38
|
+
# # This will return a point Point3d(3, 2, 0).
|
39
|
+
# points = Geom.closest_points(line1, line2)
|
40
|
+
#
|
41
|
+
# @param [Array(Geom::Point3d, Geom::Vector3d)] line1
|
42
|
+
# The first line to
|
43
|
+
# intersect
|
44
|
+
#
|
45
|
+
# @param [Array(Geom::Point3d, Geom::Vector3d)] line2
|
46
|
+
# The second line to
|
47
|
+
# intersect
|
48
|
+
#
|
49
|
+
# @return [Array(Geom::Point3d, Geom::Point3d)] An array of two points. The
|
50
|
+
# first point is on the first line and the second point is on the second line.
|
51
|
+
#
|
52
|
+
# @version SketchUp 6.0
|
53
|
+
def self.closest_points(line1, line2)
|
54
|
+
end
|
55
|
+
|
56
|
+
# The {.fit_plane_to_points} method is used to compute a plane that is a best
|
57
|
+
# fit to an array of points. If more than three points are given some of the
|
58
|
+
# points may not be on the plane.
|
59
|
+
#
|
60
|
+
# The plane is returned as an {Array} of 4 numbers which are the
|
61
|
+
# coefficients of the plane equation <code>Ax + By + Cz + D = 0</code>.
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# point1 = Geom::Point3d.new(0, 0, 0)
|
65
|
+
# point2 = Geom::Point3d.new(10, 10, 10)
|
66
|
+
# point3 = Geom::Point3d.new(25, 25, 25)
|
67
|
+
# plane = Geom.fit_plane_to_points(point1, point2, point3)
|
68
|
+
#
|
69
|
+
# @overload fit_plane_to_points(point1, point2, point3, ...)
|
70
|
+
#
|
71
|
+
# @param [Geom::Point3d] point1
|
72
|
+
# @param [Geom::Point3d] point2
|
73
|
+
# @param [Geom::Point3d] point3
|
74
|
+
# @return [Array(Geom::Point3d, Geom::Vector3d)] A plane
|
75
|
+
#
|
76
|
+
# @overload fit_plane_to_points(points)
|
77
|
+
#
|
78
|
+
# @param [Array<Geom::Point3d>] points
|
79
|
+
# @return [Array(Geom::Point3d, Geom::Vector3d)] A plane
|
80
|
+
#
|
81
|
+
# @version SketchUp 6.0
|
82
|
+
def self.fit_plane_to_points(*args)
|
83
|
+
end
|
84
|
+
|
85
|
+
# The {.intersect_line_line} computes the intersection of two lines.
|
86
|
+
#
|
87
|
+
# @example
|
88
|
+
# # Defines a line parallel to the Y axis, offset 20 units.
|
89
|
+
# line1 = [Geom::Point3d.new(20, 0, 0), Geom::Vector3d.new(0, 1, 0)]
|
90
|
+
# # Defines a line parallel to the X axis, offset 10 units.
|
91
|
+
# line2 = [Geom::Point3d.new(0, 10, 0), Geom::Point3d.new(20, 10, 0)]
|
92
|
+
# # This will return a point Point3d(20, 10, 0).
|
93
|
+
# point = Geom.intersect_line_line(line1, line2)
|
94
|
+
#
|
95
|
+
# @param [Array(Geom::Point3d, Geom::Vector3d)] line1
|
96
|
+
# The first line to
|
97
|
+
# intersect.
|
98
|
+
#
|
99
|
+
# @param [Array(Geom::Point3d, Geom::Vector3d)] line2
|
100
|
+
# The second line to
|
101
|
+
# intersect.
|
102
|
+
#
|
103
|
+
# @return [Geom::Point3d, nil] The intersection point. Returns +nil+ if they
|
104
|
+
# do not intersect.
|
105
|
+
#
|
106
|
+
# @see Geom
|
107
|
+
# The Geom module for alternative versions of defining a line.
|
108
|
+
#
|
109
|
+
# @version SketchUp 6.0
|
110
|
+
def self.intersect_line_line(line1, line2)
|
111
|
+
end
|
112
|
+
|
113
|
+
# The {.intersect_line_plane} method is used to compute the intersection of a
|
114
|
+
# line and a plane.
|
115
|
+
#
|
116
|
+
# @example
|
117
|
+
# # Defines a line parallel to the X axis, offset 20 units.
|
118
|
+
# line = [Geom::Point3d.new(-10, 20, 0), Geom::Vector3d.new(1, 0, 0)]
|
119
|
+
# # Defines a plane with it's normal parallel to the x axis.
|
120
|
+
# plane = [Geom::Point3d.new(10, 0 ,0), Geom::Vector3d.new(1, 0, 0)]
|
121
|
+
# # This will return a point Point3d(10, 20, 0).
|
122
|
+
# point = Geom.intersect_line_plane(line, plane)
|
123
|
+
#
|
124
|
+
# @param [Array(Geom::Point3d, Geom::Vector3d)] line
|
125
|
+
#
|
126
|
+
# @param [Array(Geom::Point3d, Geom::Point3d)] plane
|
127
|
+
#
|
128
|
+
# @return [Geom::Point3d, nil] A Point3d object. Returns +nil+ if they do not
|
129
|
+
# intersect.
|
130
|
+
#
|
131
|
+
# @see Geom
|
132
|
+
# The Geom module for alternative versions of defining lines and
|
133
|
+
# planes.
|
134
|
+
#
|
135
|
+
# @version SketchUp 6.0
|
136
|
+
def self.intersect_line_plane(line, plane)
|
137
|
+
end
|
138
|
+
|
139
|
+
# The {.intersect_plane_plane} method is used to compute the intersection of two
|
140
|
+
# planes.
|
141
|
+
#
|
142
|
+
# @example
|
143
|
+
# # Defines a plane with it's normal parallel to the x axis.
|
144
|
+
# plane1 = [Geom::Point3d.new(10, 0 ,0), Geom::Vector3d.new(1, 0, 0)]
|
145
|
+
# # Defines a plane with it's normal parallel to the y axis.
|
146
|
+
# plane2 = [Geom::Point3d.new(0, 20 ,0), Geom::Vector3d.new(0, 1, 0)]
|
147
|
+
# # This will return a line [Point3d(10, 20, 0), Vector3d(0, 0, 1)].
|
148
|
+
# line = Geom.intersect_plane_plane(plane1, plane2)
|
149
|
+
#
|
150
|
+
# @param [Array(Geom::Point3d, Geom::Point3d)] plane1
|
151
|
+
# The first plane to
|
152
|
+
# intersect
|
153
|
+
#
|
154
|
+
# @param [Array(Geom::Point3d, Geom::Point3d)] plane2
|
155
|
+
# The second plane to
|
156
|
+
# intersect
|
157
|
+
#
|
158
|
+
# @return [Array(Geom::Point3d, Geom::Vector3d)] A line where the planes
|
159
|
+
# intersect if successful. Returns +nil+ if the planes do not intersect.
|
160
|
+
#
|
161
|
+
# @version SketchUp 6.0
|
162
|
+
def self.intersect_plane_plane(plane1, plane2)
|
163
|
+
end
|
164
|
+
|
165
|
+
# The {.linear_combination} method is used to compute the linear combination of
|
166
|
+
# points or vectors.
|
167
|
+
#
|
168
|
+
# @example
|
169
|
+
# point1 = Geom::Point3d.new(1, 1, 1)
|
170
|
+
# point2 = Geom::Point3d.new(10, 10, 10)
|
171
|
+
# # Gets the point on the line segment connecting point1 and point2 that is
|
172
|
+
# # 3/4 the way from point1 to point2: Point3d(7.75, 7.75, 7.75).
|
173
|
+
# point = Geom.linear_combination(0.25, point1, 0.75, point2)
|
174
|
+
#
|
175
|
+
# @overload linear_combination(weight1, point1, weight2, point2)
|
176
|
+
#
|
177
|
+
# @param [Float] weight1 A weight or percentage.
|
178
|
+
# @param [Geom::Point3d] point1
|
179
|
+
# @param [Float] weight2 A weight or percentage.
|
180
|
+
# @param [Geom::Point3d] point2
|
181
|
+
# @return [Geom::Point3d]
|
182
|
+
#
|
183
|
+
# @overload linear_combination(weight1, vector1, weight2, vector2)
|
184
|
+
#
|
185
|
+
# @param [Float] weight1 A weight or percentage.
|
186
|
+
# @param [Geom::Vector3d] vector1
|
187
|
+
# @param [Float] weight2 A weight or percentage.
|
188
|
+
# @param [Geom::Vector3d] vector2
|
189
|
+
# @return [Geom::Vector3d]
|
190
|
+
#
|
191
|
+
# @version SketchUp 6.0
|
192
|
+
def self.linear_combination(weight1, pt_or_vect1, weight2, pt_or_vect2)
|
193
|
+
end
|
194
|
+
|
195
|
+
# The {.point_in_polygon_2D} method is used to determine whether a point is
|
196
|
+
# inside a polygon. The z component of both the point you're checking and
|
197
|
+
# the points in the polygon are ignored, effectively making it a 2-d check.
|
198
|
+
#
|
199
|
+
# @example
|
200
|
+
# # Create a point that we want to check. (Note that the 3rd coordinate,
|
201
|
+
# # the z, is ignored for purposes of the check.)
|
202
|
+
# point = Geom::Point3d.new(5, 0, 10)
|
203
|
+
#
|
204
|
+
# # Create a series of points of a triangle we want to check against.
|
205
|
+
# triangle = []
|
206
|
+
# triangle << Geom::Point3d.new(0, 0, 0)
|
207
|
+
# triangle << Geom::Point3d.new(10, 0, 0)
|
208
|
+
# triangle << Geom::Point3d.new(0, 10, 0)
|
209
|
+
#
|
210
|
+
# # Test to see if our point is inside the triangle, counting hits on
|
211
|
+
# # the border as an intersection in this case.
|
212
|
+
# hits_on_border_count = true
|
213
|
+
# status = Geom.point_in_polygon_2D(point, triangle, hits_on_border_count)
|
214
|
+
#
|
215
|
+
# @param [Geom::Point3d] point
|
216
|
+
#
|
217
|
+
# @param [Array<Geom::Point3d>] polygon
|
218
|
+
# An array of points that represent the
|
219
|
+
# corners of the polygon you are checking against.
|
220
|
+
#
|
221
|
+
# @param [Boolean] check_border
|
222
|
+
# Pass true if a point on the border should be
|
223
|
+
# counted as inside the polygon.
|
224
|
+
#
|
225
|
+
# @return [Boolean] +true+ if the point is inside the polygon.
|
226
|
+
#
|
227
|
+
# @version SketchUp 6.0
|
228
|
+
def self.point_in_polygon_2D(point, *polygon, check_border)
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# Copyright:: Copyright 2017 Trimble Inc.
|
2
|
+
# License:: The MIT License (MIT)
|
3
|
+
|
4
|
+
# The LanguageHandler class contains methods used to help make SketchUp
|
5
|
+
# extensions easier to localize across different languages. It looks for
|
6
|
+
# translated resources within the Resources folder in the extension's directory
|
7
|
+
# structure. All translated resources should be located within the appropriate
|
8
|
+
# language folder and encoded in UTF-8. The strings file should include
|
9
|
+
# "key"="value" string pairs in the following format:
|
10
|
+
#
|
11
|
+
# @example Example code that uses LanguageHandler:
|
12
|
+
# # Create a global language handler object
|
13
|
+
# swiveldriver_langHandler = LanguageHandler.new('swiveldriver.strings')
|
14
|
+
#
|
15
|
+
# # Get localized string
|
16
|
+
# localizedStr = swiveldriver_langHandler.GetString('String 1')
|
17
|
+
#
|
18
|
+
# @example
|
19
|
+
# "String 1"="Localized String 1";
|
20
|
+
# "String 2"="Localized String 2";
|
21
|
+
#
|
22
|
+
# @example Here's an example extension directory structure:
|
23
|
+
# gocorp_swiveldriver.rb <- creates the SketchupExtension instance
|
24
|
+
# gocorp_swiveldriver/
|
25
|
+
# gocorp_swiveldriver/Resources/
|
26
|
+
# gocorp_swiveldriver/Resources/en/swiveldriver.strings <- OPTIONAL localization files by language code
|
27
|
+
# gocorp_swiveldriver/Resources/fr/swiveldriver.strings
|
28
|
+
# gocorp_swiveldriver/Resources/es/swiveldriver.strings
|
29
|
+
#
|
30
|
+
# @version SketchUp 2014
|
31
|
+
class LanguageHandler
|
32
|
+
|
33
|
+
# Instance Methods
|
34
|
+
|
35
|
+
# Looks up and returns the localized version of a given string, based on the
|
36
|
+
# language SketchUp is currently running in, and the available translations
|
37
|
+
# in the Resources folder.
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
# swiveldriver_langHandler = LanguageHandler.new('swiveldriver.strings')
|
41
|
+
# localized_string = swiveldriver_langHandler['String 1']
|
42
|
+
#
|
43
|
+
# @param key
|
44
|
+
# The key for the string to be retrieved.
|
45
|
+
#
|
46
|
+
# @return the localized string.
|
47
|
+
#
|
48
|
+
# @version SketchUp 2014
|
49
|
+
def [](key)
|
50
|
+
end
|
51
|
+
|
52
|
+
# The new method is used to create a new LanguageHandler object.
|
53
|
+
#
|
54
|
+
# @example
|
55
|
+
# swiveldriver_langHandler = LanguageHandler.new('swiveldriver.strings')
|
56
|
+
#
|
57
|
+
# @param filename
|
58
|
+
# The name of the file that contains the localized strings
|
59
|
+
# with their keys in UTF-8 encoding.
|
60
|
+
#
|
61
|
+
# @return the new LanguageHandler object
|
62
|
+
#
|
63
|
+
# @version SketchUp 2014
|
64
|
+
def initialize(filename)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Returns a string containing the path to the given filename if it can be found
|
68
|
+
# in the Resources folder.
|
69
|
+
#
|
70
|
+
# @example
|
71
|
+
# swiveldriver_langHandler = LanguageHandler.new('swiveldriver.strings')
|
72
|
+
# image = swiveldriver_langHandler.resource_path('fancy_image.png')
|
73
|
+
#
|
74
|
+
# @return path - the location of the file in the Resources folder.
|
75
|
+
#
|
76
|
+
# @version SketchUp 2014
|
77
|
+
def resource_path
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns a Hash object containing the localization dictionary.
|
81
|
+
#
|
82
|
+
# @example
|
83
|
+
# swiveldriver_langHandler = LanguageHandler.new('swiveldriver.strings')
|
84
|
+
# hash = swiveldriver_langHandler.strings
|
85
|
+
#
|
86
|
+
# @return hash - the localization dictionary.
|
87
|
+
#
|
88
|
+
# @version SketchUp 2014
|
89
|
+
def strings
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
data/SketchUp/length.rb
ADDED
@@ -0,0 +1,210 @@
|
|
1
|
+
# Copyright:: Copyright 2017 Trimble Inc.
|
2
|
+
# License:: The MIT License (MIT)
|
3
|
+
|
4
|
+
# Because length units are used so often in SketchUp, a special class has been
|
5
|
+
# added to make it easier to work with length values. You can use a Length
|
6
|
+
# object any place that you would use a Float.
|
7
|
+
#
|
8
|
+
# Internally, all lengths in SketchUp are stored in inches. The Length class
|
9
|
+
# stores values in inches as well. A number of methods have been added to the
|
10
|
+
# Ruby Numeric class to do units conversions.
|
11
|
+
#
|
12
|
+
# Constants:
|
13
|
+
# Length Format:
|
14
|
+
# - Length::Decimal
|
15
|
+
# - Length::Architectural
|
16
|
+
# - Length::Engineering
|
17
|
+
# - Length::Fractional
|
18
|
+
# Length Unit:
|
19
|
+
# - Length::Inches
|
20
|
+
# - Length::Feet
|
21
|
+
# - Length::Millimeter
|
22
|
+
# - Length::Centimeter
|
23
|
+
# - Length::Meter
|
24
|
+
# The setting for the Length format and Length unit can be retrieved from the
|
25
|
+
# model options by querying the "UnitsOptions" OptionsProvider for
|
26
|
+
# "LengthFormat" and "LengthUnit" respectively.
|
27
|
+
#
|
28
|
+
# @note Prior to SketchUp 2015, Length used to be derived from Float. This is
|
29
|
+
# no longer the case.
|
30
|
+
#
|
31
|
+
# @version SketchUp 6.0
|
32
|
+
class Length < Float
|
33
|
+
|
34
|
+
# Instance Methods
|
35
|
+
|
36
|
+
# The < method is used to see if one length is less than another length.
|
37
|
+
#
|
38
|
+
# For example, if l1 = 1.0.inch and l2 = 1.000001.inch then l1 == l2 so l1
|
39
|
+
# < l2 should return false.
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
# length1 = 12.to_l
|
43
|
+
# length2 = 11.to_l
|
44
|
+
# if length1 < length2
|
45
|
+
# puts "length1 is less than length2"
|
46
|
+
# else
|
47
|
+
# puts "length1 is not less than length2"
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# @param length2
|
51
|
+
# A length value.
|
52
|
+
#
|
53
|
+
# @return status - true if length1 is < length2; false if
|
54
|
+
# length1 is not < length2
|
55
|
+
#
|
56
|
+
# @version SketchUp 6.0
|
57
|
+
def <(length2)
|
58
|
+
end
|
59
|
+
|
60
|
+
# The <= method is used to see if one length is less than or equal to
|
61
|
+
# another length.
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# length1 = 11.to_l
|
65
|
+
# length2 = 12.to_l
|
66
|
+
# if length1 <= length2
|
67
|
+
# puts "length1 is less than or equal length2"
|
68
|
+
# else
|
69
|
+
# puts "length1 is greater than length2"
|
70
|
+
# end
|
71
|
+
#
|
72
|
+
# @param length2
|
73
|
+
# A length value.
|
74
|
+
#
|
75
|
+
# @return status - true if length1 is <= length2; false if
|
76
|
+
# length1 is not <= length2
|
77
|
+
#
|
78
|
+
# @version SketchUp 6.0
|
79
|
+
def <=(length2)
|
80
|
+
end
|
81
|
+
|
82
|
+
# The <=> method is used to see if one length is less than equal or greater
|
83
|
+
# than another length. Because we change == for Length to do a test based on
|
84
|
+
# a tolerance, we also need to change <=> to also take tolerance into account.
|
85
|
+
#
|
86
|
+
# @example
|
87
|
+
# length1 = 20.to_l
|
88
|
+
# length2 = 30.to_l
|
89
|
+
# result = length1 <=> length2
|
90
|
+
#
|
91
|
+
# @param length2
|
92
|
+
# A length value.
|
93
|
+
#
|
94
|
+
# @return result - the result of the comparison
|
95
|
+
#
|
96
|
+
# @version SketchUp 6.0
|
97
|
+
def <=>(length2)
|
98
|
+
end
|
99
|
+
|
100
|
+
# The == method is used to see if one length is equal to another length.
|
101
|
+
#
|
102
|
+
# The equality comparison on Length values uses the default tolerance that
|
103
|
+
# SketchUp uses for comparing lengths.
|
104
|
+
#
|
105
|
+
# @example
|
106
|
+
# length1 = 20.to_l
|
107
|
+
# length2 = 30.to_l
|
108
|
+
# is_equal = length1 == length2
|
109
|
+
#
|
110
|
+
# @param length2
|
111
|
+
# A length value.
|
112
|
+
#
|
113
|
+
# @return status - true if length1 is == length2; false if
|
114
|
+
# length1 is not == length2
|
115
|
+
#
|
116
|
+
# @version SketchUp 6.0
|
117
|
+
def ==(length2)
|
118
|
+
end
|
119
|
+
|
120
|
+
# The > method is used to see if one length is greater than another length.
|
121
|
+
#
|
122
|
+
# For example, if l1 = 1.0.inch and l2 = 1.000001.inch then l1 == l2 so l1 >
|
123
|
+
# l2 should return false.
|
124
|
+
#
|
125
|
+
# @example
|
126
|
+
# length1 = 11.to_l
|
127
|
+
# length2 = 12.to_l
|
128
|
+
# if length1 > length2
|
129
|
+
# puts "length1 is greater than length2"
|
130
|
+
# else
|
131
|
+
# puts "length1 is not greater than length2"
|
132
|
+
# end
|
133
|
+
#
|
134
|
+
# @param length2
|
135
|
+
# A length value.
|
136
|
+
#
|
137
|
+
# @return status - true if length1 is > length2; false if length1
|
138
|
+
# is not > length2
|
139
|
+
#
|
140
|
+
# @version SketchUp 6.0
|
141
|
+
def >(length2)
|
142
|
+
end
|
143
|
+
|
144
|
+
# The >= method is used to see if one length is greater than or equal to
|
145
|
+
# another length.
|
146
|
+
#
|
147
|
+
# For example, if l1 = 1.0.inch and l2 = 1.000001.inch then l1 == l2 so l1 >=
|
148
|
+
# l2 should return true. Also L1 <= l2 would return true.
|
149
|
+
#
|
150
|
+
# @example
|
151
|
+
# length1 = 11.to_l
|
152
|
+
# length2 = 12.to_l
|
153
|
+
# if length1 >= length2
|
154
|
+
# puts "length1 is greater than or equal length2"
|
155
|
+
# else
|
156
|
+
# puts "length1 is less than length2"
|
157
|
+
# end
|
158
|
+
#
|
159
|
+
# @param length2
|
160
|
+
# A length value.
|
161
|
+
#
|
162
|
+
# @return status - true if length1 is >= length2; false if
|
163
|
+
# length1 is not >= length2
|
164
|
+
#
|
165
|
+
# @version SketchUp 6.0
|
166
|
+
def >=(length2)
|
167
|
+
end
|
168
|
+
|
169
|
+
# The inspect method is used to retrieve an unformatted string for the length,
|
170
|
+
# which is the length in inches, regardless of the user's model unit settings.
|
171
|
+
# See Length.to_s for a way automatically format your Length to the user's
|
172
|
+
# model units.
|
173
|
+
#
|
174
|
+
# @example
|
175
|
+
# length = 55.to_l
|
176
|
+
# str = length.inspect
|
177
|
+
#
|
178
|
+
# @return length - an unformatted length string
|
179
|
+
#
|
180
|
+
# @version SketchUp 6.0
|
181
|
+
def inspect
|
182
|
+
end
|
183
|
+
|
184
|
+
# The to_f method is used to convert a length to a normal float.
|
185
|
+
#
|
186
|
+
# @example
|
187
|
+
# length = 45.to_l
|
188
|
+
# f = length.to_f
|
189
|
+
#
|
190
|
+
# @return value - the float length value
|
191
|
+
#
|
192
|
+
# @version SketchUp 6.0
|
193
|
+
def to_f
|
194
|
+
end
|
195
|
+
|
196
|
+
# Format a length as a String using the current units formatting settings
|
197
|
+
# for the model. (So if the user's model is set to feet, this method will
|
198
|
+
# return a nicely formatted length in feet.)
|
199
|
+
#
|
200
|
+
# @example
|
201
|
+
# length = 55.to_l
|
202
|
+
# str = length.to_s
|
203
|
+
#
|
204
|
+
# @return value - the float length value
|
205
|
+
#
|
206
|
+
# @version SketchUp 6.0
|
207
|
+
def to_s
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|