sketchup-api-stubs 0.7.4 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sketchup-api-stubs.rb +1 -1
- data/lib/sketchup-api-stubs/sketchup.rb +147 -145
- data/lib/sketchup-api-stubs/stubs/Geom/BoundingBox.rb +322 -318
- data/lib/sketchup-api-stubs/stubs/Geom/Bounds2d.rb +172 -172
- data/lib/sketchup-api-stubs/stubs/Geom/LatLong.rb +126 -126
- data/lib/sketchup-api-stubs/stubs/Geom/OrientedBounds2d.rb +102 -102
- data/lib/sketchup-api-stubs/stubs/Geom/Point2d.rb +400 -400
- data/lib/sketchup-api-stubs/stubs/Geom/Point3d.rb +661 -661
- data/lib/sketchup-api-stubs/stubs/Geom/PolygonMesh.rb +498 -492
- data/lib/sketchup-api-stubs/stubs/Geom/Transformation.rb +478 -478
- data/lib/sketchup-api-stubs/stubs/Geom/Transformation2d.rb +263 -263
- data/lib/sketchup-api-stubs/stubs/Geom/UTM.rb +141 -141
- data/lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb +522 -522
- data/lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb +691 -691
- data/lib/sketchup-api-stubs/stubs/Layout.rb +25 -25
- data/lib/sketchup-api-stubs/stubs/Layout/AngularDimension.rb +573 -573
- data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinition.rb +411 -411
- data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinitions.rb +179 -174
- data/lib/sketchup-api-stubs/stubs/Layout/ConnectionPoint.rb +70 -70
- data/lib/sketchup-api-stubs/stubs/Layout/Document.rb +515 -514
- data/lib/sketchup-api-stubs/stubs/Layout/Ellipse.rb +29 -29
- data/lib/sketchup-api-stubs/stubs/Layout/Entities.rb +148 -143
- data/lib/sketchup-api-stubs/stubs/Layout/Entity.rb +353 -353
- data/lib/sketchup-api-stubs/stubs/Layout/FormattedText.rb +349 -349
- data/lib/sketchup-api-stubs/stubs/Layout/Grid.rb +311 -311
- data/lib/sketchup-api-stubs/stubs/Layout/Group.rb +261 -261
- data/lib/sketchup-api-stubs/stubs/Layout/Image.rb +91 -91
- data/lib/sketchup-api-stubs/stubs/Layout/Label.rb +370 -371
- data/lib/sketchup-api-stubs/stubs/Layout/Layer.rb +218 -218
- data/lib/sketchup-api-stubs/stubs/Layout/LayerInstance.rb +128 -128
- data/lib/sketchup-api-stubs/stubs/Layout/Layers.rb +225 -220
- data/lib/sketchup-api-stubs/stubs/Layout/LinearDimension.rb +567 -567
- data/lib/sketchup-api-stubs/stubs/Layout/LockedEntityError.rb +10 -10
- data/lib/sketchup-api-stubs/stubs/Layout/LockedLayerError.rb +11 -11
- data/lib/sketchup-api-stubs/stubs/Layout/Page.rb +183 -183
- data/lib/sketchup-api-stubs/stubs/Layout/PageInfo.rb +387 -387
- data/lib/sketchup-api-stubs/stubs/Layout/Pages.rb +209 -204
- data/lib/sketchup-api-stubs/stubs/Layout/Path.rb +344 -344
- data/lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb +174 -174
- data/lib/sketchup-api-stubs/stubs/Layout/SketchUpModel.rb +694 -694
- data/lib/sketchup-api-stubs/stubs/Layout/Style.rb +1519 -1519
- data/lib/sketchup-api-stubs/stubs/Layout/Table.rb +290 -290
- data/lib/sketchup-api-stubs/stubs/Layout/TableCell.rb +149 -149
- data/lib/sketchup-api-stubs/stubs/Layout/TableColumn.rb +139 -139
- data/lib/sketchup-api-stubs/stubs/Layout/TableRow.rb +135 -135
- data/lib/sketchup-api-stubs/stubs/Sketchup/Animation.rb +144 -140
- data/lib/sketchup-api-stubs/stubs/Sketchup/AppObserver.rb +157 -157
- data/lib/sketchup-api-stubs/stubs/Sketchup/ArcCurve.rb +209 -209
- data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionaries.rb +152 -152
- data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionary.rb +286 -281
- data/lib/sketchup-api-stubs/stubs/Sketchup/Axes.rb +149 -149
- data/lib/sketchup-api-stubs/stubs/Sketchup/Behavior.rb +302 -328
- data/lib/sketchup-api-stubs/stubs/Sketchup/Camera.rb +478 -577
- data/lib/sketchup-api-stubs/stubs/Sketchup/ClassificationSchema.rb +63 -63
- data/lib/sketchup-api-stubs/stubs/Sketchup/Classifications.rb +122 -122
- data/lib/sketchup-api-stubs/stubs/Sketchup/Color.rb +294 -281
- data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentDefinition.rb +577 -562
- data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentInstance.rb +604 -593
- data/lib/sketchup-api-stubs/stubs/Sketchup/Console.rb +76 -76
- data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionLine.rb +257 -257
- data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionPoint.rb +32 -32
- data/lib/sketchup-api-stubs/stubs/Sketchup/Curve.rb +201 -194
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionList.rb +362 -329
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb +74 -72
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionsObserver.rb +104 -102
- data/lib/sketchup-api-stubs/stubs/Sketchup/Dimension.rb +165 -165
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionLinear.rb +306 -312
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionObserver.rb +42 -38
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionRadial.rb +87 -87
- data/lib/sketchup-api-stubs/stubs/Sketchup/Drawingelement.rb +396 -390
- data/lib/sketchup-api-stubs/stubs/Sketchup/Edge.rb +502 -508
- data/lib/sketchup-api-stubs/stubs/Sketchup/EdgeUse.rb +211 -211
- data/lib/sketchup-api-stubs/stubs/Sketchup/Entities.rb +1126 -1119
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesObserver.rb +127 -125
- data/lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb +545 -544
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntityObserver.rb +60 -59
- data/lib/sketchup-api-stubs/stubs/Sketchup/ExtensionsManager.rb +126 -125
- data/lib/sketchup-api-stubs/stubs/Sketchup/Face.rb +751 -750
- data/lib/sketchup-api-stubs/stubs/Sketchup/FrameChangeObserver.rb +104 -104
- data/lib/sketchup-api-stubs/stubs/Sketchup/Group.rb +699 -697
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http.rb +27 -27
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Request.rb +285 -285
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Response.rb +62 -62
- data/lib/sketchup-api-stubs/stubs/Sketchup/Image.rb +417 -409
- data/lib/sketchup-api-stubs/stubs/Sketchup/ImageRep.rb +266 -226
- data/lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb +189 -190
- data/lib/sketchup-api-stubs/stubs/Sketchup/InputPoint.rb +405 -393
- data/lib/sketchup-api-stubs/stubs/Sketchup/InstanceObserver.rb +84 -82
- data/lib/sketchup-api-stubs/stubs/Sketchup/InstancePath.rb +306 -303
- data/lib/sketchup-api-stubs/stubs/Sketchup/Layer.rb +327 -285
- data/lib/sketchup-api-stubs/stubs/Sketchup/LayerFolder.rb +422 -0
- data/lib/sketchup-api-stubs/stubs/Sketchup/Layers.rb +427 -244
- data/lib/sketchup-api-stubs/stubs/Sketchup/LayersObserver.rb +249 -136
- data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing.rb +48 -48
- data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing/ExtensionLicense.rb +86 -86
- data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyle.rb +24 -24
- data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyles.rb +112 -112
- data/lib/sketchup-api-stubs/stubs/Sketchup/Loop.rb +137 -137
- data/lib/sketchup-api-stubs/stubs/Sketchup/Material.rb +414 -416
- data/lib/sketchup-api-stubs/stubs/Sketchup/Materials.rb +318 -311
- data/lib/sketchup-api-stubs/stubs/Sketchup/MaterialsObserver.rb +142 -141
- data/lib/sketchup-api-stubs/stubs/Sketchup/Menu.rb +93 -95
- data/lib/sketchup-api-stubs/stubs/Sketchup/Model.rb +1651 -1638
- data/lib/sketchup-api-stubs/stubs/Sketchup/ModelObserver.rb +357 -356
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsManager.rb +131 -132
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb +284 -284
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProviderObserver.rb +58 -58
- data/lib/sketchup-api-stubs/stubs/Sketchup/Page.rb +797 -770
- data/lib/sketchup-api-stubs/stubs/Sketchup/Pages.rb +363 -353
- data/lib/sketchup-api-stubs/stubs/Sketchup/PagesObserver.rb +77 -76
- data/lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb +478 -456
- data/lib/sketchup-api-stubs/stubs/Sketchup/RegionalSettings.rb +43 -43
- data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptions.rb +364 -364
- data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptionsObserver.rb +45 -44
- data/lib/sketchup-api-stubs/stubs/Sketchup/SectionPlane.rb +150 -150
- data/lib/sketchup-api-stubs/stubs/Sketchup/Selection.rb +459 -454
- data/lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb +115 -115
- data/lib/sketchup-api-stubs/stubs/Sketchup/Set.rb +212 -212
- data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfo.rb +257 -257
- data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfoObserver.rb +59 -57
- data/lib/sketchup-api-stubs/stubs/Sketchup/Skp.rb +40 -0
- data/lib/sketchup-api-stubs/stubs/Sketchup/Style.rb +69 -69
- data/lib/sketchup-api-stubs/stubs/Sketchup/Styles.rb +217 -211
- data/lib/sketchup-api-stubs/stubs/Sketchup/Text.rb +262 -262
- data/lib/sketchup-api-stubs/stubs/Sketchup/Texture.rb +217 -225
- data/lib/sketchup-api-stubs/stubs/Sketchup/TextureWriter.rb +237 -237
- data/lib/sketchup-api-stubs/stubs/Sketchup/Tool.rb +835 -829
- data/lib/sketchup-api-stubs/stubs/Sketchup/Tools.rb +132 -132
- data/lib/sketchup-api-stubs/stubs/Sketchup/ToolsObserver.rb +156 -154
- data/lib/sketchup-api-stubs/stubs/Sketchup/UVHelper.rb +71 -61
- data/lib/sketchup-api-stubs/stubs/Sketchup/Vertex.rb +142 -142
- data/lib/sketchup-api-stubs/stubs/Sketchup/View.rb +1307 -1301
- data/lib/sketchup-api-stubs/stubs/Sketchup/ViewObserver.rb +45 -43
- data/lib/sketchup-api-stubs/stubs/UI/Command.rb +317 -310
- data/lib/sketchup-api-stubs/stubs/UI/HtmlDialog.rb +387 -356
- data/lib/sketchup-api-stubs/stubs/UI/Notification.rb +255 -229
- data/lib/sketchup-api-stubs/stubs/UI/Toolbar.rb +240 -240
- data/lib/sketchup-api-stubs/stubs/UI/WebDialog.rb +633 -633
- data/lib/sketchup-api-stubs/stubs/_top_level.rb +311 -311
- data/lib/sketchup-api-stubs/stubs/array.rb +741 -741
- data/lib/sketchup-api-stubs/stubs/geom.rb +351 -348
- data/lib/sketchup-api-stubs/stubs/languagehandler.rb +92 -92
- data/lib/sketchup-api-stubs/stubs/length.rb +278 -278
- data/lib/sketchup-api-stubs/stubs/numeric.rb +249 -249
- data/lib/sketchup-api-stubs/stubs/sketchup.rb +1342 -1310
- data/lib/sketchup-api-stubs/stubs/sketchupextension.rb +353 -353
- data/lib/sketchup-api-stubs/stubs/string.rb +24 -24
- data/lib/sketchup-api-stubs/stubs/ui.rb +668 -667
- metadata +4 -2
@@ -1,829 +1,835 @@
|
|
1
|
-
# Copyright:: Copyright 2020 Trimble Inc.
|
2
|
-
# License:: The MIT License (MIT)
|
3
|
-
|
4
|
-
# Tool is the interface that you implement to create a SketchUp tool.
|
5
|
-
# See https://github.com/SketchUp/sketchup-ruby-api-tutorials/tree/master/examples/02_custom_tool
|
6
|
-
# for an example of how to create a custom tool in Ruby.
|
7
|
-
#
|
8
|
-
# To create a new tool in Ruby, you must define a new class that implements
|
9
|
-
# the methods for the events that you want to respond to. You do not have
|
10
|
-
# to implement methods for every possible event that a Tool can respond to.
|
11
|
-
#
|
12
|
-
# Once you have defined a tool class, you select that tool by creating an
|
13
|
-
# instance of it and passing it to {Sketchup::Model#select_tool}. For
|
14
|
-
# example:
|
15
|
-
#
|
16
|
-
# class MyTool
|
17
|
-
# def activate
|
18
|
-
# puts 'Your tool has been activated.'
|
19
|
-
# end
|
20
|
-
# end
|
21
|
-
#
|
22
|
-
# my_tool = MyTool.new
|
23
|
-
# Sketchup.active_model.select_tool(my_tool)
|
24
|
-
#
|
25
|
-
# The following table contains several constants you can use when check for
|
26
|
-
# certain key presses inside the keyboard handling callbacks:
|
27
|
-
#
|
28
|
-
# - +CONSTRAIN_MODIFIER_KEY+ = Shift Key
|
29
|
-
# - +CONSTRAIN_MODIFIER_MASK+ = Shift Key
|
30
|
-
# - +COPY_MODIFIER_KEY+ = Alt/Option on Mac, Ctrl on PC
|
31
|
-
# - +COPY_MODIFIER_MASK+ = Alt/Option on Mac, Ctrl on PC
|
32
|
-
# - +ALT_MODIFIER_KEY+ = Command on Mac, Alt on PC
|
33
|
-
# - +ALT_MODIFIER_MASK+ = Command on Mac, Alt on PC
|
34
|
-
#
|
35
|
-
# @
|
36
|
-
class
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
#
|
42
|
-
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
# Geom::Point3d.new(0,
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
84
|
-
# #
|
85
|
-
# view.
|
86
|
-
# view.
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
# @
|
98
|
-
#
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
#
|
112
|
-
#
|
113
|
-
#
|
114
|
-
#
|
115
|
-
#
|
116
|
-
#
|
117
|
-
#
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
131
|
-
#
|
132
|
-
#
|
133
|
-
#
|
134
|
-
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
140
|
-
#
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
#
|
148
|
-
#
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
#
|
153
|
-
#
|
154
|
-
#
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
158
|
-
#
|
159
|
-
#
|
160
|
-
#
|
161
|
-
#
|
162
|
-
#
|
163
|
-
#
|
164
|
-
#
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
#
|
172
|
-
#
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
#
|
177
|
-
#
|
178
|
-
#
|
179
|
-
#
|
180
|
-
#
|
181
|
-
#
|
182
|
-
#
|
183
|
-
#
|
184
|
-
#
|
185
|
-
#
|
186
|
-
#
|
187
|
-
#
|
188
|
-
#
|
189
|
-
#
|
190
|
-
#
|
191
|
-
#
|
192
|
-
#
|
193
|
-
#
|
194
|
-
#
|
195
|
-
#
|
196
|
-
#
|
197
|
-
#
|
198
|
-
#
|
199
|
-
#
|
200
|
-
#
|
201
|
-
#
|
202
|
-
#
|
203
|
-
#
|
204
|
-
#
|
205
|
-
#
|
206
|
-
#
|
207
|
-
#
|
208
|
-
#
|
209
|
-
#
|
210
|
-
# @param
|
211
|
-
# A
|
212
|
-
#
|
213
|
-
#
|
214
|
-
#
|
215
|
-
#
|
216
|
-
#
|
217
|
-
#
|
218
|
-
#
|
219
|
-
#
|
220
|
-
#
|
221
|
-
#
|
222
|
-
#
|
223
|
-
#
|
224
|
-
#
|
225
|
-
#
|
226
|
-
#
|
227
|
-
#
|
228
|
-
#
|
229
|
-
#
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
#
|
237
|
-
# The
|
238
|
-
#
|
239
|
-
#
|
240
|
-
#
|
241
|
-
#
|
242
|
-
#
|
243
|
-
#
|
244
|
-
#
|
245
|
-
#
|
246
|
-
#
|
247
|
-
#
|
248
|
-
#
|
249
|
-
#
|
250
|
-
#
|
251
|
-
#
|
252
|
-
#
|
253
|
-
#
|
254
|
-
#
|
255
|
-
#
|
256
|
-
# @
|
257
|
-
#
|
258
|
-
#
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
#
|
263
|
-
#
|
264
|
-
#
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
#
|
269
|
-
#
|
270
|
-
#
|
271
|
-
#
|
272
|
-
#
|
273
|
-
#
|
274
|
-
#
|
275
|
-
#
|
276
|
-
#
|
277
|
-
#
|
278
|
-
#
|
279
|
-
#
|
280
|
-
# - +
|
281
|
-
# - +
|
282
|
-
# - +
|
283
|
-
# - +
|
284
|
-
# - +
|
285
|
-
# - +
|
286
|
-
# - +
|
287
|
-
# - +
|
288
|
-
# - +
|
289
|
-
# - +
|
290
|
-
#
|
291
|
-
#
|
292
|
-
#
|
293
|
-
#
|
294
|
-
#
|
295
|
-
#
|
296
|
-
#
|
297
|
-
#
|
298
|
-
#
|
299
|
-
#
|
300
|
-
#
|
301
|
-
#
|
302
|
-
#
|
303
|
-
#
|
304
|
-
#
|
305
|
-
#
|
306
|
-
#
|
307
|
-
#
|
308
|
-
#
|
309
|
-
#
|
310
|
-
#
|
311
|
-
#
|
312
|
-
#
|
313
|
-
#
|
314
|
-
#
|
315
|
-
#
|
316
|
-
# @
|
317
|
-
#
|
318
|
-
#
|
319
|
-
#
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
#
|
324
|
-
#
|
325
|
-
#
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
#
|
330
|
-
#
|
331
|
-
#
|
332
|
-
#
|
333
|
-
#
|
334
|
-
#
|
335
|
-
#
|
336
|
-
#
|
337
|
-
#
|
338
|
-
#
|
339
|
-
#
|
340
|
-
#
|
341
|
-
#
|
342
|
-
#
|
343
|
-
#
|
344
|
-
#
|
345
|
-
#
|
346
|
-
#
|
347
|
-
#
|
348
|
-
# @
|
349
|
-
#
|
350
|
-
#
|
351
|
-
#
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
#
|
356
|
-
#
|
357
|
-
#
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
#
|
362
|
-
#
|
363
|
-
#
|
364
|
-
#
|
365
|
-
#
|
366
|
-
#
|
367
|
-
#
|
368
|
-
#
|
369
|
-
#
|
370
|
-
#
|
371
|
-
#
|
372
|
-
#
|
373
|
-
#
|
374
|
-
#
|
375
|
-
#
|
376
|
-
# @param [
|
377
|
-
#
|
378
|
-
#
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
#
|
383
|
-
#
|
384
|
-
#
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
#
|
389
|
-
#
|
390
|
-
#
|
391
|
-
#
|
392
|
-
#
|
393
|
-
#
|
394
|
-
#
|
395
|
-
#
|
396
|
-
#
|
397
|
-
#
|
398
|
-
#
|
399
|
-
#
|
400
|
-
#
|
401
|
-
#
|
402
|
-
#
|
403
|
-
# @param [
|
404
|
-
#
|
405
|
-
#
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
#
|
410
|
-
#
|
411
|
-
#
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
#
|
416
|
-
#
|
417
|
-
#
|
418
|
-
#
|
419
|
-
#
|
420
|
-
#
|
421
|
-
#
|
422
|
-
#
|
423
|
-
#
|
424
|
-
#
|
425
|
-
#
|
426
|
-
#
|
427
|
-
#
|
428
|
-
#
|
429
|
-
#
|
430
|
-
# @param [
|
431
|
-
#
|
432
|
-
#
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
#
|
437
|
-
#
|
438
|
-
#
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
#
|
443
|
-
#
|
444
|
-
#
|
445
|
-
#
|
446
|
-
#
|
447
|
-
#
|
448
|
-
#
|
449
|
-
#
|
450
|
-
#
|
451
|
-
#
|
452
|
-
#
|
453
|
-
#
|
454
|
-
#
|
455
|
-
#
|
456
|
-
#
|
457
|
-
#
|
458
|
-
#
|
459
|
-
#
|
460
|
-
#
|
461
|
-
#
|
462
|
-
#
|
463
|
-
#
|
464
|
-
#
|
465
|
-
# @param [
|
466
|
-
#
|
467
|
-
#
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
#
|
472
|
-
#
|
473
|
-
#
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
#
|
478
|
-
#
|
479
|
-
#
|
480
|
-
#
|
481
|
-
#
|
482
|
-
#
|
483
|
-
#
|
484
|
-
#
|
485
|
-
#
|
486
|
-
#
|
487
|
-
#
|
488
|
-
#
|
489
|
-
#
|
490
|
-
#
|
491
|
-
#
|
492
|
-
#
|
493
|
-
#
|
494
|
-
#
|
495
|
-
#
|
496
|
-
# @param [
|
497
|
-
#
|
498
|
-
#
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
#
|
503
|
-
#
|
504
|
-
#
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
#
|
509
|
-
#
|
510
|
-
#
|
511
|
-
#
|
512
|
-
#
|
513
|
-
#
|
514
|
-
#
|
515
|
-
#
|
516
|
-
#
|
517
|
-
#
|
518
|
-
#
|
519
|
-
#
|
520
|
-
#
|
521
|
-
#
|
522
|
-
#
|
523
|
-
#
|
524
|
-
#
|
525
|
-
#
|
526
|
-
#
|
527
|
-
#
|
528
|
-
# @param [
|
529
|
-
#
|
530
|
-
#
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
#
|
535
|
-
#
|
536
|
-
#
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
#
|
541
|
-
#
|
542
|
-
#
|
543
|
-
#
|
544
|
-
#
|
545
|
-
|
546
|
-
end
|
547
|
-
|
548
|
-
#
|
549
|
-
#
|
550
|
-
#
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
#
|
555
|
-
#
|
556
|
-
#
|
557
|
-
#
|
558
|
-
#
|
559
|
-
|
560
|
-
end
|
561
|
-
|
562
|
-
#
|
563
|
-
#
|
564
|
-
#
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
#
|
569
|
-
#
|
570
|
-
#
|
571
|
-
#
|
572
|
-
#
|
573
|
-
#
|
574
|
-
#
|
575
|
-
#
|
576
|
-
#
|
577
|
-
#
|
578
|
-
#
|
579
|
-
#
|
580
|
-
#
|
581
|
-
#
|
582
|
-
#
|
583
|
-
#
|
584
|
-
#
|
585
|
-
#
|
586
|
-
# @param [
|
587
|
-
#
|
588
|
-
#
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
#
|
593
|
-
#
|
594
|
-
#
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
#
|
599
|
-
#
|
600
|
-
#
|
601
|
-
#
|
602
|
-
#
|
603
|
-
#
|
604
|
-
#
|
605
|
-
#
|
606
|
-
#
|
607
|
-
#
|
608
|
-
#
|
609
|
-
#
|
610
|
-
#
|
611
|
-
#
|
612
|
-
#
|
613
|
-
#
|
614
|
-
#
|
615
|
-
#
|
616
|
-
#
|
617
|
-
#
|
618
|
-
#
|
619
|
-
# #
|
620
|
-
#
|
621
|
-
#
|
622
|
-
# true
|
623
|
-
#
|
624
|
-
#
|
625
|
-
#
|
626
|
-
#
|
627
|
-
# view.
|
628
|
-
#
|
629
|
-
#
|
630
|
-
#
|
631
|
-
#
|
632
|
-
# view.
|
633
|
-
#
|
634
|
-
#
|
635
|
-
#
|
636
|
-
#
|
637
|
-
#
|
638
|
-
#
|
639
|
-
#
|
640
|
-
#
|
641
|
-
#
|
642
|
-
#
|
643
|
-
#
|
644
|
-
#
|
645
|
-
#
|
646
|
-
#
|
647
|
-
#
|
648
|
-
#
|
649
|
-
#
|
650
|
-
#
|
651
|
-
#
|
652
|
-
#
|
653
|
-
#
|
654
|
-
# @param [
|
655
|
-
#
|
656
|
-
#
|
657
|
-
#
|
658
|
-
#
|
659
|
-
#
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
#
|
664
|
-
#
|
665
|
-
#
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
#
|
670
|
-
#
|
671
|
-
#
|
672
|
-
#
|
673
|
-
#
|
674
|
-
#
|
675
|
-
#
|
676
|
-
#
|
677
|
-
#
|
678
|
-
#
|
679
|
-
#
|
680
|
-
#
|
681
|
-
#
|
682
|
-
#
|
683
|
-
#
|
684
|
-
# @param [
|
685
|
-
#
|
686
|
-
#
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
#
|
691
|
-
#
|
692
|
-
#
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
#
|
697
|
-
#
|
698
|
-
#
|
699
|
-
#
|
700
|
-
#
|
701
|
-
#
|
702
|
-
#
|
703
|
-
#
|
704
|
-
#
|
705
|
-
#
|
706
|
-
#
|
707
|
-
#
|
708
|
-
#
|
709
|
-
#
|
710
|
-
#
|
711
|
-
#
|
712
|
-
#
|
713
|
-
# @param [
|
714
|
-
#
|
715
|
-
#
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
#
|
720
|
-
#
|
721
|
-
#
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
#
|
726
|
-
#
|
727
|
-
#
|
728
|
-
#
|
729
|
-
#
|
730
|
-
#
|
731
|
-
#
|
732
|
-
#
|
733
|
-
#
|
734
|
-
#
|
735
|
-
#
|
736
|
-
#
|
737
|
-
#
|
738
|
-
#
|
739
|
-
#
|
740
|
-
# @param [
|
741
|
-
#
|
742
|
-
#
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
#
|
747
|
-
#
|
748
|
-
#
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
#
|
753
|
-
#
|
754
|
-
#
|
755
|
-
#
|
756
|
-
#
|
757
|
-
#
|
758
|
-
#
|
759
|
-
#
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
#
|
764
|
-
#
|
765
|
-
#
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
#
|
770
|
-
#
|
771
|
-
#
|
772
|
-
#
|
773
|
-
#
|
774
|
-
#
|
775
|
-
#
|
776
|
-
|
777
|
-
end
|
778
|
-
|
779
|
-
#
|
780
|
-
#
|
781
|
-
#
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
#
|
786
|
-
#
|
787
|
-
#
|
788
|
-
#
|
789
|
-
#
|
790
|
-
#
|
791
|
-
#
|
792
|
-
#
|
793
|
-
#
|
794
|
-
#
|
795
|
-
# @
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
#
|
800
|
-
#
|
801
|
-
#
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
#
|
806
|
-
#
|
807
|
-
#
|
808
|
-
#
|
809
|
-
#
|
810
|
-
|
811
|
-
end
|
812
|
-
|
813
|
-
#
|
814
|
-
#
|
815
|
-
#
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
#
|
820
|
-
#
|
821
|
-
#
|
822
|
-
#
|
823
|
-
#
|
824
|
-
#
|
825
|
-
#
|
826
|
-
|
827
|
-
end
|
828
|
-
|
829
|
-
|
1
|
+
# Copyright:: Copyright 2020 Trimble Inc.
|
2
|
+
# License:: The MIT License (MIT)
|
3
|
+
|
4
|
+
# Tool is the interface that you implement to create a SketchUp tool.
|
5
|
+
# See https://github.com/SketchUp/sketchup-ruby-api-tutorials/tree/master/examples/02_custom_tool
|
6
|
+
# for an example of how to create a custom tool in Ruby.
|
7
|
+
#
|
8
|
+
# To create a new tool in Ruby, you must define a new class that implements
|
9
|
+
# the methods for the events that you want to respond to. You do not have
|
10
|
+
# to implement methods for every possible event that a Tool can respond to.
|
11
|
+
#
|
12
|
+
# Once you have defined a tool class, you select that tool by creating an
|
13
|
+
# instance of it and passing it to {Sketchup::Model#select_tool}. For
|
14
|
+
# example:
|
15
|
+
#
|
16
|
+
# class MyTool
|
17
|
+
# def activate
|
18
|
+
# puts 'Your tool has been activated.'
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# my_tool = MyTool.new
|
23
|
+
# Sketchup.active_model.select_tool(my_tool)
|
24
|
+
#
|
25
|
+
# The following table contains several constants you can use when check for
|
26
|
+
# certain key presses inside the keyboard handling callbacks:
|
27
|
+
#
|
28
|
+
# - +CONSTRAIN_MODIFIER_KEY+ = Shift Key
|
29
|
+
# - +CONSTRAIN_MODIFIER_MASK+ = Shift Key
|
30
|
+
# - +COPY_MODIFIER_KEY+ = Alt/Option on Mac, Ctrl on PC
|
31
|
+
# - +COPY_MODIFIER_MASK+ = Alt/Option on Mac, Ctrl on PC
|
32
|
+
# - +ALT_MODIFIER_KEY+ = Command on Mac, Alt on PC
|
33
|
+
# - +ALT_MODIFIER_MASK+ = Command on Mac, Alt on PC
|
34
|
+
#
|
35
|
+
# @abstract Implement the methods described in this class to create a tool.
|
36
|
+
# You can not sub-class this class because it is not defined by the API.
|
37
|
+
#
|
38
|
+
# @version SketchUp 6.0
|
39
|
+
class Sketchup::Tool
|
40
|
+
|
41
|
+
# Instance Methods
|
42
|
+
|
43
|
+
# The {#activate} method is called by SketchUp when the tool is selected.
|
44
|
+
# It is a good place to put most of your initialization, such as instance
|
45
|
+
# variables to track the state of the tool.
|
46
|
+
#
|
47
|
+
# @example
|
48
|
+
# def activate
|
49
|
+
# puts 'Your tool has been activated.'
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# @version SketchUp 6.0
|
53
|
+
def activate
|
54
|
+
end
|
55
|
+
|
56
|
+
# The {#deactivate} method is called when the tool is deactivated because a
|
57
|
+
# different tool was selected.
|
58
|
+
#
|
59
|
+
# @example
|
60
|
+
# def deactivate(view)
|
61
|
+
# puts "Your tool has been deactivated in view: #{view}"
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
# @param [Sketchup::View] view
|
65
|
+
#
|
66
|
+
# @version SketchUp 6.0
|
67
|
+
def deactivate(view)
|
68
|
+
end
|
69
|
+
|
70
|
+
# The {#draw} method is called by SketchUp whenever the view is refreshed to
|
71
|
+
# allow the tool to do its own drawing. If the tool has some temporary graphics
|
72
|
+
# that it wants displayed while it is active, it should implement this method
|
73
|
+
# and draw to the {Sketchup::View}.
|
74
|
+
#
|
75
|
+
# @example
|
76
|
+
# def draw(view)
|
77
|
+
# # Draw a square.
|
78
|
+
# points = [
|
79
|
+
# Geom::Point3d.new(0, 0, 0),
|
80
|
+
# Geom::Point3d.new(9, 0, 0),
|
81
|
+
# Geom::Point3d.new(9, 9, 0),
|
82
|
+
# Geom::Point3d.new(0, 9, 0)
|
83
|
+
# ]
|
84
|
+
# # Fill
|
85
|
+
# view.drawing_color = Sketchup::Color.new(255, 128, 128)
|
86
|
+
# view.draw(GL_QUADS, points)
|
87
|
+
# # Outline
|
88
|
+
# view.line_stipple = '' # Solid line
|
89
|
+
# view.drawing_color = Sketchup::Color.new(64, 0, 0)
|
90
|
+
# view.draw(GL_LINE_LOOP, points)
|
91
|
+
# end
|
92
|
+
#
|
93
|
+
# @note If you draw outside the model bounds you need to implement
|
94
|
+
# {Tool#getExtents} which return a bounding box large enough to include the
|
95
|
+
# points you draw. Otherwise your drawing will be clipped.
|
96
|
+
#
|
97
|
+
# @param [Sketchup::View] view
|
98
|
+
# A View object where the method was invoked.
|
99
|
+
#
|
100
|
+
# @see getExtents
|
101
|
+
#
|
102
|
+
# @see Sketchup::View#draw
|
103
|
+
#
|
104
|
+
# @version SketchUp 6.0
|
105
|
+
def draw(view)
|
106
|
+
end
|
107
|
+
|
108
|
+
# The {#enableVCB?} method is used to tell SketchUp whether to allow the user
|
109
|
+
# to enter text into the VCB (value control box, aka the "measurements" panel).
|
110
|
+
# If you do not implement this method, then the vcb is disabled by default.
|
111
|
+
#
|
112
|
+
# @example
|
113
|
+
# # For this tool, allow vcb text entry while the tool is active.
|
114
|
+
# def enableVCB?
|
115
|
+
# return true
|
116
|
+
# end
|
117
|
+
#
|
118
|
+
# @return [Boolean] Return +true+ if you want the VCB enabled
|
119
|
+
#
|
120
|
+
# @version SketchUp 6.0
|
121
|
+
def enableVCB?
|
122
|
+
end
|
123
|
+
|
124
|
+
# In order to accurately draw things, SketchUp needs to know the extents of
|
125
|
+
# what it is drawing. If the tool is doing its own drawing, it may need to
|
126
|
+
# implement this method to tell SketchUp the extents of what it will be
|
127
|
+
# drawing. If you don't implement this method, you may find that part of what
|
128
|
+
# the tool is drawing gets clipped to the extents of the rest of the
|
129
|
+
# model.
|
130
|
+
#
|
131
|
+
# This must return a {Geom::BoundingBox}. In a typical implementation, you
|
132
|
+
# will create a new {Geom::BoundingBox}, add points to set the extents of the
|
133
|
+
# drawing that the tool will do and then return it.
|
134
|
+
#
|
135
|
+
# @example
|
136
|
+
# def getExtents
|
137
|
+
# bb = Sketchup.active_model.bounds
|
138
|
+
# return bb
|
139
|
+
# end
|
140
|
+
#
|
141
|
+
# @return [Geom::BoundingBox]
|
142
|
+
#
|
143
|
+
# @version SketchUp 6.0
|
144
|
+
def getExtents
|
145
|
+
end
|
146
|
+
|
147
|
+
# The {#getInstructorContentDirectory} method is used to tell SketchUp the
|
148
|
+
# directory containing your Tool's instructor content. To use this, create
|
149
|
+
# a custom instructor directory, put an index.html file inside of it, and then
|
150
|
+
# return that path via this method. If the SketchUp user has the Instructor
|
151
|
+
# window open when they activate your tool, they will see your html file.
|
152
|
+
#
|
153
|
+
# @example
|
154
|
+
# def getInstructorContentDirectory
|
155
|
+
# extension_path = Sketchup.extensions['MyExtension].extension_path
|
156
|
+
# instructor_path = File.join(extension_path, 'MyExtension', 'instructor')
|
157
|
+
# return instructor_path
|
158
|
+
# end
|
159
|
+
#
|
160
|
+
# @note Prior to SketchUp 2014 this method would assume the path was relative
|
161
|
+
# to the SketchUp resource folder. From 2014 and onwards you can specify the
|
162
|
+
# absolute path to an HTML file or the absolute path to a directory
|
163
|
+
# containing an index.html file.
|
164
|
+
#
|
165
|
+
# @return [String] the directory path where the Instructor content exists.
|
166
|
+
#
|
167
|
+
# @version SketchUp 6.0
|
168
|
+
def getInstructorContentDirectory
|
169
|
+
end
|
170
|
+
|
171
|
+
# The {#getMenu} method is called by SketchUp to let the tool provide its own
|
172
|
+
# context menu. Most tools will not want to implement this method and,
|
173
|
+
# instead, use the normal context menu found on all entities.
|
174
|
+
#
|
175
|
+
# If you do implement this method, the argument is a Menu. You should use the
|
176
|
+
# add_item method to build the context menu.
|
177
|
+
#
|
178
|
+
# Your tool will use a standard context menu by default if you do not
|
179
|
+
# implement this method. Implement this method if you want a context-click to
|
180
|
+
# display something other than this default context menu.
|
181
|
+
#
|
182
|
+
# In SketchUp 2015 the flags, x, y and view parameters were added. They are
|
183
|
+
# needed if you need to pick the entities under the mouse position. The new
|
184
|
+
# parameters are optional, but if you need to use one you must include them
|
185
|
+
# all.
|
186
|
+
#
|
187
|
+
# @example
|
188
|
+
# if Sketchup.version.to_i < 15
|
189
|
+
# # Compatible with SketchUp 2014 and older:
|
190
|
+
# def getMenu(menu)
|
191
|
+
# menu.add_item('Say Hello') {
|
192
|
+
# UI.messagebox('Hello')
|
193
|
+
# }
|
194
|
+
# end
|
195
|
+
# else
|
196
|
+
# # Only works with SketchUp 2015 and newer:
|
197
|
+
# def getMenu(menu, flags, x, y, view)
|
198
|
+
# ph = view.pick_helper(x, y)
|
199
|
+
# entity = ph.best_picked
|
200
|
+
# if entity
|
201
|
+
# view.model.selection.clear
|
202
|
+
# view.model.selection.add(entity)
|
203
|
+
# menu.add_item("Erase #{entity.typename}") {
|
204
|
+
# entity.erase!
|
205
|
+
# }
|
206
|
+
# end
|
207
|
+
# end
|
208
|
+
# end
|
209
|
+
#
|
210
|
+
# @param menu
|
211
|
+
# A Menu object.
|
212
|
+
#
|
213
|
+
# @param [optional] flags
|
214
|
+
# A bit mask that tells the state of the
|
215
|
+
# modifier keys and other mouse buttons at the time.
|
216
|
+
# Added in SU2015.
|
217
|
+
#
|
218
|
+
# @param [optional] x
|
219
|
+
# The X coordinate on the screen where the
|
220
|
+
# event occurred. Added in SU2015.
|
221
|
+
#
|
222
|
+
# @param [optional] y
|
223
|
+
# The Y coordinate on the screen where the
|
224
|
+
# event occurred. Added in SU2015.
|
225
|
+
#
|
226
|
+
# @param [optional] view
|
227
|
+
# A View object where the method was invoked.
|
228
|
+
# Added in SU2015.
|
229
|
+
#
|
230
|
+
# @return nil
|
231
|
+
#
|
232
|
+
# @version SketchUp 6.0
|
233
|
+
def getMenu(menu, flags, x, y, view)
|
234
|
+
end
|
235
|
+
|
236
|
+
# The {#onCancel} method is called by SketchUp to cancel the current operation
|
237
|
+
# of the tool. The typical response will be to reset the tool to its initial
|
238
|
+
# state.
|
239
|
+
#
|
240
|
+
# The reason identifies the action that triggered the call. The reason can be
|
241
|
+
# one of the following values:
|
242
|
+
#
|
243
|
+
# - +0+: the user canceled the current operation by hitting the escape key.
|
244
|
+
# - +1+: the user re-selected the same tool from the toolbar or menu.
|
245
|
+
# - +2+: the user did an undo while the tool was active.
|
246
|
+
#
|
247
|
+
# @example
|
248
|
+
# def onCancel(reason, view)
|
249
|
+
# puts "MyTool was canceled for reason ##{reason} in view: #{view}"
|
250
|
+
# end
|
251
|
+
#
|
252
|
+
# @note When something is undone {#onCancel} is called before the undo is
|
253
|
+
# actually executed. If you need to do something with the model after an undo
|
254
|
+
# use {Sketchup::ModelObserver#onTransactionUndo}.
|
255
|
+
#
|
256
|
+
# @note When {#onKeyDown} is implemented and returns +true+, pressing Esc
|
257
|
+
# doesn't trigger {#onCancel}.
|
258
|
+
#
|
259
|
+
# @param [Integer] reason
|
260
|
+
# A reason value (see comments).
|
261
|
+
#
|
262
|
+
# @param [Sketchup::View] view
|
263
|
+
#
|
264
|
+
# @version SketchUp 6.0
|
265
|
+
def onCancel(reason, view)
|
266
|
+
end
|
267
|
+
|
268
|
+
# The {#onKeyDown} method is called by SketchUp when the user presses a key on
|
269
|
+
# the keyboard. If you want to get input from the VCB, you should implement
|
270
|
+
# onUserText rather than this method.
|
271
|
+
#
|
272
|
+
# This method is can be used for special keys such as the Shift key, Ctrl key,
|
273
|
+
# and so on, or for just determining which key a user pressed. This method is
|
274
|
+
# actually called for all keys that are pressed.
|
275
|
+
#
|
276
|
+
# There are several
|
277
|
+
# "virtual keys" defined as constants you can use. Their use is cross
|
278
|
+
# platform. They are:
|
279
|
+
#
|
280
|
+
# - +VK_ALT+
|
281
|
+
# - +VK_COMMAND+
|
282
|
+
# - +VK_CONTROL+
|
283
|
+
# - +VK_DELETE+
|
284
|
+
# - +VK_DOWN+
|
285
|
+
# - +VK_END+
|
286
|
+
# - +VK_HOME+
|
287
|
+
# - +VK_INSERT+
|
288
|
+
# - +VK_LEFT+
|
289
|
+
# - +VK_MENU+
|
290
|
+
# - +VK_NEXT+
|
291
|
+
# - +VK_PRIOR+
|
292
|
+
# - +VK_RIGHT+
|
293
|
+
# - +VK_SHIFT+
|
294
|
+
# - +VK_SPACE+
|
295
|
+
# - +VK_UP+
|
296
|
+
#
|
297
|
+
# V6: There is a bug on Windows where the typematic effect does
|
298
|
+
# not work. Typematic effects work fine on a Mac.
|
299
|
+
#
|
300
|
+
# @example
|
301
|
+
# def onKeyDown(key, repeat, flags, view)
|
302
|
+
# puts "onKeyDown: key = #{key}"
|
303
|
+
# puts " repeat = #{repeat}"
|
304
|
+
# puts " flags = #{flags}"
|
305
|
+
# puts " view = #{view}"
|
306
|
+
# end
|
307
|
+
#
|
308
|
+
# @param [Integer] key
|
309
|
+
# The key that was pressed.
|
310
|
+
#
|
311
|
+
# @param [Integer] repeat
|
312
|
+
# A value of 1 for a single press of a key. A value
|
313
|
+
# of 2 if the user has pressed a key and is holding
|
314
|
+
# it down.
|
315
|
+
#
|
316
|
+
# @param [Integer] flags
|
317
|
+
# A bit mask that tells the state of the modifier
|
318
|
+
# keys at the time of the event.
|
319
|
+
#
|
320
|
+
# @param [Sketchup::View] view
|
321
|
+
#
|
322
|
+
# @return [Boolean] Return +true+ to prevent SketchUp from processing the
|
323
|
+
# event.
|
324
|
+
#
|
325
|
+
# @version SketchUp 6.0
|
326
|
+
def onKeyDown(key, repeat, flags, view)
|
327
|
+
end
|
328
|
+
|
329
|
+
# The {#onKeyUp} method is called by SketchUp when the user releases a key on
|
330
|
+
# the keyboard.
|
331
|
+
#
|
332
|
+
# @example
|
333
|
+
# def onKeyUp(key, repeat, flags, view)
|
334
|
+
# puts "onKeyUp: key = #{key}"
|
335
|
+
# puts " repeat = #{repeat}"
|
336
|
+
# puts " flags = #{flags}"
|
337
|
+
# puts " view = #{view}"
|
338
|
+
# end
|
339
|
+
#
|
340
|
+
# @param [Integer] key
|
341
|
+
# The key that was pressed.
|
342
|
+
#
|
343
|
+
# @param [Integer] repeat
|
344
|
+
# A value of 1 for a single press of a key. A value
|
345
|
+
# of 2 if the user has pressed a key and is holding
|
346
|
+
# it down.
|
347
|
+
#
|
348
|
+
# @param [Integer] flags
|
349
|
+
# A bit mask that tells the state of the modifier
|
350
|
+
# keys at the time of the event.
|
351
|
+
#
|
352
|
+
# @param [Sketchup::View] view
|
353
|
+
#
|
354
|
+
# @return [Boolean] Return +true+ to prevent SketchUp from processing the
|
355
|
+
# event.
|
356
|
+
#
|
357
|
+
# @version SketchUp 6.0
|
358
|
+
def onKeyUp(key, repeat, flags, view)
|
359
|
+
end
|
360
|
+
|
361
|
+
# The {#onLButtonDoubleClick} is called by SketchUp when the user double clicks
|
362
|
+
# with the left mouse button.
|
363
|
+
#
|
364
|
+
# @example
|
365
|
+
# def onLButtonDoubleClick(flags, x, y, view)
|
366
|
+
# puts "onLButtonDoubleClick: flags = #{flags}"
|
367
|
+
# puts " x = #{x}"
|
368
|
+
# puts " y = #{y}"
|
369
|
+
# puts " view = #{view}"
|
370
|
+
# end
|
371
|
+
#
|
372
|
+
# @param [Integer] flags
|
373
|
+
# A bit mask that tells the state of the modifier
|
374
|
+
# keys and other mouse buttons at the time.
|
375
|
+
#
|
376
|
+
# @param [Integer] x
|
377
|
+
# The X coordinate on the screen where the event occurred.
|
378
|
+
#
|
379
|
+
# @param [Integer] y
|
380
|
+
# The Y coordinate on the screen where the event occurred.
|
381
|
+
#
|
382
|
+
# @param [Sketchup::View] view
|
383
|
+
#
|
384
|
+
# @version SketchUp 6.0
|
385
|
+
def onLButtonDoubleClick(flags, x, y, view)
|
386
|
+
end
|
387
|
+
|
388
|
+
# The {#onLButtonDown} method is called by SketchUp when the left mouse button
|
389
|
+
# is pressed. Most tools will implement this method.
|
390
|
+
#
|
391
|
+
# @example
|
392
|
+
# def onLButtonDown(flags, x, y, view)
|
393
|
+
# puts "onLButtonDown: flags = #{flags}"
|
394
|
+
# puts " x = #{x}"
|
395
|
+
# puts " y = #{y}"
|
396
|
+
# puts " view = #{view}"
|
397
|
+
# end
|
398
|
+
#
|
399
|
+
# @param [Integer] flags
|
400
|
+
# A bit mask that tells the state of the modifier
|
401
|
+
# keys and other mouse buttons at the time.
|
402
|
+
#
|
403
|
+
# @param [Integer] x
|
404
|
+
# The X coordinate on the screen where the event occurred.
|
405
|
+
#
|
406
|
+
# @param [Integer] y
|
407
|
+
# The Y coordinate on the screen where the event occurred.
|
408
|
+
#
|
409
|
+
# @param [Sketchup::View] view
|
410
|
+
#
|
411
|
+
# @version SketchUp 6.0
|
412
|
+
def onLButtonDown(flags, x, y, view)
|
413
|
+
end
|
414
|
+
|
415
|
+
# The {#onLButtonUp} method is called by SketchUp when the left mouse button is
|
416
|
+
# released.
|
417
|
+
#
|
418
|
+
# @example
|
419
|
+
# def onLButtonUp(flags, x, y, view)
|
420
|
+
# puts "onLButtonUp: flags = #{flags}"
|
421
|
+
# puts " x = #{x}"
|
422
|
+
# puts " y = #{y}"
|
423
|
+
# puts " view = #{view}"
|
424
|
+
# end
|
425
|
+
#
|
426
|
+
# @param [Integer] flags
|
427
|
+
# A bit mask that tells the state of the modifier
|
428
|
+
# keys and other mouse buttons at the time.
|
429
|
+
#
|
430
|
+
# @param [Integer] x
|
431
|
+
# The X coordinate on the screen where the event occurred.
|
432
|
+
#
|
433
|
+
# @param [Integer] y
|
434
|
+
# The Y coordinate on the screen where the event occurred.
|
435
|
+
#
|
436
|
+
# @param [Sketchup::View] view
|
437
|
+
#
|
438
|
+
# @version SketchUp 6.0
|
439
|
+
def onLButtonUp(flags, x, y, view)
|
440
|
+
end
|
441
|
+
|
442
|
+
# The {#onMButtonDoubleClick} method is called by SketchUp when the middle
|
443
|
+
# mouse button (on a three button mouse) is double-clicked.
|
444
|
+
#
|
445
|
+
# Only implement this method if you want SketchUp to react to a middle mouse
|
446
|
+
# button being double-clicked.
|
447
|
+
#
|
448
|
+
# @example
|
449
|
+
# def onMButtonDoubleClick(flags, x, y, view)
|
450
|
+
# puts "onMButtonDoubleClick: flags = #{flags}"
|
451
|
+
# puts " x = #{x}"
|
452
|
+
# puts " y = #{y}"
|
453
|
+
# puts " view = #{view}"
|
454
|
+
# end
|
455
|
+
#
|
456
|
+
# @note Though this method has been documented in the Ruby API for many years,
|
457
|
+
# it has never worked properly. We are leaving this documentation in place
|
458
|
+
# for now in the hopes of fixing the implementation, but you won't have any
|
459
|
+
# luck trying to use it in SU7 and earlier.
|
460
|
+
#
|
461
|
+
# @param [Integer] flags
|
462
|
+
# A bit mask that tells the state of the modifier
|
463
|
+
# keys and other mouse buttons at the time.
|
464
|
+
#
|
465
|
+
# @param [Integer] x
|
466
|
+
# The X coordinate on the screen where the event occurred.
|
467
|
+
#
|
468
|
+
# @param [Integer] y
|
469
|
+
# The Y coordinate on the screen where the event occurred.
|
470
|
+
#
|
471
|
+
# @param [Sketchup::View] view
|
472
|
+
#
|
473
|
+
# @version SketchUp 6.0
|
474
|
+
def onMButtonDoubleClick(flags, x, y, view)
|
475
|
+
end
|
476
|
+
|
477
|
+
# The {#onMButtonDown} method is called by SketchUp when the middle mouse
|
478
|
+
# button (on a three button mouse) is down.
|
479
|
+
#
|
480
|
+
# The Orbit tool is activated by default when the middle mouse button is down.
|
481
|
+
# Implement this method if you want a middle mouse button to do something
|
482
|
+
# other than invoke the Orbit tool.
|
483
|
+
#
|
484
|
+
# @example
|
485
|
+
# def onMButtonDown(flags, x, y, view)
|
486
|
+
# puts "onMButtonDown: flags = #{flags}"
|
487
|
+
# puts " x = #{x}"
|
488
|
+
# puts " y = #{y}"
|
489
|
+
# puts " view = #{view}"
|
490
|
+
# end
|
491
|
+
#
|
492
|
+
# @param [Integer] flags
|
493
|
+
# A bit mask that tells the state of the modifier
|
494
|
+
# keys and other mouse buttons at the time.
|
495
|
+
#
|
496
|
+
# @param [Integer] x
|
497
|
+
# The X coordinate on the screen where the event occurred.
|
498
|
+
#
|
499
|
+
# @param [Integer] y
|
500
|
+
# The Y coordinate on the screen where the event occurred.
|
501
|
+
#
|
502
|
+
# @param [Sketchup::View] view
|
503
|
+
#
|
504
|
+
# @version SketchUp 6.0
|
505
|
+
def onMButtonDown(flags, x, y, view)
|
506
|
+
end
|
507
|
+
|
508
|
+
# The {#onMButtonUp} method is called by SketchUp when the middle mouse button
|
509
|
+
# (on a three button mouse) is released.
|
510
|
+
#
|
511
|
+
# SketchUp returns to the previous tool from the Orbit tool when the middle
|
512
|
+
# mouse button is released. Implement this method if you want a middle mouse
|
513
|
+
# button to do something other than return to the previous tool when in the
|
514
|
+
# Orbit tool.
|
515
|
+
#
|
516
|
+
# @example
|
517
|
+
# def onMButtonUp(flags, x, y, view)
|
518
|
+
# puts "onMButtonUp: flags = #{flags}"
|
519
|
+
# puts " x = #{x}"
|
520
|
+
# puts " y = #{y}"
|
521
|
+
# puts " view = #{view}"
|
522
|
+
# end
|
523
|
+
#
|
524
|
+
# @param [Integer] flags
|
525
|
+
# A bit mask that tells the state of the modifier
|
526
|
+
# keys and other mouse buttons at the time.
|
527
|
+
#
|
528
|
+
# @param [Integer] x
|
529
|
+
# The X coordinate on the screen where the event occurred.
|
530
|
+
#
|
531
|
+
# @param [Integer] y
|
532
|
+
# The Y coordinate on the screen where the event occurred.
|
533
|
+
#
|
534
|
+
# @param [Sketchup::View] view
|
535
|
+
#
|
536
|
+
# @version SketchUp 6.0
|
537
|
+
def onMButtonUp(flags, x, y, view)
|
538
|
+
end
|
539
|
+
|
540
|
+
# The {#onMouseEnter} method is called by SketchUp when the mouse enters the
|
541
|
+
# viewport.
|
542
|
+
#
|
543
|
+
# @example
|
544
|
+
# def onMouseEnter(view)
|
545
|
+
# puts "onMouseEnter: view = #{view}"
|
546
|
+
# end
|
547
|
+
#
|
548
|
+
# @param [Sketchup::View] view
|
549
|
+
#
|
550
|
+
# @version SketchUp 6.0
|
551
|
+
def onMouseEnter(view)
|
552
|
+
end
|
553
|
+
|
554
|
+
# The {#onMouseLeave} method is called by SketchUp when the mouse leaves the
|
555
|
+
# viewport.
|
556
|
+
#
|
557
|
+
# @example
|
558
|
+
# def onMouseLeave(view)
|
559
|
+
# puts "onMouseLeave: view = #{view}"
|
560
|
+
# end
|
561
|
+
#
|
562
|
+
# @param [Sketchup::View] view
|
563
|
+
#
|
564
|
+
# @version SketchUp 6.0
|
565
|
+
def onMouseLeave(view)
|
566
|
+
end
|
567
|
+
|
568
|
+
# The {#onMouseMove} method is called by SketchUp whenever the mouse is moved.
|
569
|
+
# You will often want to implement this method.
|
570
|
+
#
|
571
|
+
# Try to make this method as efficient as possible because this method is
|
572
|
+
# called often.
|
573
|
+
#
|
574
|
+
# @example
|
575
|
+
# def onMouseMove(flags, x, y, view)
|
576
|
+
# puts "onMouseMove: flags = #{flags}"
|
577
|
+
# puts " x = #{x}"
|
578
|
+
# puts " y = #{y}"
|
579
|
+
# puts " view = #{view}"
|
580
|
+
# end
|
581
|
+
#
|
582
|
+
# @param [Integer] flags
|
583
|
+
# A bit mask that tells the state of the modifier
|
584
|
+
# keys and other mouse buttons at the time.
|
585
|
+
#
|
586
|
+
# @param [Integer] x
|
587
|
+
# The X coordinate on the screen where the event occurred.
|
588
|
+
#
|
589
|
+
# @param [Integer] y
|
590
|
+
# The Y coordinate on the screen where the event occurred.
|
591
|
+
#
|
592
|
+
# @param [Sketchup::View] view
|
593
|
+
#
|
594
|
+
# @version SketchUp 6.0
|
595
|
+
def onMouseMove(flags, x, y, view)
|
596
|
+
end
|
597
|
+
|
598
|
+
# The {#onMouseWheel} method is called by SketchUp when the mouse scroll wheel
|
599
|
+
# is used.
|
600
|
+
#
|
601
|
+
# @example
|
602
|
+
# class ExampleTool
|
603
|
+
#
|
604
|
+
# def initialize
|
605
|
+
# @property_value = 0
|
606
|
+
# @rect = [
|
607
|
+
# Geom::Point3d.new(100, 150, 0),
|
608
|
+
# Geom::Point3d.new(300, 150, 0),
|
609
|
+
# Geom::Point3d.new(300, 250, 0),
|
610
|
+
# Geom::Point3d.new(100, 250, 0),
|
611
|
+
# ]
|
612
|
+
# end
|
613
|
+
#
|
614
|
+
# def onMouseMove(flags, x, y, view)
|
615
|
+
# view.invalidate
|
616
|
+
# end
|
617
|
+
#
|
618
|
+
# def onMouseWheel(flags, delta, x, y, view)
|
619
|
+
# # If the cursor is not within the bounds of the rectangle, return false
|
620
|
+
# # to let SketchUp do its default action (zoom).
|
621
|
+
# point = Geom::Point3d.new(x, y)
|
622
|
+
# return false unless Geom.point_in_polygon_2D(point, @rect, true)
|
623
|
+
#
|
624
|
+
# # If cursor is within the bounds of the rectangle, update the value
|
625
|
+
# # and prevent the default zoom.
|
626
|
+
# @property_value += delta
|
627
|
+
# view.invalidate
|
628
|
+
# true
|
629
|
+
# end
|
630
|
+
#
|
631
|
+
# def draw(view)
|
632
|
+
# view.line_width = 2
|
633
|
+
# view.line_stipple = ''
|
634
|
+
# view.drawing_color = 'red'
|
635
|
+
# view.draw2d(GL_QUADS, @rect)
|
636
|
+
#
|
637
|
+
# point = Geom::Point3d.new(120, 170)
|
638
|
+
# view.draw_text(point, "Value: #{@property_value}",
|
639
|
+
# size: 20, bold: true, color: 'black')
|
640
|
+
# end
|
641
|
+
#
|
642
|
+
# end
|
643
|
+
#
|
644
|
+
# Sketchup.active_model.select_tool(ExampleTool.new)
|
645
|
+
#
|
646
|
+
# @param [Integer] flags
|
647
|
+
# A bit mask that tells the state of the modifier
|
648
|
+
# keys and other mouse buttons at the time.
|
649
|
+
#
|
650
|
+
# @param [Integer] delta
|
651
|
+
# Either +1+ or +-1+ depending on which direction the
|
652
|
+
# mouse wheel scrolled.
|
653
|
+
#
|
654
|
+
# @param [Float] x
|
655
|
+
# The X coordinate on the screen where the event occurred.
|
656
|
+
#
|
657
|
+
# @param [Float] y
|
658
|
+
# The Y coordinate on the screen where the event occurred.
|
659
|
+
#
|
660
|
+
# @param [Sketchup::View] view
|
661
|
+
#
|
662
|
+
# @return [Boolean] Return +true+ to prevent SketchUp from performing default
|
663
|
+
# zoom action.
|
664
|
+
#
|
665
|
+
# @version SketchUp 2019.2
|
666
|
+
def onMouseWheel(flags, delta, x, y, view)
|
667
|
+
end
|
668
|
+
|
669
|
+
# The {#onRButtonDoubleClick} is called by SketchUp when the user double clicks
|
670
|
+
# with the right mouse button.
|
671
|
+
#
|
672
|
+
# @example
|
673
|
+
# def onRButtonDoubleClick(flags, x, y, view)
|
674
|
+
# puts "onRButtonDoubleClick: flags = #{flags}"
|
675
|
+
# puts " x = #{x}"
|
676
|
+
# puts " y = #{y}"
|
677
|
+
# puts " view = #{view}"
|
678
|
+
# end
|
679
|
+
#
|
680
|
+
# @param [Integer] flags
|
681
|
+
# A bit mask that tells the state of the modifier
|
682
|
+
# keys and other mouse buttons at the time.
|
683
|
+
#
|
684
|
+
# @param [Integer] x
|
685
|
+
# The X coordinate on the screen where the event occurred.
|
686
|
+
#
|
687
|
+
# @param [Integer] y
|
688
|
+
# The Y coordinate on the screen where the event occurred.
|
689
|
+
#
|
690
|
+
# @param [Sketchup::View] view
|
691
|
+
#
|
692
|
+
# @version SketchUp 6.0
|
693
|
+
def onRButtonDoubleClick(flags, x, y, view)
|
694
|
+
end
|
695
|
+
|
696
|
+
# The {#onRButtonDown} method is called by SketchUp when the user presses
|
697
|
+
# the right mouse button. Implement this method, along with the tool.getMenu
|
698
|
+
# method, when you want your tool to do something other than display the
|
699
|
+
# default context menu when the right mouse button is clicked.
|
700
|
+
#
|
701
|
+
# @example
|
702
|
+
# def onRButtonDown(flags, x, y, view)
|
703
|
+
# puts "onRButtonDown: flags = #{flags}"
|
704
|
+
# puts " x = #{x}"
|
705
|
+
# puts " y = #{y}"
|
706
|
+
# puts " view = #{view}"
|
707
|
+
# end
|
708
|
+
#
|
709
|
+
# @param [Integer] flags
|
710
|
+
# A bit mask that tells the state of the modifier
|
711
|
+
# keys and other mouse buttons at the time.
|
712
|
+
#
|
713
|
+
# @param [Integer] x
|
714
|
+
# The X coordinate on the screen where the event occurred.
|
715
|
+
#
|
716
|
+
# @param [Integer] y
|
717
|
+
# The Y coordinate on the screen where the event occurred.
|
718
|
+
#
|
719
|
+
# @param [Sketchup::View] view
|
720
|
+
#
|
721
|
+
# @version SketchUp 6.0
|
722
|
+
def onRButtonDown(flags, x, y, view)
|
723
|
+
end
|
724
|
+
|
725
|
+
# The {#onRButtonUp} method is called by SketchUp when the user releases the
|
726
|
+
# right mouse button.
|
727
|
+
#
|
728
|
+
# @example
|
729
|
+
# def onRButtonUp(flags, x, y, view)
|
730
|
+
# puts "onRButtonUp: flags = #{flags}"
|
731
|
+
# puts " x = #{x}"
|
732
|
+
# puts " y = #{y}"
|
733
|
+
# puts " view = #{view}"
|
734
|
+
# end
|
735
|
+
#
|
736
|
+
# @param [Integer] flags
|
737
|
+
# A bit mask that tells the state of the modifier
|
738
|
+
# keys and other mouse buttons at the time.
|
739
|
+
#
|
740
|
+
# @param [Integer] x
|
741
|
+
# The X coordinate on the screen where the event occurred.
|
742
|
+
#
|
743
|
+
# @param [Integer] y
|
744
|
+
# The Y coordinate on the screen where the event occurred.
|
745
|
+
#
|
746
|
+
# @param [Sketchup::View] view
|
747
|
+
#
|
748
|
+
# @version SketchUp 6.0
|
749
|
+
def onRButtonUp(flags, x, y, view)
|
750
|
+
end
|
751
|
+
|
752
|
+
# The {#onReturn} method is called by SketchUp when the user hit the Return key
|
753
|
+
# to complete an operation in the tool. This method will rarely need to be
|
754
|
+
# implemented.
|
755
|
+
#
|
756
|
+
# @example
|
757
|
+
# def onReturn(view)
|
758
|
+
# puts "onReturn(#{view})"
|
759
|
+
# end
|
760
|
+
#
|
761
|
+
# @param [Sketchup::View] view
|
762
|
+
#
|
763
|
+
# @return [nil]
|
764
|
+
#
|
765
|
+
# @version SketchUp 6.0
|
766
|
+
def onReturn(view)
|
767
|
+
end
|
768
|
+
|
769
|
+
# The {#onSetCursor} method is called by SketchUp when the tool wants to set
|
770
|
+
# the cursor.
|
771
|
+
#
|
772
|
+
# @example
|
773
|
+
# def onSetCursor
|
774
|
+
# puts "onSetCursor: view = #{view}"
|
775
|
+
# # You would set your cursor here. See UI.set_cursor method.
|
776
|
+
# UI.set_cursor(@cursor_id) # UI.set_cursor return true
|
777
|
+
# end
|
778
|
+
#
|
779
|
+
# @return [Boolean] Return +true+ to prevent SketchUp using the default cursor.
|
780
|
+
#
|
781
|
+
# @version SketchUp 6.0
|
782
|
+
def onSetCursor
|
783
|
+
end
|
784
|
+
|
785
|
+
# The {#onUserText} method is called by SketchUp when the user has typed text
|
786
|
+
# into the VCB and hit return.
|
787
|
+
#
|
788
|
+
# @example
|
789
|
+
# def onUserText(text, view)
|
790
|
+
# @distance = text.to_l
|
791
|
+
# rescue ArgumentError
|
792
|
+
# view.tooltip = 'Invalid length'
|
793
|
+
# end
|
794
|
+
#
|
795
|
+
# @param [String] text
|
796
|
+
# The text string that was typed into the VCB.
|
797
|
+
#
|
798
|
+
# @param [Sketchup::View] view
|
799
|
+
# A view object where the method was invoked.
|
800
|
+
#
|
801
|
+
# @version SketchUp 6.0
|
802
|
+
def onUserText(text, view)
|
803
|
+
end
|
804
|
+
|
805
|
+
# The {#resume} method is called by SketchUp when the tool becomes active again
|
806
|
+
# after being suspended.
|
807
|
+
#
|
808
|
+
# @example
|
809
|
+
# def resume(view)
|
810
|
+
# puts "resume: view = #{view}"
|
811
|
+
# end
|
812
|
+
#
|
813
|
+
# @param [Sketchup::View] view
|
814
|
+
#
|
815
|
+
# @version SketchUp 6.0
|
816
|
+
def resume(view)
|
817
|
+
end
|
818
|
+
|
819
|
+
# The {#suspend} method is called by SketchUp when the tool temporarily becomes
|
820
|
+
# inactive because another tool has been activated. This typically happens
|
821
|
+
# when a viewing tool is activated, such as when orbit is active due to the
|
822
|
+
# middle mouse button.
|
823
|
+
#
|
824
|
+
# @example
|
825
|
+
# def suspend(view)
|
826
|
+
# puts "suspend: view = #{view}"
|
827
|
+
# end
|
828
|
+
#
|
829
|
+
# @param [Sketchup::View] view
|
830
|
+
#
|
831
|
+
# @version SketchUp 6.0
|
832
|
+
def suspend(view)
|
833
|
+
end
|
834
|
+
|
835
|
+
end
|