sketchup-api-stubs 0.1.2 → 0.2.0
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/SketchUp/Geom/BoundingBox.rb +17 -20
- data/SketchUp/Geom/Bounds2d.rb +172 -0
- data/SketchUp/Geom/LatLong.rb +31 -16
- data/SketchUp/Geom/OrientedBounds2d.rb +102 -0
- data/SketchUp/Geom/Point2d.rb +365 -0
- data/SketchUp/Geom/Point3d.rb +121 -110
- data/SketchUp/Geom/PolygonMesh.rb +30 -21
- data/SketchUp/Geom/Transformation.rb +8 -4
- data/SketchUp/Geom/Transformation2d.rb +125 -0
- data/SketchUp/Geom/UTM.rb +43 -37
- data/SketchUp/Geom/Vector2d.rb +497 -0
- data/SketchUp/Geom/Vector3d.rb +143 -131
- data/SketchUp/Layout.rb +25 -0
- data/SketchUp/Layout/AngularDimension.rb +569 -0
- data/SketchUp/Layout/AutoTextDefinition.rb +417 -0
- data/SketchUp/Layout/AutoTextDefinitions.rb +186 -0
- data/SketchUp/Layout/ConnectionPoint.rb +70 -0
- data/SketchUp/Layout/Document.rb +458 -0
- data/SketchUp/Layout/Ellipse.rb +29 -0
- data/SketchUp/Layout/Entities.rb +155 -0
- data/SketchUp/Layout/Entity.rb +363 -0
- data/SketchUp/Layout/FormattedText.rb +349 -0
- data/SketchUp/Layout/Grid.rb +131 -0
- data/SketchUp/Layout/Group.rb +261 -0
- data/SketchUp/Layout/Image.rb +86 -0
- data/SketchUp/Layout/Label.rb +371 -0
- data/SketchUp/Layout/Layer.rb +222 -0
- data/SketchUp/Layout/LayerInstance.rb +128 -0
- data/SketchUp/Layout/Layers.rb +232 -0
- data/SketchUp/Layout/LinearDimension.rb +563 -0
- data/SketchUp/Layout/LockedEntityError.rb +10 -0
- data/SketchUp/Layout/LockedLayerError.rb +11 -0
- data/SketchUp/Layout/Page.rb +187 -0
- data/SketchUp/Layout/PageInfo.rb +393 -0
- data/SketchUp/Layout/Pages.rb +216 -0
- data/SketchUp/Layout/Path.rb +326 -0
- data/SketchUp/Layout/Rectangle.rb +174 -0
- data/SketchUp/Layout/SketchUpModel.rb +522 -0
- data/SketchUp/Layout/Style.rb +1520 -0
- data/SketchUp/Layout/Table.rb +290 -0
- data/SketchUp/Layout/TableCell.rb +149 -0
- data/SketchUp/Layout/TableColumn.rb +139 -0
- data/SketchUp/Layout/TableRow.rb +135 -0
- data/SketchUp/Sketchup/Animation.rb +7 -4
- data/SketchUp/Sketchup/ArcCurve.rb +10 -10
- data/SketchUp/Sketchup/AttributeDictionaries.rb +13 -4
- data/SketchUp/Sketchup/AttributeDictionary.rb +12 -12
- data/SketchUp/Sketchup/Color.rb +68 -78
- data/SketchUp/Sketchup/ComponentDefinition.rb +60 -60
- data/SketchUp/Sketchup/ComponentInstance.rb +57 -55
- data/SketchUp/Sketchup/DefinitionList.rb +34 -17
- data/SketchUp/Sketchup/Drawingelement.rb +19 -21
- data/SketchUp/Sketchup/Edge.rb +22 -24
- data/SketchUp/Sketchup/Entities.rb +173 -162
- data/SketchUp/Sketchup/Entity.rb +71 -55
- data/SketchUp/Sketchup/Face.rb +45 -44
- data/SketchUp/Sketchup/Group.rb +47 -49
- data/SketchUp/Sketchup/Image.rb +16 -0
- data/SketchUp/Sketchup/ImageRep.rb +226 -0
- data/SketchUp/Sketchup/InstancePath.rb +13 -13
- data/SketchUp/Sketchup/Layer.rb +15 -17
- data/SketchUp/Sketchup/Material.rb +40 -30
- data/SketchUp/Sketchup/Materials.rb +40 -22
- data/SketchUp/Sketchup/Menu.rb +5 -5
- data/SketchUp/Sketchup/Model.rb +230 -228
- data/SketchUp/Sketchup/Page.rb +32 -0
- data/SketchUp/Sketchup/Pages.rb +3 -4
- data/SketchUp/Sketchup/RenderingOptions.rb +21 -16
- data/SketchUp/Sketchup/SectionPlane.rb +64 -0
- data/SketchUp/Sketchup/Selection.rb +20 -28
- data/SketchUp/Sketchup/ShadowInfo.rb +14 -14
- data/SketchUp/Sketchup/Text.rb +24 -26
- data/SketchUp/Sketchup/Texture.rb +28 -12
- data/SketchUp/Sketchup/Vertex.rb +14 -11
- data/SketchUp/Sketchup/View.rb +126 -116
- data/SketchUp/UI/Command.rb +17 -17
- data/SketchUp/UI/HtmlDialog.rb +8 -5
- data/SketchUp/UI/Notification.rb +1 -1
- data/SketchUp/UI/Toolbar.rb +13 -14
- data/SketchUp/UI/WebDialog.rb +55 -59
- data/SketchUp/_top_level.rb +139 -27
- data/SketchUp/{Array.rb → array.rb} +167 -30
- data/SketchUp/{Geom.rb → geom.rb} +9 -7
- data/SketchUp/{LanguageHandler.rb → languagehandler.rb} +15 -15
- data/SketchUp/{Length.rb → length.rb} +15 -15
- data/SketchUp/{Numeric.rb → numeric.rb} +19 -19
- data/SketchUp/sketchup.rb +167 -156
- data/SketchUp/{SketchupExtension.rb → sketchupextension.rb} +27 -27
- data/SketchUp/{String.rb → string.rb} +1 -1
- data/SketchUp/ui.rb +113 -87
- metadata +46 -9
@@ -1,16 +1,23 @@
|
|
1
1
|
# Copyright:: Copyright 2017 Trimble Inc.
|
2
2
|
# License:: The MIT License (MIT)
|
3
3
|
|
4
|
-
# The ComponentDefinition class is used to define the contents for
|
5
|
-
# component. Components are a collection of entities that can be
|
6
|
-
# and reused multiple times throughout a model. For example, you
|
7
|
-
# draw a chair once, turn it into a component, and then use 6 instances
|
8
|
-
# it to surround a table. Edits to the original "definition" will then
|
4
|
+
# The {Sketchup::ComponentDefinition} class is used to define the contents for
|
5
|
+
# a SketchUp component. Components are a collection of entities that can be
|
6
|
+
# instanced and reused multiple times throughout a model. For example, you
|
7
|
+
# could draw a chair once, turn it into a component, and then use 6 instances
|
8
|
+
# of it to surround a table. Edits to the original "definition" will then
|
9
9
|
# propagate across all of its instances.
|
10
10
|
#
|
11
|
-
# The ComponentDefinition class contains the global entities and settings
|
12
|
-
#
|
13
|
-
# is defined.
|
11
|
+
# The ComponentDefinition class contains the global entities and settings for
|
12
|
+
# each definition. See the {Sketchup::ComponentInstance} class for how each
|
13
|
+
# copy is defined.
|
14
|
+
#
|
15
|
+
# Starting from SketchUp 2018+, the {Sketchup::ComponentDefinition} class
|
16
|
+
# contains a new default attribute dictionary named "SU_DefinitionSet" with
|
17
|
+
# default keys named named "Price", "Size", "Url". See the
|
18
|
+
# {https://help.sketchup.com/en/article/3000124 Help article} for more
|
19
|
+
# information. The dictionary cannot be deleted via ruby and an ArgumentError
|
20
|
+
# will be raised. The key/value pairs in the dictionary can be deleted safely.
|
14
21
|
#
|
15
22
|
# @version SketchUp 6.0
|
16
23
|
class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
@@ -33,10 +40,10 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
33
40
|
# UI.messagebox("c1 sorts before c2")
|
34
41
|
# end
|
35
42
|
#
|
36
|
-
# @param compdef2
|
43
|
+
# @param [Sketchup::ComponentDefinition] compdef2
|
37
44
|
# The second component definition in the comparison.
|
38
45
|
#
|
39
|
-
# @return
|
46
|
+
# @return [Integer] a -1 if component1 is less then component2. A 1
|
40
47
|
# if component1 greater than component2
|
41
48
|
#
|
42
49
|
# @version SketchUp 6.0
|
@@ -55,10 +62,10 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
55
62
|
# UI.messagebox("These definitions are the same.")
|
56
63
|
# end
|
57
64
|
#
|
58
|
-
# @param compdef2
|
65
|
+
# @param [Sketchup::ComponentDefinition] compdef2
|
59
66
|
# The second component definition in the comparison.
|
60
67
|
#
|
61
|
-
# @return
|
68
|
+
# @return [Boolean] true if the ComponentDefinition objects are
|
62
69
|
# the same object. False if the objects are not the same.
|
63
70
|
#
|
64
71
|
# @version SketchUp 6.0
|
@@ -74,13 +81,13 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
74
81
|
# definition = Sketchup.active_model.definitions.first
|
75
82
|
# success = definition.add_classification("IFC 2x3", "IfcDoor")
|
76
83
|
#
|
77
|
-
# @param schema_name
|
84
|
+
# @param [String] schema_name
|
78
85
|
# a String - Schema name to add
|
79
86
|
#
|
80
|
-
# @param schema_type
|
87
|
+
# @param [String] schema_type
|
81
88
|
# a String - Schema type to add
|
82
89
|
#
|
83
|
-
# @return true if the classification succeeds. Otherwise false.
|
90
|
+
# @return [Boolean] true if the classification succeeds. Otherwise false.
|
84
91
|
#
|
85
92
|
# @version SketchUp 2015
|
86
93
|
def add_classification(schema_name, schema_type)
|
@@ -92,10 +99,10 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
92
99
|
# componentdefinition = Sketchup.active_model.definitions[0]
|
93
100
|
# status = componentdefinition.add_observer observer
|
94
101
|
#
|
95
|
-
# @param observer
|
102
|
+
# @param [Object] observer
|
96
103
|
# An observer.
|
97
104
|
#
|
98
|
-
# @return true if successful, false if unsuccessful.
|
105
|
+
# @return [Boolean] true if successful, false if unsuccessful.
|
99
106
|
#
|
100
107
|
# @version SketchUp 6.0
|
101
108
|
def add_observer(observer)
|
@@ -112,7 +119,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
112
119
|
# componentdefinition = definitions.load path
|
113
120
|
# behavior = componentdefinition.behavior
|
114
121
|
#
|
115
|
-
# @return
|
122
|
+
# @return [Sketchup::Behavior] a Behavior object if successful
|
116
123
|
#
|
117
124
|
# @version SketchUp 6.0
|
118
125
|
def behavior
|
@@ -130,7 +137,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
130
137
|
# definition = definitions.load(path)
|
131
138
|
# number = definition.count_instances
|
132
139
|
#
|
133
|
-
# @return
|
140
|
+
# @return [Integer] the number of component instances of this
|
134
141
|
# component definition (if successful)
|
135
142
|
#
|
136
143
|
# @version SketchUp 6.0
|
@@ -148,7 +155,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
148
155
|
# definition = definitions.load(path)
|
149
156
|
# number = definition.count_used_instances
|
150
157
|
#
|
151
|
-
# @return
|
158
|
+
# @return [Integer] the number of component instances of this
|
152
159
|
# component definition (if successful)
|
153
160
|
#
|
154
161
|
# @version SketchUp 2016
|
@@ -165,8 +172,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
165
172
|
# componentdefinition = Sketchup.active_model.definitions[0]
|
166
173
|
# description = componentdefinition.description
|
167
174
|
#
|
168
|
-
# @return
|
169
|
-
# definition if successful
|
175
|
+
# @return [String] the description of the component definition if successful
|
170
176
|
#
|
171
177
|
# @version SketchUp 6.0
|
172
178
|
def description
|
@@ -182,7 +188,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
182
188
|
#
|
183
189
|
# @param [String] description
|
184
190
|
#
|
185
|
-
# @return
|
191
|
+
# @return [String] the description if successful, false if
|
186
192
|
# unsuccessful
|
187
193
|
#
|
188
194
|
# @version SketchUp 6.0
|
@@ -196,7 +202,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
196
202
|
# componentdefinition = Sketchup.active_model.definitions[0]
|
197
203
|
# entities = componentdefinition.entities
|
198
204
|
#
|
199
|
-
# @return
|
205
|
+
# @return [Sketchup::Entities] an Entities object if successful
|
200
206
|
#
|
201
207
|
# @version SketchUp 6.0
|
202
208
|
def entities
|
@@ -212,10 +218,10 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
212
218
|
# path = ["IFC 2x3", "IfcDoor", "ObjectType", "IfcLabel"]
|
213
219
|
# value = definition.get_classification_value(path)
|
214
220
|
#
|
215
|
-
# @param path
|
221
|
+
# @param [Array<String>] path
|
216
222
|
# An array composed of the key path to the value.
|
217
223
|
#
|
218
|
-
# @return
|
224
|
+
# @return [Object, nil] a Ruby object if successful, nil otherwise.
|
219
225
|
#
|
220
226
|
# @version SketchUp 2015
|
221
227
|
def get_classification_value(path)
|
@@ -232,8 +238,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
232
238
|
# componentdefinition = definitions.load path
|
233
239
|
# status = componentdefinition.group?
|
234
240
|
#
|
235
|
-
# @return
|
236
|
-
# group, false if the definition does not hold a group.
|
241
|
+
# @return [Boolean]
|
237
242
|
#
|
238
243
|
# @return [Boolean]
|
239
244
|
#
|
@@ -249,7 +254,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
249
254
|
# componentdefinition = Sketchup.active_model.definitions[0]
|
250
255
|
# guid = componentdefinition.guid
|
251
256
|
#
|
252
|
-
# @return
|
257
|
+
# @return [String] a string guid if successful
|
253
258
|
#
|
254
259
|
# @version SketchUp 6.0
|
255
260
|
def guid
|
@@ -262,8 +267,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
262
267
|
# componentdefinition = Sketchup.active_model.definitions[0]
|
263
268
|
# status = componentdefinition.hidden?
|
264
269
|
#
|
265
|
-
# @return
|
266
|
-
# if the definition should not be hidden
|
270
|
+
# @return [Boolean]
|
267
271
|
#
|
268
272
|
# @return [Boolean]
|
269
273
|
#
|
@@ -284,9 +288,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
284
288
|
# UI.messagebox "Component definition does not define an image"
|
285
289
|
# end
|
286
290
|
#
|
287
|
-
# @return
|
288
|
-
# image, false if the component definition does not
|
289
|
-
# define an image.
|
291
|
+
# @return [Boolean]
|
290
292
|
#
|
291
293
|
# @return [Boolean]
|
292
294
|
#
|
@@ -309,7 +311,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
309
311
|
# instance = entities.add_instance componentdefinition, transform
|
310
312
|
# point = componentdefinition.insertion_point
|
311
313
|
#
|
312
|
-
# @return
|
314
|
+
# @return [Geom::Point3d] the Point3d where the component was inserted if
|
313
315
|
# successful. False if unsuccessful.
|
314
316
|
#
|
315
317
|
# @version SketchUp 6.0
|
@@ -340,8 +342,8 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
340
342
|
# componentdefinition = Sketchup.active_model.definitions[0]
|
341
343
|
# instances = componentdefinition.instances
|
342
344
|
#
|
343
|
-
# @return
|
344
|
-
# successful)
|
345
|
+
# @return [Array<Sketchup::ComponentInstance>] an array of ComponentInstances
|
346
|
+
# (if successful)
|
345
347
|
#
|
346
348
|
# @version SketchUp 6.0
|
347
349
|
def instances
|
@@ -361,9 +363,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
361
363
|
# componentdefinition = definitions.load path
|
362
364
|
# status = componentdefinition.internal?
|
363
365
|
#
|
364
|
-
# @return
|
365
|
-
# to SketchUp's Component Browser. False if the
|
366
|
-
# component definition is not internal to SketchUp.
|
366
|
+
# @return [Boolean]
|
367
367
|
#
|
368
368
|
# @return [Boolean]
|
369
369
|
#
|
@@ -383,7 +383,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
383
383
|
# componentdefinition = Sketchup.active_model.definitions[0]
|
384
384
|
# componentdefinition.invalidate_bounds
|
385
385
|
#
|
386
|
-
# @return true if successful
|
386
|
+
# @return [Boolean] true if successful
|
387
387
|
#
|
388
388
|
# @version SketchUp 6.0
|
389
389
|
def invalidate_bounds
|
@@ -399,7 +399,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
399
399
|
# componentdefinition = definitions.load path
|
400
400
|
# name = componentdefinition.name
|
401
401
|
#
|
402
|
-
# @return
|
402
|
+
# @return [String] the component definition's name if successful
|
403
403
|
#
|
404
404
|
# @version SketchUp 6.0
|
405
405
|
def name
|
@@ -417,7 +417,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
417
417
|
#
|
418
418
|
# @param [String] name
|
419
419
|
#
|
420
|
-
# @return
|
420
|
+
# @return [String] the name assigned to the component definition if
|
421
421
|
# successful
|
422
422
|
#
|
423
423
|
# @version SketchUp 6.0
|
@@ -436,7 +436,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
436
436
|
# componentdefinition = definitions.load path
|
437
437
|
# path = componentdefinition.path
|
438
438
|
#
|
439
|
-
# @return
|
439
|
+
# @return [String, false] a valid path if successful, false if
|
440
440
|
# unsuccessful
|
441
441
|
#
|
442
442
|
# @version SketchUp 6.0
|
@@ -452,7 +452,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
452
452
|
# componentdefinition = Sketchup.active_model.definitions[0]
|
453
453
|
# componentdefinition.refresh_thumbnail
|
454
454
|
#
|
455
|
-
# @return nil
|
455
|
+
# @return [nil]
|
456
456
|
#
|
457
457
|
# @version SketchUp 7.0
|
458
458
|
def refresh_thumbnail
|
@@ -467,15 +467,15 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
467
467
|
# definition = Sketchup.active_model.definitions.first
|
468
468
|
# success = definition.remove_classification("IFC 2x3", "IfcDoor")
|
469
469
|
#
|
470
|
-
# @param schema_name
|
471
|
-
#
|
470
|
+
# @param [String] schema_name
|
471
|
+
# Schema name to remove
|
472
472
|
#
|
473
|
-
# @param schema_type
|
474
|
-
#
|
473
|
+
# @param [String] schema_type
|
474
|
+
# Schema type to remove. If not provided or an
|
475
475
|
# empty string, the currently applied schema type for the
|
476
476
|
# given schema name will be removed.
|
477
477
|
#
|
478
|
-
# @return true if the removal succeeds. Otherwise false.
|
478
|
+
# @return [Boolean] true if the removal succeeds. Otherwise false.
|
479
479
|
#
|
480
480
|
# @version SketchUp 2015
|
481
481
|
def remove_classification(schema_name, schema_type)
|
@@ -488,10 +488,10 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
488
488
|
# componentdefinition = Sketchup.active_model.definitions[0]
|
489
489
|
# status = componentdefinition.remove_observer observer
|
490
490
|
#
|
491
|
-
# @param observer
|
491
|
+
# @param [Object] observer
|
492
492
|
# An observer.
|
493
493
|
#
|
494
|
-
# @return true if successful, false if unsuccessful.
|
494
|
+
# @return [Boolean] true if successful, false if unsuccessful.
|
495
495
|
#
|
496
496
|
# @version SketchUp 6.0
|
497
497
|
def remove_observer(observer)
|
@@ -504,10 +504,10 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
504
504
|
# my_definition = Sketchup.active_model.definitions[0]
|
505
505
|
# success = my_definition.save_as "c:\\myComponent.skp"
|
506
506
|
#
|
507
|
-
# @param file_path
|
507
|
+
# @param [String] file_path
|
508
508
|
# Local file path to save the .skp file to.
|
509
509
|
#
|
510
|
-
# @return true if successful
|
510
|
+
# @return [Boolean] true if successful
|
511
511
|
#
|
512
512
|
# @version SketchUp 7.0
|
513
513
|
def save_as(file_path)
|
@@ -523,7 +523,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
523
523
|
#
|
524
524
|
# @param [String] filename
|
525
525
|
#
|
526
|
-
# @return true if successful, false otherwise.
|
526
|
+
# @return [Boolean] true if successful, false otherwise.
|
527
527
|
#
|
528
528
|
# @version SketchUp 7.0
|
529
529
|
def save_thumbnail(filename)
|
@@ -539,12 +539,12 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
539
539
|
# path = ["IFC 2x3", "IfcDoor", "ObjectType", "IfcLabel"]
|
540
540
|
# success = definition.set_classification_value(path, "Room 101")
|
541
541
|
#
|
542
|
-
# @param
|
543
|
-
# A value valid for that specific attribute.
|
544
|
-
#
|
545
|
-
# @param path
|
542
|
+
# @param [Array<String>] path
|
546
543
|
# An array composed of the key path to the value.
|
547
544
|
#
|
545
|
+
# @param [Object] value
|
546
|
+
# A value valid for that specific attribute.
|
547
|
+
#
|
548
548
|
# @raise [NotImplementedError] when trying to set the value of "choice"
|
549
549
|
# attributes.
|
550
550
|
#
|
@@ -553,7 +553,7 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
553
553
|
#
|
554
554
|
# @raise [RuntimeError] if the attributes being set are corrupt.
|
555
555
|
#
|
556
|
-
# @return
|
556
|
+
# @return [Boolean] true if the path was valid, false otherwise.
|
557
557
|
#
|
558
558
|
# @version SketchUp 2015
|
559
559
|
def set_classification_value(path, value)
|
@@ -1,12 +1,19 @@
|
|
1
1
|
# Copyright:: Copyright 2017 Trimble Inc.
|
2
2
|
# License:: The MIT License (MIT)
|
3
3
|
|
4
|
-
# The ComponentInstance class is used to represent component
|
5
|
-
# component definition or components that have been dragged from
|
6
|
-
# Browser and placed (thus, instanced) within the Model.
|
7
|
-
# ComponentInstance class contains a reference to a
|
8
|
-
# ComponentDefinition object and a Transformation object (which
|
9
|
-
# location of the component in the Drawing Window).
|
4
|
+
# The {Sketchup::ComponentInstance} class is used to represent component
|
5
|
+
# instances of a component definition or components that have been dragged from
|
6
|
+
# the Component Browser and placed (thus, instanced) within the Model.
|
7
|
+
# Therefore, the ComponentInstance class contains a reference to a
|
8
|
+
# corresponding ComponentDefinition object and a Transformation object (which
|
9
|
+
# contains the location of the component in the Drawing Window).
|
10
|
+
#
|
11
|
+
# Starting from SketchUp 2018+, the {Sketchup::ComponentInstance} class
|
12
|
+
# contains default attributes when created or imported. The attributes
|
13
|
+
# are: "Owner", "Status". See the
|
14
|
+
# {https://help.sketchup.com/en/article/3000124 Help article} for more
|
15
|
+
# information. The dictionary cannot be deleted via ruby and an @raise ArgumentError
|
16
|
+
# will be raised. The key/value pairs in the dictionary can be deleted safely.
|
10
17
|
#
|
11
18
|
# @version SketchUp 6.0
|
12
19
|
class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
@@ -22,10 +29,10 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
22
29
|
# componentinstance = entities.add_instance(definition, transformation)
|
23
30
|
# status = componentinstance.add_observer observer
|
24
31
|
#
|
25
|
-
# @param observer
|
32
|
+
# @param [Object] observer
|
26
33
|
# An observer.
|
27
34
|
#
|
28
|
-
# @return true if successful, false if unsuccessful.
|
35
|
+
# @return [Boolean] true if successful, false if unsuccessful.
|
29
36
|
#
|
30
37
|
# @version SketchUp 6.0
|
31
38
|
def add_observer(observer)
|
@@ -44,7 +51,7 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
44
51
|
# # You can get an instance's definition with this method.
|
45
52
|
# definition = componentinstance.definition
|
46
53
|
#
|
47
|
-
# @return
|
54
|
+
# @return [Sketchup::ComponentDefinition] a ComponentDefinition object if
|
48
55
|
# successful
|
49
56
|
#
|
50
57
|
# @version SketchUp 6.0
|
@@ -69,10 +76,10 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
69
76
|
# # Replace 2nd instance with the 1st definition.
|
70
77
|
# instance2.definition = definition1
|
71
78
|
#
|
72
|
-
# @param definition
|
79
|
+
# @param [Sketchup::ComponentDefinition] definition
|
73
80
|
# A ComponentDefinition object to set.
|
74
81
|
#
|
75
|
-
# @return
|
82
|
+
# @return [Sketchup::ComponentDefinition] the ComponentDefinition object
|
76
83
|
# that was set if successful, false if unsuccessful
|
77
84
|
#
|
78
85
|
# @version SketchUp 6.0
|
@@ -88,12 +95,10 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
88
95
|
# instance2 = entities[1]
|
89
96
|
# status = instance1.equals?(instance2)
|
90
97
|
#
|
91
|
-
# @param instance
|
98
|
+
# @param [Sketchup::ComponentInstance] instance
|
92
99
|
# The instance to compare this instance with.
|
93
100
|
#
|
94
|
-
# @return
|
95
|
-
# equivalent.
|
96
|
-
# Otherwise false.
|
101
|
+
# @return [Boolean]
|
97
102
|
#
|
98
103
|
# @return [Boolean]
|
99
104
|
#
|
@@ -113,7 +118,7 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
113
118
|
# UI.messagebox "Failure"
|
114
119
|
# end
|
115
120
|
#
|
116
|
-
# @return An array of entity objects if successful, false if
|
121
|
+
# @return [Array<Sketchup:Entity>] An array of entity objects if successful, false if
|
117
122
|
# unsuccessful
|
118
123
|
#
|
119
124
|
# @version SketchUp 6.0
|
@@ -137,7 +142,7 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
137
142
|
# instance = entities.add_instance componentdefinition, transform
|
138
143
|
# status = instance.glued_to
|
139
144
|
#
|
140
|
-
# @return
|
145
|
+
# @return [Sketchup::Face, nil] the Entity object that the instance is glued
|
141
146
|
# to (if successful)
|
142
147
|
#
|
143
148
|
# @version SketchUp 6.0
|
@@ -180,9 +185,9 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
180
185
|
# UI.messagebox "Failure"
|
181
186
|
# end
|
182
187
|
#
|
183
|
-
# @param [Sketchup::Face] face
|
188
|
+
# @param [Sketchup::Face, nil] face
|
184
189
|
#
|
185
|
-
# @return
|
190
|
+
# @return [Sketchup::Face, nil] - the Face object where the component is glued if
|
186
191
|
# successful
|
187
192
|
#
|
188
193
|
# @version SketchUp 6.0
|
@@ -199,7 +204,7 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
199
204
|
# componentinstance = entities.add_instance(definition, transformation)
|
200
205
|
# guid = componentinstance.guid
|
201
206
|
#
|
202
|
-
# @return
|
207
|
+
# @return [String] a unique 22 character string
|
203
208
|
#
|
204
209
|
# @version SketchUp 2014
|
205
210
|
def guid
|
@@ -215,10 +220,10 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
215
220
|
# instance2 = entities[1]
|
216
221
|
# result = instance1.intersect(instance2)
|
217
222
|
#
|
218
|
-
# @param instance
|
223
|
+
# @param [Sketchup::ComponentInstance] instance
|
219
224
|
# The instance to intersect this instance with.
|
220
225
|
#
|
221
|
-
# @return
|
226
|
+
# @return [Sketchup::Group, nil] The resultant group if the two objects
|
222
227
|
# (this and arg) represent manifold solids and the
|
223
228
|
# operation succeeds otherwise nil is returned.
|
224
229
|
#
|
@@ -237,7 +242,7 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
237
242
|
#
|
238
243
|
# @param [Boolean] lock
|
239
244
|
#
|
240
|
-
# @return
|
245
|
+
# @return [Boolean] true if the component instance is locked.
|
241
246
|
# False if the instance is not locked.
|
242
247
|
#
|
243
248
|
# @version SketchUp 6.0
|
@@ -253,8 +258,7 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
253
258
|
# componentinstance = entities.add_instance(definition, transformation)
|
254
259
|
# status = componentinstance.locked?
|
255
260
|
#
|
256
|
-
# @return
|
257
|
-
# False if the instance is not locked.
|
261
|
+
# @return [Boolean]
|
258
262
|
#
|
259
263
|
# @return [Boolean]
|
260
264
|
#
|
@@ -279,7 +283,7 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
279
283
|
# # Returns unique component instance
|
280
284
|
# status = instance.make_unique
|
281
285
|
#
|
282
|
-
# @return
|
286
|
+
# @return [Boolean] true if successful, false if unsuccessful
|
283
287
|
#
|
284
288
|
# @version SketchUp 6.0
|
285
289
|
def make_unique
|
@@ -294,8 +298,7 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
294
298
|
# componentinstance = entities.add_instance(definition, transformation)
|
295
299
|
# status = componentinstance.manifold?
|
296
300
|
#
|
297
|
-
# @return
|
298
|
-
# false if the instance is not manifold.
|
301
|
+
# @return [Boolean]
|
299
302
|
#
|
300
303
|
# @return [Boolean]
|
301
304
|
#
|
@@ -317,10 +320,10 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
317
320
|
# new_transformation = Geom::Transformation.new([100,0,0])
|
318
321
|
# componentinstance.move! new_transformation
|
319
322
|
#
|
320
|
-
# @param transform
|
323
|
+
# @param [Geom::Transformation] transform
|
321
324
|
# The transform object to apply to the component instance.
|
322
325
|
#
|
323
|
-
# @return
|
326
|
+
# @return [Boolean] true if successful, false if unsuccessful
|
324
327
|
#
|
325
328
|
# @version SketchUp 6.0
|
326
329
|
def move!(transform)
|
@@ -335,7 +338,7 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
335
338
|
# componentinstance = entities.add_instance(definition, transformation)
|
336
339
|
# name = componentinstance.name
|
337
340
|
#
|
338
|
-
# @return
|
341
|
+
# @return [String] the string name of the ComponentInstance
|
339
342
|
#
|
340
343
|
# @version SketchUp 6.0
|
341
344
|
def name
|
@@ -350,10 +353,10 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
350
353
|
# componentinstance = entities.add_instance(definition, transformation)
|
351
354
|
# componentinstance.name = "Sang"
|
352
355
|
#
|
353
|
-
# @param name
|
354
|
-
#
|
356
|
+
# @param [String] name
|
357
|
+
# the string name to set
|
355
358
|
#
|
356
|
-
# @return
|
359
|
+
# @return [Sketchup::ComponentInstance] the newly named ComponentInstance
|
357
360
|
#
|
358
361
|
# @version SketchUp 6.0
|
359
362
|
def name=(name)
|
@@ -369,10 +372,10 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
369
372
|
# instance2 = entities[1]
|
370
373
|
# result = instance1.outer_shell(instance2)
|
371
374
|
#
|
372
|
-
# @param instance
|
375
|
+
# @param [Sketchup::ComponentInstance] instance
|
373
376
|
# The instance to outer shell this instance with.
|
374
377
|
#
|
375
|
-
# @return
|
378
|
+
# @return [Sketchup::Group, nil] The resultant group if the two objects
|
376
379
|
# (this and arg) represent manifold solids and the
|
377
380
|
# operation succeeds otherwise nil is returned.
|
378
381
|
#
|
@@ -390,10 +393,10 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
390
393
|
# componentinstance = entities.add_instance(definition, transformation)
|
391
394
|
# status = componentinstance.remove_observer observer
|
392
395
|
#
|
393
|
-
# @param observer
|
396
|
+
# @param [Object] observer
|
394
397
|
# An observer.
|
395
398
|
#
|
396
|
-
# @return true if successful, false if unsuccessful.
|
399
|
+
# @return [Boolean] true if successful, false if unsuccessful.
|
397
400
|
#
|
398
401
|
# @version SketchUp 6.0
|
399
402
|
def remove_observer(observer)
|
@@ -417,14 +420,14 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
417
420
|
# instance2 = entities[1]
|
418
421
|
# status = instance1.show_differences(instance2, true)
|
419
422
|
#
|
420
|
-
# @param instance
|
423
|
+
# @param [Sketchup::ComponentInstance] instance
|
421
424
|
# The instance to be compared with.
|
422
425
|
#
|
423
|
-
# @param verbose
|
426
|
+
# @param [Boolean] verbose
|
424
427
|
# A boolean flag indicating whether to display a textural
|
425
428
|
# report of the found differences to the Ruby console.
|
426
429
|
#
|
427
|
-
# @return
|
430
|
+
# @return [Boolean] true if the instances are geometrically
|
428
431
|
# equivalent, otherwise false.
|
429
432
|
#
|
430
433
|
# @version SketchUp 8.0
|
@@ -441,12 +444,12 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
441
444
|
# instance2 = entities[1]
|
442
445
|
# result = instance1.split(instance2)
|
443
446
|
#
|
444
|
-
# @param instance
|
447
|
+
# @param [Sketchup::ComponentInstance, nil] instance
|
445
448
|
# The instance to split this instance with.
|
446
449
|
#
|
447
|
-
# @return
|
450
|
+
# @return [Array(Sketchup::Group, Sketchup::Group, Sketchup::Group)] A vector (array) of the three resultant groups
|
448
451
|
# if the two objects (this and arg) represent manifold
|
449
|
-
# solids and the operation succeeds otherwise
|
452
|
+
# solids and the operation succeeds otherwise nil is
|
450
453
|
# returned. The 3 groups are as follows: The intersection
|
451
454
|
# of volume 1 & volume 2, the difference of
|
452
455
|
# volume 1 minus volume 2, and the reverse difference of
|
@@ -466,10 +469,10 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
466
469
|
# instance2 = entities[1]
|
467
470
|
# result = instance1.subtract(instance2)
|
468
471
|
#
|
469
|
-
# @param instance
|
472
|
+
# @param [Sketchup::ComponentInstance] instance
|
470
473
|
# The instance to subtract this instance from.
|
471
474
|
#
|
472
|
-
# @return
|
475
|
+
# @return [Sketchup::Group, nil] The resultant group if the two objects
|
473
476
|
# (this and arg) represent manifold solids and the
|
474
477
|
# operation succeeds otherwise nil is returned.
|
475
478
|
#
|
@@ -506,8 +509,7 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
506
509
|
# componentinstance = entities.add_instance(definition, transformation)
|
507
510
|
# t = componentinstance.transformation
|
508
511
|
#
|
509
|
-
# @return
|
510
|
-
# successful
|
512
|
+
# @return [Geom::Transformation] the Transformation object if successful
|
511
513
|
#
|
512
514
|
# @version SketchUp 6.0
|
513
515
|
def transformation
|
@@ -524,10 +526,10 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
524
526
|
# new_transformation = Geom::Transformation.new([100,0,0])
|
525
527
|
# componentinstance.transformation = new_transformation
|
526
528
|
#
|
527
|
-
# @param transformation
|
529
|
+
# @param [Geom::Transformation] transformation
|
528
530
|
# A Transformation object to apply.
|
529
531
|
#
|
530
|
-
# @return
|
532
|
+
# @return [Sketchup::ComponentInstance] the transformed ComponentInstance
|
531
533
|
#
|
532
534
|
# @version SketchUp 6.0
|
533
535
|
def transformation=(transformation)
|
@@ -544,10 +546,10 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
544
546
|
# instance2 = entities[1]
|
545
547
|
# result = instance1.trim(instance2)
|
546
548
|
#
|
547
|
-
# @param instance
|
549
|
+
# @param [Sketchup::ComponentInstance] instance
|
548
550
|
# The instance to trim this instance against.
|
549
551
|
#
|
550
|
-
# @return
|
552
|
+
# @return [Sketchup::Group, nil] The resultant group if the two objects
|
551
553
|
# (this and arg) represent manifold solids and the
|
552
554
|
# operation succeeds otherwise nil is returned.
|
553
555
|
#
|
@@ -565,10 +567,10 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
565
567
|
# instance2 = entities[1]
|
566
568
|
# result = instance1.union(instance2)
|
567
569
|
#
|
568
|
-
# @param instance
|
570
|
+
# @param [Sketchup::ComponentInstance] instance
|
569
571
|
# The instance to union this instance with.
|
570
572
|
#
|
571
|
-
# @return
|
573
|
+
# @return [Sketchup::Group, nil] The resultant group if the two objects
|
572
574
|
# (this and arg) represent manifold solids and the
|
573
575
|
# operation succeeds otherwise nil is returned.
|
574
576
|
#
|
@@ -586,7 +588,7 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
586
588
|
# componentinstance = entities.add_instance(definition, transformation)
|
587
589
|
# volume = componentinstance.volume
|
588
590
|
#
|
589
|
-
# @return
|
591
|
+
# @return [Float] If the instance represents a manifold volume,
|
590
592
|
# volume will be a positive value. If volume is negative,
|
591
593
|
# the instance is not manifold.
|
592
594
|
#
|