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