sketchup-api-stubs 0.7.7 → 0.7.9
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/sketchup.rb +151 -147
- data/lib/sketchup-api-stubs/stubs/{array.rb → Array.rb} +741 -741
- data/lib/sketchup-api-stubs/stubs/Geom/BoundingBox.rb +322 -322
- 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 +509 -509
- data/lib/sketchup-api-stubs/stubs/Geom/Transformation.rb +476 -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 +693 -691
- data/lib/sketchup-api-stubs/stubs/{geom.rb → Geom.rb} +351 -351
- data/lib/sketchup-api-stubs/stubs/{languagehandler.rb → LanguageHandler.rb} +93 -92
- data/lib/sketchup-api-stubs/stubs/Layout/AngularDimension.rb +595 -573
- data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinition.rb +747 -411
- data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinitions.rb +183 -179
- data/lib/sketchup-api-stubs/stubs/Layout/ConnectionPoint.rb +70 -70
- data/lib/sketchup-api-stubs/stubs/Layout/Document.rb +517 -515
- data/lib/sketchup-api-stubs/stubs/Layout/Ellipse.rb +29 -29
- data/lib/sketchup-api-stubs/stubs/Layout/Entities.rb +148 -148
- data/lib/sketchup-api-stubs/stubs/Layout/Entity.rb +353 -353
- data/lib/sketchup-api-stubs/stubs/Layout/FormattedText.rb +354 -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 -370
- 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 -225
- 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 -209
- 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/ReferenceEntity.rb +82 -0
- data/lib/sketchup-api-stubs/stubs/Layout/SketchUpModel.rb +692 -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/Layout.rb +25 -25
- data/lib/sketchup-api-stubs/stubs/{length.rb → Length.rb} +278 -278
- data/lib/sketchup-api-stubs/stubs/{numeric.rb → Numeric.rb} +249 -249
- data/lib/sketchup-api-stubs/stubs/Sketchup/Animation.rb +144 -144
- data/lib/sketchup-api-stubs/stubs/Sketchup/AppObserver.rb +169 -157
- data/lib/sketchup-api-stubs/stubs/Sketchup/ArcCurve.rb +209 -209
- data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionaries.rb +150 -152
- data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionary.rb +281 -286
- data/lib/sketchup-api-stubs/stubs/Sketchup/Axes.rb +149 -149
- data/lib/sketchup-api-stubs/stubs/Sketchup/Behavior.rb +302 -302
- data/lib/sketchup-api-stubs/stubs/Sketchup/Camera.rb +478 -478
- data/lib/sketchup-api-stubs/stubs/Sketchup/ClassificationSchema.rb +63 -63
- data/lib/sketchup-api-stubs/stubs/Sketchup/Classifications.rb +121 -122
- data/lib/sketchup-api-stubs/stubs/Sketchup/Color.rb +294 -294
- data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentDefinition.rb +659 -577
- data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentInstance.rb +593 -594
- 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 -201
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionList.rb +449 -425
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb +74 -74
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionsObserver.rb +104 -104
- data/lib/sketchup-api-stubs/stubs/Sketchup/Dimension.rb +165 -165
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionLinear.rb +306 -306
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionObserver.rb +42 -42
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionRadial.rb +87 -87
- data/lib/sketchup-api-stubs/stubs/Sketchup/Drawingelement.rb +406 -396
- data/lib/sketchup-api-stubs/stubs/Sketchup/Edge.rb +397 -502
- data/lib/sketchup-api-stubs/stubs/Sketchup/EdgeUse.rb +211 -211
- data/lib/sketchup-api-stubs/stubs/Sketchup/Entities.rb +1239 -1126
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesBuilder.rb +261 -0
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesObserver.rb +127 -127
- data/lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb +545 -545
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntityObserver.rb +60 -60
- data/lib/sketchup-api-stubs/stubs/Sketchup/ExtensionsManager.rb +125 -126
- data/lib/sketchup-api-stubs/stubs/Sketchup/Face.rb +937 -917
- data/lib/sketchup-api-stubs/stubs/Sketchup/FrameChangeObserver.rb +102 -104
- data/lib/sketchup-api-stubs/stubs/Sketchup/Group.rb +750 -750
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Request.rb +282 -292
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Response.rb +62 -62
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http.rb +27 -27
- data/lib/sketchup-api-stubs/stubs/Sketchup/Image.rb +468 -468
- data/lib/sketchup-api-stubs/stubs/Sketchup/ImageRep.rb +266 -266
- data/lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb +189 -189
- data/lib/sketchup-api-stubs/stubs/Sketchup/InputPoint.rb +406 -405
- data/lib/sketchup-api-stubs/stubs/Sketchup/InstanceObserver.rb +84 -84
- data/lib/sketchup-api-stubs/stubs/Sketchup/InstancePath.rb +306 -306
- data/lib/sketchup-api-stubs/stubs/Sketchup/Layer.rb +326 -327
- data/lib/sketchup-api-stubs/stubs/Sketchup/LayerFolder.rb +422 -422
- data/lib/sketchup-api-stubs/stubs/Sketchup/Layers.rb +427 -427
- data/lib/sketchup-api-stubs/stubs/Sketchup/LayersObserver.rb +249 -249
- data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing/ExtensionLicense.rb +86 -86
- data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing.rb +48 -48
- data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyle.rb +24 -24
- data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyles.rb +114 -112
- data/lib/sketchup-api-stubs/stubs/Sketchup/Loop.rb +137 -137
- data/lib/sketchup-api-stubs/stubs/Sketchup/Material.rb +414 -414
- data/lib/sketchup-api-stubs/stubs/Sketchup/Materials.rb +317 -318
- data/lib/sketchup-api-stubs/stubs/Sketchup/MaterialsObserver.rb +142 -142
- data/lib/sketchup-api-stubs/stubs/Sketchup/Menu.rb +93 -93
- data/lib/sketchup-api-stubs/stubs/Sketchup/Model.rb +1652 -1654
- data/lib/sketchup-api-stubs/stubs/Sketchup/ModelObserver.rb +357 -357
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsManager.rb +130 -131
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb +271 -284
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProviderObserver.rb +58 -58
- data/lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb +490 -0
- data/lib/sketchup-api-stubs/stubs/Sketchup/OverlaysManager.rb +116 -0
- data/lib/sketchup-api-stubs/stubs/Sketchup/Page.rb +797 -797
- data/lib/sketchup-api-stubs/stubs/Sketchup/Pages.rb +361 -363
- data/lib/sketchup-api-stubs/stubs/Sketchup/PagesObserver.rb +77 -77
- data/lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb +478 -478
- data/lib/sketchup-api-stubs/stubs/Sketchup/RegionalSettings.rb +43 -43
- data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptions.rb +361 -364
- data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptionsObserver.rb +45 -45
- data/lib/sketchup-api-stubs/stubs/Sketchup/SectionPlane.rb +150 -150
- data/lib/sketchup-api-stubs/stubs/Sketchup/Selection.rb +458 -459
- 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 +255 -257
- data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfoObserver.rb +59 -59
- data/lib/sketchup-api-stubs/stubs/Sketchup/Skp.rb +40 -40
- data/lib/sketchup-api-stubs/stubs/Sketchup/Style.rb +69 -69
- data/lib/sketchup-api-stubs/stubs/Sketchup/Styles.rb +217 -217
- data/lib/sketchup-api-stubs/stubs/Sketchup/Text.rb +262 -262
- data/lib/sketchup-api-stubs/stubs/Sketchup/Texture.rb +217 -217
- data/lib/sketchup-api-stubs/stubs/Sketchup/TextureWriter.rb +237 -237
- data/lib/sketchup-api-stubs/stubs/Sketchup/Tool.rb +834 -835
- data/lib/sketchup-api-stubs/stubs/Sketchup/Tools.rb +132 -132
- data/lib/sketchup-api-stubs/stubs/Sketchup/ToolsObserver.rb +156 -156
- data/lib/sketchup-api-stubs/stubs/Sketchup/UVHelper.rb +75 -71
- data/lib/sketchup-api-stubs/stubs/Sketchup/Vertex.rb +142 -142
- data/lib/sketchup-api-stubs/stubs/Sketchup/View.rb +1311 -1307
- data/lib/sketchup-api-stubs/stubs/Sketchup/ViewObserver.rb +45 -45
- data/lib/sketchup-api-stubs/stubs/{sketchup.rb → Sketchup.rb} +1377 -1353
- data/lib/sketchup-api-stubs/stubs/{sketchupextension.rb → SketchupExtension.rb} +353 -353
- data/lib/sketchup-api-stubs/stubs/{string.rb → String.rb} +24 -24
- data/lib/sketchup-api-stubs/stubs/UI/Command.rb +389 -317
- data/lib/sketchup-api-stubs/stubs/UI/HtmlDialog.rb +494 -478
- data/lib/sketchup-api-stubs/stubs/UI/Notification.rb +269 -269
- data/lib/sketchup-api-stubs/stubs/UI/Toolbar.rb +241 -240
- data/lib/sketchup-api-stubs/stubs/UI/WebDialog.rb +635 -633
- data/lib/sketchup-api-stubs/stubs/{ui.rb → UI.rb} +683 -672
- data/lib/sketchup-api-stubs/stubs/_top_level.rb +303 -311
- data/lib/sketchup-api-stubs.rb +1 -1
- metadata +20 -16
@@ -1,425 +1,449 @@
|
|
1
|
-
# Copyright:: Copyright
|
2
|
-
# License:: The MIT License (MIT)
|
3
|
-
|
4
|
-
# A DefinitionList object holds a list of all of the ComponentDefinition
|
5
|
-
# objects in a model. This class contains methods for adding and retrieving
|
6
|
-
# definitions from the list.
|
7
|
-
#
|
8
|
-
# @version SketchUp 6.0
|
9
|
-
class Sketchup::DefinitionList < Entity
|
10
|
-
|
11
|
-
# Includes
|
12
|
-
|
13
|
-
include Enumerable
|
14
|
-
|
15
|
-
# Instance Methods
|
16
|
-
|
17
|
-
# The [] method is used to retrieve a component definition from the list. You
|
18
|
-
# can give an integer index in the range 0 to length, a string which
|
19
|
-
# represents the GUID (a unique internal identifier), or a string that is
|
20
|
-
# the name of the definition.
|
21
|
-
#
|
22
|
-
# @example
|
23
|
-
# path=Sketchup.find_support_file "Bed.skp",
|
24
|
-
# "Components/Components Sampler/"
|
25
|
-
# model = Sketchup.active_model
|
26
|
-
# definitions = model.definitions
|
27
|
-
# componentdefinition = definitions.load path
|
28
|
-
# component = definitions[0]
|
29
|
-
#
|
30
|
-
# @overload [](index)
|
31
|
-
#
|
32
|
-
# @param [Integer] index The index for a specific component definition.
|
33
|
-
# @return [Sketchup::ComponentDefinition, nil]
|
34
|
-
#
|
35
|
-
# @overload [](name)
|
36
|
-
#
|
37
|
-
# @param [String] name The unique GUID for the component definition.
|
38
|
-
# @return [Sketchup::ComponentDefinition, nil]
|
39
|
-
#
|
40
|
-
# @overload [](guid)
|
41
|
-
#
|
42
|
-
# @param [String] guid The name of an existing component definition.
|
43
|
-
# @return [Sketchup::ComponentDefinition, nil]
|
44
|
-
#
|
45
|
-
# @version SketchUp 6.0
|
46
|
-
def [](arg)
|
47
|
-
end
|
48
|
-
|
49
|
-
# The add method is used to add a new component definition to the definition
|
50
|
-
# list with the given name.
|
51
|
-
#
|
52
|
-
# @example
|
53
|
-
# model = Sketchup.active_model
|
54
|
-
# definitions = model.definitions
|
55
|
-
# componentdefinition = definitions.add "BedTraditional"
|
56
|
-
# component = definitions[0]
|
57
|
-
#
|
58
|
-
# @param [String] def_name
|
59
|
-
# The new component definition to add to the definition
|
60
|
-
# list.
|
61
|
-
#
|
62
|
-
# @return [Sketchup::ComponentDefinition] the ComponentDefinition object
|
63
|
-
# that was added (if successful)
|
64
|
-
#
|
65
|
-
# @version SketchUp 6.0
|
66
|
-
def add(def_name)
|
67
|
-
end
|
68
|
-
|
69
|
-
# The add_observer method is used to add an observer to the current object.
|
70
|
-
#
|
71
|
-
# @example
|
72
|
-
# definitions = Sketchup.active_model.definitions
|
73
|
-
# status = definitions.add_observer observer
|
74
|
-
#
|
75
|
-
# @param [Object] observer
|
76
|
-
# An observer.
|
77
|
-
#
|
78
|
-
# @return [Boolean] true if successful, false if unsuccessful.
|
79
|
-
#
|
80
|
-
# @version SketchUp 6.0
|
81
|
-
def add_observer(observer)
|
82
|
-
end
|
83
|
-
|
84
|
-
# The [] method is used to retrieve a component definition from the list. You
|
85
|
-
# can give an integer index in the range 0 to length, a string which
|
86
|
-
# represents the GUID (a unique internal identifier), or a string that is
|
87
|
-
# the name of the definition.
|
88
|
-
#
|
89
|
-
# @example
|
90
|
-
# path=Sketchup.find_support_file "Bed.skp",
|
91
|
-
# "Components/Components Sampler/"
|
92
|
-
# model = Sketchup.active_model
|
93
|
-
# definitions = model.definitions
|
94
|
-
# componentdefinition = definitions.load path
|
95
|
-
# component = definitions[0]
|
96
|
-
#
|
97
|
-
# @overload [](index)
|
98
|
-
#
|
99
|
-
# @param [Integer] index The index for a specific component definition.
|
100
|
-
# @return [Sketchup::ComponentDefinition, nil]
|
101
|
-
#
|
102
|
-
# @overload [](name)
|
103
|
-
#
|
104
|
-
# @param [String] name The unique GUID for the component definition.
|
105
|
-
# @return [Sketchup::ComponentDefinition, nil]
|
106
|
-
#
|
107
|
-
# @overload [](guid)
|
108
|
-
#
|
109
|
-
# @param [String] guid The name of an existing component definition.
|
110
|
-
# @return [Sketchup::ComponentDefinition, nil]
|
111
|
-
#
|
112
|
-
# @version SketchUp 6.0
|
113
|
-
def at(arg)
|
114
|
-
end
|
115
|
-
|
116
|
-
#
|
117
|
-
# @example
|
118
|
-
# model = Sketchup.active_model
|
119
|
-
# definitions = model.definitions
|
120
|
-
# number = definitions.count
|
121
|
-
#
|
122
|
-
# @note Since SketchUp 2014 the count method is inherited from Ruby's
|
123
|
-
# +
|
124
|
-
# for {#length}.
|
125
|
-
#
|
126
|
-
# @return [Integer]
|
127
|
-
#
|
128
|
-
# @see #length
|
129
|
-
#
|
130
|
-
# @version SketchUp 6.0
|
131
|
-
def count
|
132
|
-
end
|
133
|
-
|
134
|
-
# The {#each} method is used to iterate through all of the component
|
135
|
-
# definitions in the definition list.
|
136
|
-
#
|
137
|
-
# @example
|
138
|
-
# model = Sketchup.active_model
|
139
|
-
# definitions = model.definitions
|
140
|
-
# definitions.add("BedTraditional")
|
141
|
-
# number = definitions.each { |definition| puts definition.name }
|
142
|
-
#
|
143
|
-
# @note Don't remove content from this collection while iterating over it with
|
144
|
-
# {#each}. This would change the size of the collection and cause elements to
|
145
|
-
# be skipped as the indices change. Instead copy the current collection to an
|
146
|
-
# array using +to_a+ and then use +each+ on the array, when removing content.
|
147
|
-
#
|
148
|
-
# @return [nil]
|
149
|
-
#
|
150
|
-
# @version SketchUp 6.0
|
151
|
-
#
|
152
|
-
# @
|
153
|
-
def each
|
154
|
-
end
|
155
|
-
|
156
|
-
# The {#import} method is used to import a (non-SketchUp) 3d model file as a definition.
|
157
|
-
#
|
158
|
-
# Importers using the C API +SketchUpModelImporterInterface+ interface are supported (those in the
|
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
|
-
#
|
211
|
-
#
|
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
|
-
#
|
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
|
-
# def
|
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
|
-
end
|
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
|
-
|
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
|
-
#
|
404
|
-
#
|
405
|
-
# @
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
#
|
410
|
-
#
|
411
|
-
#
|
412
|
-
# @
|
413
|
-
#
|
414
|
-
#
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
#
|
419
|
-
#
|
420
|
-
#
|
421
|
-
#
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
1
|
+
# Copyright:: Copyright 2023 Trimble Inc.
|
2
|
+
# License:: The MIT License (MIT)
|
3
|
+
|
4
|
+
# A DefinitionList object holds a list of all of the ComponentDefinition
|
5
|
+
# objects in a model. This class contains methods for adding and retrieving
|
6
|
+
# definitions from the list.
|
7
|
+
#
|
8
|
+
# @version SketchUp 6.0
|
9
|
+
class Sketchup::DefinitionList < Sketchup::Entity
|
10
|
+
|
11
|
+
# Includes
|
12
|
+
|
13
|
+
include Enumerable
|
14
|
+
|
15
|
+
# Instance Methods
|
16
|
+
|
17
|
+
# The [] method is used to retrieve a component definition from the list. You
|
18
|
+
# can give an integer index in the range 0 to length, a string which
|
19
|
+
# represents the GUID (a unique internal identifier), or a string that is
|
20
|
+
# the name of the definition.
|
21
|
+
#
|
22
|
+
# @example
|
23
|
+
# path=Sketchup.find_support_file "Bed.skp",
|
24
|
+
# "Components/Components Sampler/"
|
25
|
+
# model = Sketchup.active_model
|
26
|
+
# definitions = model.definitions
|
27
|
+
# componentdefinition = definitions.load path
|
28
|
+
# component = definitions[0]
|
29
|
+
#
|
30
|
+
# @overload [](index)
|
31
|
+
#
|
32
|
+
# @param [Integer] index The index for a specific component definition.
|
33
|
+
# @return [Sketchup::ComponentDefinition, nil]
|
34
|
+
#
|
35
|
+
# @overload [](name)
|
36
|
+
#
|
37
|
+
# @param [String] name The unique GUID for the component definition.
|
38
|
+
# @return [Sketchup::ComponentDefinition, nil]
|
39
|
+
#
|
40
|
+
# @overload [](guid)
|
41
|
+
#
|
42
|
+
# @param [String] guid The name of an existing component definition.
|
43
|
+
# @return [Sketchup::ComponentDefinition, nil]
|
44
|
+
#
|
45
|
+
# @version SketchUp 6.0
|
46
|
+
def [](arg)
|
47
|
+
end
|
48
|
+
|
49
|
+
# The add method is used to add a new component definition to the definition
|
50
|
+
# list with the given name.
|
51
|
+
#
|
52
|
+
# @example
|
53
|
+
# model = Sketchup.active_model
|
54
|
+
# definitions = model.definitions
|
55
|
+
# componentdefinition = definitions.add "BedTraditional"
|
56
|
+
# component = definitions[0]
|
57
|
+
#
|
58
|
+
# @param [String] def_name
|
59
|
+
# The new component definition to add to the definition
|
60
|
+
# list.
|
61
|
+
#
|
62
|
+
# @return [Sketchup::ComponentDefinition] the ComponentDefinition object
|
63
|
+
# that was added (if successful)
|
64
|
+
#
|
65
|
+
# @version SketchUp 6.0
|
66
|
+
def add(def_name)
|
67
|
+
end
|
68
|
+
|
69
|
+
# The add_observer method is used to add an observer to the current object.
|
70
|
+
#
|
71
|
+
# @example
|
72
|
+
# definitions = Sketchup.active_model.definitions
|
73
|
+
# status = definitions.add_observer observer
|
74
|
+
#
|
75
|
+
# @param [Object] observer
|
76
|
+
# An observer.
|
77
|
+
#
|
78
|
+
# @return [Boolean] true if successful, false if unsuccessful.
|
79
|
+
#
|
80
|
+
# @version SketchUp 6.0
|
81
|
+
def add_observer(observer)
|
82
|
+
end
|
83
|
+
|
84
|
+
# The [] method is used to retrieve a component definition from the list. You
|
85
|
+
# can give an integer index in the range 0 to length, a string which
|
86
|
+
# represents the GUID (a unique internal identifier), or a string that is
|
87
|
+
# the name of the definition.
|
88
|
+
#
|
89
|
+
# @example
|
90
|
+
# path=Sketchup.find_support_file "Bed.skp",
|
91
|
+
# "Components/Components Sampler/"
|
92
|
+
# model = Sketchup.active_model
|
93
|
+
# definitions = model.definitions
|
94
|
+
# componentdefinition = definitions.load path
|
95
|
+
# component = definitions[0]
|
96
|
+
#
|
97
|
+
# @overload [](index)
|
98
|
+
#
|
99
|
+
# @param [Integer] index The index for a specific component definition.
|
100
|
+
# @return [Sketchup::ComponentDefinition, nil]
|
101
|
+
#
|
102
|
+
# @overload [](name)
|
103
|
+
#
|
104
|
+
# @param [String] name The unique GUID for the component definition.
|
105
|
+
# @return [Sketchup::ComponentDefinition, nil]
|
106
|
+
#
|
107
|
+
# @overload [](guid)
|
108
|
+
#
|
109
|
+
# @param [String] guid The name of an existing component definition.
|
110
|
+
# @return [Sketchup::ComponentDefinition, nil]
|
111
|
+
#
|
112
|
+
# @version SketchUp 6.0
|
113
|
+
def at(arg)
|
114
|
+
end
|
115
|
+
|
116
|
+
#
|
117
|
+
# @example
|
118
|
+
# model = Sketchup.active_model
|
119
|
+
# definitions = model.definitions
|
120
|
+
# number = definitions.count
|
121
|
+
#
|
122
|
+
# @note Since SketchUp 2014 the count method is inherited from Ruby's
|
123
|
+
# +Enumerable+ mix-in module. Prior to that the {#count} method is an alias
|
124
|
+
# for {#length}.
|
125
|
+
#
|
126
|
+
# @return [Integer]
|
127
|
+
#
|
128
|
+
# @see #length
|
129
|
+
#
|
130
|
+
# @version SketchUp 6.0
|
131
|
+
def count
|
132
|
+
end
|
133
|
+
|
134
|
+
# The {#each} method is used to iterate through all of the component
|
135
|
+
# definitions in the definition list.
|
136
|
+
#
|
137
|
+
# @example
|
138
|
+
# model = Sketchup.active_model
|
139
|
+
# definitions = model.definitions
|
140
|
+
# definitions.add("BedTraditional")
|
141
|
+
# number = definitions.each { |definition| puts definition.name }
|
142
|
+
#
|
143
|
+
# @note Don't remove content from this collection while iterating over it with
|
144
|
+
# {#each}. This would change the size of the collection and cause elements to
|
145
|
+
# be skipped as the indices change. Instead copy the current collection to an
|
146
|
+
# array using +to_a+ and then use +each+ on the array, when removing content.
|
147
|
+
#
|
148
|
+
# @return [nil]
|
149
|
+
#
|
150
|
+
# @version SketchUp 6.0
|
151
|
+
#
|
152
|
+
# @yieldparam [Sketchup::ComponentDefinition] definition
|
153
|
+
def each
|
154
|
+
end
|
155
|
+
|
156
|
+
# The {#import} method is used to import a (non-SketchUp) 3d model file as a definition.
|
157
|
+
#
|
158
|
+
# Importers using the C API +SketchUpModelImporterInterface+ interface are supported (those in the
|
159
|
+
# +Importers/+ directory).
|
160
|
+
#
|
161
|
+
# See the {file:pages/importer_options.md Importer Options} file for information
|
162
|
+
# on creating a valid hash for the various importers.
|
163
|
+
#
|
164
|
+
# For SketchUp models, instead use {#load}.
|
165
|
+
#
|
166
|
+
# @example
|
167
|
+
# path = "C:/circle.dwg"
|
168
|
+
# definition = Sketchup.active_model.definitions.import(path)
|
169
|
+
#
|
170
|
+
# @param [String] path
|
171
|
+
#
|
172
|
+
# @param [Hash] options
|
173
|
+
#
|
174
|
+
# @raise [IOError] if the file is missing.
|
175
|
+
#
|
176
|
+
# @raise [ArgumentError] if no suitable importer could be found.
|
177
|
+
#
|
178
|
+
# @return [Sketchup::ComponentDefinition]
|
179
|
+
#
|
180
|
+
# @version SketchUp 2021.1
|
181
|
+
def import(path, options = {})
|
182
|
+
end
|
183
|
+
|
184
|
+
# The {#length} method is used to retrieve number of component definitions in
|
185
|
+
# the list.
|
186
|
+
#
|
187
|
+
# @example
|
188
|
+
# model = Sketchup.active_model
|
189
|
+
# definitions = model.definitions
|
190
|
+
# number = definitions.length
|
191
|
+
#
|
192
|
+
# @return [Integer]
|
193
|
+
#
|
194
|
+
# @see #size
|
195
|
+
#
|
196
|
+
# @version SketchUp 6.0
|
197
|
+
def length
|
198
|
+
end
|
199
|
+
|
200
|
+
# The {#load} method is used to load a component from a file.
|
201
|
+
#
|
202
|
+
# @bug In SketchUp versions prior to SketchUp 2019 the application would crash
|
203
|
+
# if you tried to open a newer model instead of raising the expected
|
204
|
+
# +RuntimeError+.
|
205
|
+
#
|
206
|
+
# @bug Prior to SketchUp 2023.0 this method silently failed to load a component if the model
|
207
|
+
# already contained a different component associated with the same path.
|
208
|
+
# Instead the existing component was returned.
|
209
|
+
# Making arbitrary changes to the existing component would allow the new one to be loaded.
|
210
|
+
#
|
211
|
+
# @example
|
212
|
+
# path = Sketchup.find_support_file("Bed.skp",
|
213
|
+
# "Components/Components Sampler/")
|
214
|
+
# model = Sketchup.active_model
|
215
|
+
# definitions = model.definitions
|
216
|
+
# definition = definitions.load(path)
|
217
|
+
#
|
218
|
+
# @example Workaround for loading from the same path twice
|
219
|
+
# path = "some/location/on/your/computer.skp"
|
220
|
+
# definition1 = Sketchup.active_model.definitions.load(path)
|
221
|
+
#
|
222
|
+
# # Now open the external file and make some changes to it.
|
223
|
+
#
|
224
|
+
# # HACK: Prior to version 2023.0 SketchUp wouldn't load components from the same path twice.
|
225
|
+
# # Instead it silently returned the existing, outdated component.
|
226
|
+
# # Making an arbitrary change to the existing component allows a new one to be loaded.
|
227
|
+
# definition1.entities.add_cpoint(ORIGIN) if Sketchup.version.to_i < 23
|
228
|
+
#
|
229
|
+
# definition2 = Sketchup.active_model.definitions.load(path)
|
230
|
+
#
|
231
|
+
# @overload load(path)
|
232
|
+
#
|
233
|
+
# @param [String] path
|
234
|
+
# The path where the component definition file is located.
|
235
|
+
#
|
236
|
+
# @overload load(path, allow_newer: true)
|
237
|
+
#
|
238
|
+
# Starting with SketchUp 2021.0 SketchUp attempts to load newer SketchUp
|
239
|
+
# models. If a newer model is loaded some information might have been skipped
|
240
|
+
# and extensions should be careful to not save over the file they loaded from
|
241
|
+
# as information might be lost.
|
242
|
+
#
|
243
|
+
# @version SketchUp 2021.0
|
244
|
+
# @param [String] path
|
245
|
+
# The path where the component definition file is located.
|
246
|
+
# @param [Boolean] allow_newer
|
247
|
+
# Indicate that it is ok to load a model with of a newer version.
|
248
|
+
#
|
249
|
+
# @raise IOError If the file is not a valid SketchUp model.
|
250
|
+
#
|
251
|
+
# @raise RuntimeError If the file is the same as the model being loaded into.
|
252
|
+
#
|
253
|
+
# @raise IOError If the file is an empty component.
|
254
|
+
#
|
255
|
+
# @raise RuntimeError If the file contains only screen text.
|
256
|
+
#
|
257
|
+
# @raise RuntimeError If the file is of a newer file version that the executing
|
258
|
+
# SketchUp version cannot open.
|
259
|
+
#
|
260
|
+
# @return [Sketchup::ComponentDefinition] the loaded ComponentDefinition
|
261
|
+
#
|
262
|
+
# @version SketchUp 6.0
|
263
|
+
def load(*args)
|
264
|
+
end
|
265
|
+
|
266
|
+
# The {#load_from_url} method loads a component from a location specified by
|
267
|
+
# string url.
|
268
|
+
#
|
269
|
+
# This method throws an exception if an url string is not
|
270
|
+
# given, or an error occurs during retrieval from URL and a
|
271
|
+
# +load_handler+ was not given. Optional second parameter +load_handler+ can be
|
272
|
+
# used to pass in a Ruby object that responds to the following methods:
|
273
|
+
#
|
274
|
+
# - +cancelled?+
|
275
|
+
# - +onPercentChange(percent)+
|
276
|
+
# - +onSuccess()+
|
277
|
+
# - +onFailure(message_string)+
|
278
|
+
#
|
279
|
+
# @bug Calling this method from an {UI::HtmlDialog}'s action callback on macOS will cause the
|
280
|
+
# SketchUp application to become unresponsive or crash. To work around this, defer the call
|
281
|
+
# from the action callback with a non-repeating zero-delay timer;
|
282
|
+
# +UI.start_timer(0, false) { method_calling_load_from_url }+
|
283
|
+
#
|
284
|
+
# @example Download a component using a LoadHandler
|
285
|
+
# class LoadHandler
|
286
|
+
# attr_accessor :error
|
287
|
+
#
|
288
|
+
# # @param [Float] percent
|
289
|
+
# def onPercentChange(percent)
|
290
|
+
# Sketchup::set_status_text("loading: #{percent.round}%")
|
291
|
+
# end
|
292
|
+
#
|
293
|
+
# def cancelled?
|
294
|
+
# # You could, for example, show a messagebox after X seconds asking if the
|
295
|
+
# # user wants to cancel the download. If this method returns true, then
|
296
|
+
# # the download cancels.
|
297
|
+
# return false
|
298
|
+
# end
|
299
|
+
#
|
300
|
+
# def onSuccess
|
301
|
+
# Sketchup::set_status_text('')
|
302
|
+
# end
|
303
|
+
#
|
304
|
+
# # @param [String] error_message
|
305
|
+
# def onFailure(error_message)
|
306
|
+
# self.error = error_message
|
307
|
+
# Sketchup::set_status_text('')
|
308
|
+
# end
|
309
|
+
# end
|
310
|
+
#
|
311
|
+
# # Replace this with a real URL...
|
312
|
+
# url = 'https://www.sketchup.com/model.skp'
|
313
|
+
# model = Sketchup.active_model
|
314
|
+
# load_handler = LoadHandler.new
|
315
|
+
# definition = model.definitions.load_from_url(url, load_handler)
|
316
|
+
#
|
317
|
+
# if definition.nil?
|
318
|
+
# puts "Error: #{load_handler.error}"
|
319
|
+
# end
|
320
|
+
#
|
321
|
+
# @example Workaround for macOS bug related to HtmlDialog action callbacks
|
322
|
+
# module Example
|
323
|
+
#
|
324
|
+
# def self.open_dialog
|
325
|
+
# @dialog = UI::HtmlDialog.new
|
326
|
+
# @dialog.add_action_callback("say") { |action_context, url|
|
327
|
+
# self.load_component_deferred(url)
|
328
|
+
# }
|
329
|
+
# @dialog.set_file("path/to/file.html")
|
330
|
+
# @dialog.show
|
331
|
+
# end
|
332
|
+
#
|
333
|
+
# def load_component_deferred
|
334
|
+
# # The timer delay is enough to avoid .load_from_url from deadlocking.
|
335
|
+
# UI.start_timer(0, false) do
|
336
|
+
# self.load_component(url)
|
337
|
+
# end
|
338
|
+
# end
|
339
|
+
#
|
340
|
+
# def self.load_component(url)
|
341
|
+
# model = Sketchup.active_model
|
342
|
+
# definition = model.definitions.load_from_url(url)
|
343
|
+
# # ...
|
344
|
+
# end
|
345
|
+
#
|
346
|
+
# end
|
347
|
+
#
|
348
|
+
# @overload load_from_url(url)
|
349
|
+
#
|
350
|
+
# @param [String] url
|
351
|
+
# URL to load a .skp file from.
|
352
|
+
#
|
353
|
+
# @overload load_from_url(url, load_handler)
|
354
|
+
#
|
355
|
+
# @param [String] url
|
356
|
+
# URL to load a .skp file from.
|
357
|
+
# @param [Object] load_handler
|
358
|
+
# Ruby object that has methods defined
|
359
|
+
# as described in the +load_from_url+ details above.
|
360
|
+
#
|
361
|
+
# @return [Sketchup::ComponentDefinition]
|
362
|
+
#
|
363
|
+
# @version SketchUp 7.0
|
364
|
+
def load_from_url(*args)
|
365
|
+
end
|
366
|
+
|
367
|
+
# The purge_unused method is used to remove the unused component definitions.
|
368
|
+
#
|
369
|
+
# @example
|
370
|
+
# definitions = Sketchup.active_model.definitions
|
371
|
+
# definitions.purge_unused
|
372
|
+
#
|
373
|
+
# @return [Sketchup::DefinitionList]
|
374
|
+
#
|
375
|
+
# @version SketchUp 6.0
|
376
|
+
def purge_unused
|
377
|
+
end
|
378
|
+
|
379
|
+
# The {#remove} method is used to remove a component definition from the
|
380
|
+
# definition list with the given component definition. This will remove all
|
381
|
+
# instances of the definition.
|
382
|
+
#
|
383
|
+
# @bug Prior to SketchUp 2023.0 this could crash SketchUp if you erased an
|
384
|
+
# definition used by the active edit path.
|
385
|
+
#
|
386
|
+
# @example
|
387
|
+
# model = Sketchup.active_model
|
388
|
+
# definitions = model.definitions
|
389
|
+
# definition = definitions[0]
|
390
|
+
# definitions.remove(definition)
|
391
|
+
#
|
392
|
+
# @param [Sketchup::ComponentDefinition] definition
|
393
|
+
#
|
394
|
+
# @raise [ArgumentError] if the given definition is used by {Sketchup::Model#active_path}.
|
395
|
+
#
|
396
|
+
# @return [Boolean]
|
397
|
+
#
|
398
|
+
# @version SketchUp 2018
|
399
|
+
def remove(definition)
|
400
|
+
end
|
401
|
+
|
402
|
+
# The remove_observer method is used to remove an observer from the current
|
403
|
+
# object.
|
404
|
+
#
|
405
|
+
# @example
|
406
|
+
# definitions = Sketchup.active_model.definitions
|
407
|
+
# status = definitions.remove_observer observer
|
408
|
+
#
|
409
|
+
# @param [Object] observer
|
410
|
+
# An observer.
|
411
|
+
#
|
412
|
+
# @return [Boolean] true if successful, false if unsuccessful.
|
413
|
+
#
|
414
|
+
# @version SketchUp 6.0
|
415
|
+
def remove_observer(observer)
|
416
|
+
end
|
417
|
+
|
418
|
+
# The {#size} method is an alias for {#length}.
|
419
|
+
#
|
420
|
+
# @example
|
421
|
+
# model = Sketchup.active_model
|
422
|
+
# definitions = model.definitions
|
423
|
+
# number = definitions.size
|
424
|
+
#
|
425
|
+
# @return [Integer]
|
426
|
+
#
|
427
|
+
# @see #length
|
428
|
+
#
|
429
|
+
# @version SketchUp 2014
|
430
|
+
def size
|
431
|
+
end
|
432
|
+
|
433
|
+
# The unique_name is used to generate a unique name for a definition based on
|
434
|
+
# a base_name string. For example, a base_name of "Joe" might return "Joe #2"
|
435
|
+
#
|
436
|
+
# @example
|
437
|
+
# model = Sketchup.active_model
|
438
|
+
# definitions = model.definitions
|
439
|
+
# new_name = definitions.unique_name "My Base Name"
|
440
|
+
#
|
441
|
+
# @param [String] base_name
|
442
|
+
#
|
443
|
+
# @return [String] the unique name.
|
444
|
+
#
|
445
|
+
# @version SketchUp 6.0
|
446
|
+
def unique_name(base_name)
|
447
|
+
end
|
448
|
+
|
449
|
+
end
|