sketchup-api-stubs 0.7.9 → 0.7.11

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.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sketchup-api-stubs/sketchup.rb +157 -151
  3. data/lib/sketchup-api-stubs/stubs/Array.rb +741 -741
  4. data/lib/sketchup-api-stubs/stubs/Geom/BoundingBox.rb +322 -322
  5. data/lib/sketchup-api-stubs/stubs/Geom/Bounds2d.rb +182 -172
  6. data/lib/sketchup-api-stubs/stubs/Geom/LatLong.rb +111 -126
  7. data/lib/sketchup-api-stubs/stubs/Geom/OrientedBounds2d.rb +102 -102
  8. data/lib/sketchup-api-stubs/stubs/Geom/Point2d.rb +423 -400
  9. data/lib/sketchup-api-stubs/stubs/Geom/Point3d.rb +693 -661
  10. data/lib/sketchup-api-stubs/stubs/Geom/PolygonMesh.rb +535 -509
  11. data/lib/sketchup-api-stubs/stubs/Geom/Transformation.rb +500 -476
  12. data/lib/sketchup-api-stubs/stubs/Geom/Transformation2d.rb +267 -263
  13. data/lib/sketchup-api-stubs/stubs/Geom/UTM.rb +133 -141
  14. data/lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb +547 -522
  15. data/lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb +678 -693
  16. data/lib/sketchup-api-stubs/stubs/Geom.rb +351 -351
  17. data/lib/sketchup-api-stubs/stubs/LanguageHandler.rb +93 -93
  18. data/lib/sketchup-api-stubs/stubs/Layout/AngularDimension.rb +595 -595
  19. data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinition.rb +751 -747
  20. data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinitions.rb +183 -183
  21. data/lib/sketchup-api-stubs/stubs/Layout/ConnectionPoint.rb +70 -70
  22. data/lib/sketchup-api-stubs/stubs/Layout/Dictionary.rb +234 -0
  23. data/lib/sketchup-api-stubs/stubs/Layout/Document.rb +683 -517
  24. data/lib/sketchup-api-stubs/stubs/Layout/Ellipse.rb +29 -29
  25. data/lib/sketchup-api-stubs/stubs/Layout/Entities.rb +148 -148
  26. data/lib/sketchup-api-stubs/stubs/Layout/Entity.rb +464 -353
  27. data/lib/sketchup-api-stubs/stubs/Layout/FormattedText.rb +354 -354
  28. data/lib/sketchup-api-stubs/stubs/Layout/Grid.rb +311 -311
  29. data/lib/sketchup-api-stubs/stubs/Layout/Group.rb +261 -261
  30. data/lib/sketchup-api-stubs/stubs/Layout/Image.rb +91 -91
  31. data/lib/sketchup-api-stubs/stubs/Layout/Label.rb +370 -370
  32. data/lib/sketchup-api-stubs/stubs/Layout/Layer.rb +218 -218
  33. data/lib/sketchup-api-stubs/stubs/Layout/LayerInstance.rb +128 -128
  34. data/lib/sketchup-api-stubs/stubs/Layout/Layers.rb +225 -225
  35. data/lib/sketchup-api-stubs/stubs/Layout/LinearDimension.rb +614 -567
  36. data/lib/sketchup-api-stubs/stubs/Layout/LockedEntityError.rb +10 -10
  37. data/lib/sketchup-api-stubs/stubs/Layout/LockedLayerError.rb +11 -11
  38. data/lib/sketchup-api-stubs/stubs/Layout/Page.rb +282 -183
  39. data/lib/sketchup-api-stubs/stubs/Layout/PageInfo.rb +458 -387
  40. data/lib/sketchup-api-stubs/stubs/Layout/Pages.rb +209 -209
  41. data/lib/sketchup-api-stubs/stubs/Layout/Path.rb +346 -344
  42. data/lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb +174 -174
  43. data/lib/sketchup-api-stubs/stubs/Layout/ReferenceEntity.rb +82 -82
  44. data/lib/sketchup-api-stubs/stubs/Layout/SketchUpModel.rb +714 -692
  45. data/lib/sketchup-api-stubs/stubs/Layout/Style.rb +1565 -1519
  46. data/lib/sketchup-api-stubs/stubs/Layout/Table.rb +290 -290
  47. data/lib/sketchup-api-stubs/stubs/Layout/TableCell.rb +149 -149
  48. data/lib/sketchup-api-stubs/stubs/Layout/TableColumn.rb +139 -139
  49. data/lib/sketchup-api-stubs/stubs/Layout/TableRow.rb +135 -135
  50. data/lib/sketchup-api-stubs/stubs/Layout.rb +25 -25
  51. data/lib/sketchup-api-stubs/stubs/Length.rb +286 -278
  52. data/lib/sketchup-api-stubs/stubs/Numeric.rb +249 -249
  53. data/lib/sketchup-api-stubs/stubs/Sketchup/Animation.rb +196 -144
  54. data/lib/sketchup-api-stubs/stubs/Sketchup/AppObserver.rb +169 -169
  55. data/lib/sketchup-api-stubs/stubs/Sketchup/ArcCurve.rb +226 -209
  56. data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionaries.rb +145 -150
  57. data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionary.rb +294 -281
  58. data/lib/sketchup-api-stubs/stubs/Sketchup/Axes.rb +149 -149
  59. data/lib/sketchup-api-stubs/stubs/Sketchup/Behavior.rb +296 -302
  60. data/lib/sketchup-api-stubs/stubs/Sketchup/Camera.rb +473 -478
  61. data/lib/sketchup-api-stubs/stubs/Sketchup/ClassificationSchema.rb +63 -63
  62. data/lib/sketchup-api-stubs/stubs/Sketchup/Classifications.rb +121 -121
  63. data/lib/sketchup-api-stubs/stubs/Sketchup/Color.rb +294 -294
  64. data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentDefinition.rb +673 -659
  65. data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentInstance.rb +600 -593
  66. data/lib/sketchup-api-stubs/stubs/Sketchup/Console.rb +76 -76
  67. data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionLine.rb +252 -257
  68. data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionPoint.rb +32 -32
  69. data/lib/sketchup-api-stubs/stubs/Sketchup/Curve.rb +201 -201
  70. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionList.rb +443 -449
  71. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb +74 -74
  72. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionsObserver.rb +104 -104
  73. data/lib/sketchup-api-stubs/stubs/Sketchup/Dimension.rb +167 -165
  74. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionLinear.rb +306 -306
  75. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionObserver.rb +42 -42
  76. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionRadial.rb +87 -87
  77. data/lib/sketchup-api-stubs/stubs/Sketchup/Drawingelement.rb +403 -406
  78. data/lib/sketchup-api-stubs/stubs/Sketchup/Edge.rb +397 -397
  79. data/lib/sketchup-api-stubs/stubs/Sketchup/EdgeUse.rb +211 -211
  80. data/lib/sketchup-api-stubs/stubs/Sketchup/Entities.rb +1282 -1239
  81. data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesBuilder.rb +261 -261
  82. data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesObserver.rb +127 -127
  83. data/lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb +519 -545
  84. data/lib/sketchup-api-stubs/stubs/Sketchup/EntityObserver.rb +60 -60
  85. data/lib/sketchup-api-stubs/stubs/Sketchup/Environment.rb +406 -0
  86. data/lib/sketchup-api-stubs/stubs/Sketchup/Environments.rb +185 -0
  87. data/lib/sketchup-api-stubs/stubs/Sketchup/EnvironmentsObserver.rb +113 -0
  88. data/lib/sketchup-api-stubs/stubs/Sketchup/ExtensionsManager.rb +122 -125
  89. data/lib/sketchup-api-stubs/stubs/Sketchup/Face.rb +1006 -937
  90. data/lib/sketchup-api-stubs/stubs/Sketchup/FrameChangeObserver.rb +102 -102
  91. data/lib/sketchup-api-stubs/stubs/Sketchup/Group.rb +740 -750
  92. data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Request.rb +289 -282
  93. data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Response.rb +64 -62
  94. data/lib/sketchup-api-stubs/stubs/Sketchup/Http.rb +27 -27
  95. data/lib/sketchup-api-stubs/stubs/Sketchup/Image.rb +405 -468
  96. data/lib/sketchup-api-stubs/stubs/Sketchup/ImageRep.rb +266 -266
  97. data/lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb +189 -189
  98. data/lib/sketchup-api-stubs/stubs/Sketchup/InputPoint.rb +432 -406
  99. data/lib/sketchup-api-stubs/stubs/Sketchup/InstanceObserver.rb +84 -84
  100. data/lib/sketchup-api-stubs/stubs/Sketchup/InstancePath.rb +307 -306
  101. data/lib/sketchup-api-stubs/stubs/Sketchup/Layer.rb +332 -326
  102. data/lib/sketchup-api-stubs/stubs/Sketchup/LayerFolder.rb +380 -422
  103. data/lib/sketchup-api-stubs/stubs/Sketchup/Layers.rb +409 -427
  104. data/lib/sketchup-api-stubs/stubs/Sketchup/LayersObserver.rb +241 -249
  105. data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing/ExtensionLicense.rb +86 -86
  106. data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing.rb +55 -48
  107. data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyle.rb +24 -24
  108. data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyles.rb +114 -114
  109. data/lib/sketchup-api-stubs/stubs/Sketchup/LoadHandler.rb +70 -0
  110. data/lib/sketchup-api-stubs/stubs/Sketchup/Loop.rb +137 -137
  111. data/lib/sketchup-api-stubs/stubs/Sketchup/Material.rb +1115 -414
  112. data/lib/sketchup-api-stubs/stubs/Sketchup/Materials.rb +330 -317
  113. data/lib/sketchup-api-stubs/stubs/Sketchup/MaterialsObserver.rb +142 -142
  114. data/lib/sketchup-api-stubs/stubs/Sketchup/Menu.rb +93 -93
  115. data/lib/sketchup-api-stubs/stubs/Sketchup/Model.rb +1714 -1652
  116. data/lib/sketchup-api-stubs/stubs/Sketchup/ModelObserver.rb +372 -357
  117. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsManager.rb +133 -130
  118. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb +271 -271
  119. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProviderObserver.rb +58 -58
  120. data/lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb +463 -490
  121. data/lib/sketchup-api-stubs/stubs/Sketchup/OverlaysManager.rb +104 -116
  122. data/lib/sketchup-api-stubs/stubs/Sketchup/Page.rb +939 -797
  123. data/lib/sketchup-api-stubs/stubs/Sketchup/Pages.rb +388 -361
  124. data/lib/sketchup-api-stubs/stubs/Sketchup/PagesObserver.rb +77 -77
  125. data/lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb +501 -478
  126. data/lib/sketchup-api-stubs/stubs/Sketchup/RegionalSettings.rb +43 -43
  127. data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptions.rb +385 -361
  128. data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptionsObserver.rb +45 -45
  129. data/lib/sketchup-api-stubs/stubs/Sketchup/SectionPlane.rb +150 -150
  130. data/lib/sketchup-api-stubs/stubs/Sketchup/Selection.rb +451 -458
  131. data/lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb +115 -115
  132. data/lib/sketchup-api-stubs/stubs/Sketchup/Set.rb +211 -212
  133. data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfo.rb +259 -255
  134. data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfoObserver.rb +59 -59
  135. data/lib/sketchup-api-stubs/stubs/Sketchup/Skp.rb +40 -40
  136. data/lib/sketchup-api-stubs/stubs/Sketchup/Snap.rb +125 -0
  137. data/lib/sketchup-api-stubs/stubs/Sketchup/Style.rb +88 -69
  138. data/lib/sketchup-api-stubs/stubs/Sketchup/Styles.rb +263 -217
  139. data/lib/sketchup-api-stubs/stubs/Sketchup/Text.rb +283 -262
  140. data/lib/sketchup-api-stubs/stubs/Sketchup/Texture.rb +199 -217
  141. data/lib/sketchup-api-stubs/stubs/Sketchup/TextureWriter.rb +237 -237
  142. data/lib/sketchup-api-stubs/stubs/Sketchup/Tool.rb +924 -834
  143. data/lib/sketchup-api-stubs/stubs/Sketchup/Tools.rb +132 -132
  144. data/lib/sketchup-api-stubs/stubs/Sketchup/ToolsObserver.rb +156 -156
  145. data/lib/sketchup-api-stubs/stubs/Sketchup/UVHelper.rb +75 -75
  146. data/lib/sketchup-api-stubs/stubs/Sketchup/Vertex.rb +143 -142
  147. data/lib/sketchup-api-stubs/stubs/Sketchup/View.rb +1566 -1311
  148. data/lib/sketchup-api-stubs/stubs/Sketchup/ViewObserver.rb +71 -45
  149. data/lib/sketchup-api-stubs/stubs/Sketchup.rb +1429 -1377
  150. data/lib/sketchup-api-stubs/stubs/SketchupExtension.rb +353 -353
  151. data/lib/sketchup-api-stubs/stubs/String.rb +24 -24
  152. data/lib/sketchup-api-stubs/stubs/UI/Command.rb +399 -389
  153. data/lib/sketchup-api-stubs/stubs/UI/HtmlDialog.rb +580 -494
  154. data/lib/sketchup-api-stubs/stubs/UI/Notification.rb +280 -269
  155. data/lib/sketchup-api-stubs/stubs/UI/Toolbar.rb +258 -241
  156. data/lib/sketchup-api-stubs/stubs/UI/WebDialog.rb +636 -635
  157. data/lib/sketchup-api-stubs/stubs/UI.rb +791 -683
  158. data/lib/sketchup-api-stubs/stubs/_top_level.rb +303 -303
  159. data/lib/sketchup-api-stubs.rb +1 -1
  160. metadata +10 -24
@@ -1,449 +1,443 @@
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
1
+ # Copyright:: Copyright 2026 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 [Sketchup::ComponentDefinition]
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: false)
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
+ # {Sketchup::LoadHandler load_handler} was not given.
272
+ #
273
+ # @bug Calling this method from an {UI::HtmlDialog}'s action callback on macOS will cause the
274
+ # SketchUp application to become unresponsive or crash. To work around this, defer the call
275
+ # from the action callback with a non-repeating zero-delay timer;
276
+ # +UI.start_timer(0, false) { method_calling_load_from_url }+
277
+ #
278
+ # @example Download a component using a LoadHandler
279
+ # class LoadHandler
280
+ # attr_accessor :error
281
+ #
282
+ # # @param [Float] percent
283
+ # def onPercentChange(percent)
284
+ # Sketchup::set_status_text("loading: #{percent.round}%")
285
+ # end
286
+ #
287
+ # def cancelled?
288
+ # # You could, for example, show a messagebox after X seconds asking if the
289
+ # # user wants to cancel the download. If this method returns true, then
290
+ # # the download cancels.
291
+ # return false
292
+ # end
293
+ #
294
+ # def onSuccess
295
+ # Sketchup::set_status_text('')
296
+ # end
297
+ #
298
+ # # @param [String] error_message
299
+ # def onFailure(error_message)
300
+ # self.error = error_message
301
+ # Sketchup::set_status_text('')
302
+ # end
303
+ # end
304
+ #
305
+ # # Replace this with a real URL...
306
+ # url = 'https://www.sketchup.com/model.skp'
307
+ # model = Sketchup.active_model
308
+ # load_handler = LoadHandler.new
309
+ # definition = model.definitions.load_from_url(url, load_handler)
310
+ #
311
+ # if definition.nil?
312
+ # puts "Error: #{load_handler.error}"
313
+ # end
314
+ #
315
+ # @example Workaround for macOS bug related to HtmlDialog action callbacks
316
+ # module Example
317
+ #
318
+ # def self.open_dialog
319
+ # @dialog = UI::HtmlDialog.new
320
+ # @dialog.add_action_callback("say") { |action_context, url|
321
+ # self.load_component_deferred(url)
322
+ # }
323
+ # @dialog.set_file("path/to/file.html")
324
+ # @dialog.show
325
+ # end
326
+ #
327
+ # def load_component_deferred
328
+ # # The timer delay is enough to avoid .load_from_url from deadlocking.
329
+ # UI.start_timer(0, false) do
330
+ # self.load_component(url)
331
+ # end
332
+ # end
333
+ #
334
+ # def self.load_component(url)
335
+ # model = Sketchup.active_model
336
+ # definition = model.definitions.load_from_url(url)
337
+ # # ...
338
+ # end
339
+ #
340
+ # end
341
+ #
342
+ # @overload load_from_url(url)
343
+ #
344
+ # @param [String] url
345
+ # URL to load a .skp file from.
346
+ #
347
+ # @overload load_from_url(url, load_handler)
348
+ #
349
+ # @param [String] url
350
+ # URL to load a .skp file from.
351
+ # @param [Object] load_handler
352
+ # Ruby object that has methods defined
353
+ # as described in the +load_from_url+ details above.
354
+ #
355
+ # @return [Sketchup::ComponentDefinition]
356
+ #
357
+ # @version SketchUp 7.0
358
+ def load_from_url(*args)
359
+ end
360
+
361
+ # The purge_unused method is used to remove the unused component definitions.
362
+ #
363
+ # @example
364
+ # definitions = Sketchup.active_model.definitions
365
+ # definitions.purge_unused
366
+ #
367
+ # @return [Sketchup::DefinitionList]
368
+ #
369
+ # @version SketchUp 6.0
370
+ def purge_unused
371
+ end
372
+
373
+ # The {#remove} method is used to remove a component definition from the
374
+ # definition list with the given component definition. This will remove all
375
+ # instances of the definition.
376
+ #
377
+ # @bug Prior to SketchUp 2023.0 this could crash SketchUp if you erased an
378
+ # definition used by the active edit path.
379
+ #
380
+ # @example
381
+ # model = Sketchup.active_model
382
+ # definitions = model.definitions
383
+ # definition = definitions[0]
384
+ # definitions.remove(definition)
385
+ #
386
+ # @param [Sketchup::ComponentDefinition] definition
387
+ #
388
+ # @raise [ArgumentError] if the given definition is used by {Sketchup::Model#active_path}.
389
+ #
390
+ # @return [Boolean]
391
+ #
392
+ # @version SketchUp 2018
393
+ def remove(definition)
394
+ end
395
+
396
+ # The remove_observer method is used to remove an observer from the current
397
+ # object.
398
+ #
399
+ # @example
400
+ # definitions = Sketchup.active_model.definitions
401
+ # status = definitions.remove_observer observer
402
+ #
403
+ # @param [Object] observer
404
+ # An observer.
405
+ #
406
+ # @return [Boolean] true if successful, false if unsuccessful.
407
+ #
408
+ # @version SketchUp 6.0
409
+ def remove_observer(observer)
410
+ end
411
+
412
+ # The {#size} method is an alias for {#length}.
413
+ #
414
+ # @example
415
+ # model = Sketchup.active_model
416
+ # definitions = model.definitions
417
+ # number = definitions.size
418
+ #
419
+ # @return [Integer]
420
+ #
421
+ # @see #length
422
+ #
423
+ # @version SketchUp 2014
424
+ def size
425
+ end
426
+
427
+ # The unique_name is used to generate a unique name for a definition based on
428
+ # a base_name string. For example, a base_name of "Joe" might return "Joe #2"
429
+ #
430
+ # @example
431
+ # model = Sketchup.active_model
432
+ # definitions = model.definitions
433
+ # new_name = definitions.unique_name "My Base Name"
434
+ #
435
+ # @param [String] base_name
436
+ #
437
+ # @return [String] the unique name.
438
+ #
439
+ # @version SketchUp 6.0
440
+ def unique_name(base_name)
441
+ end
442
+
443
+ end