sketchup-api-stubs 0.7.0 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sketchup-api-stubs/sketchup.rb +2 -0
- data/lib/sketchup-api-stubs/stubs/Geom/BoundingBox.rb +14 -10
- data/lib/sketchup-api-stubs/stubs/Geom/Bounds2d.rb +4 -4
- data/lib/sketchup-api-stubs/stubs/Geom/LatLong.rb +4 -4
- data/lib/sketchup-api-stubs/stubs/Geom/Point2d.rb +4 -5
- data/lib/sketchup-api-stubs/stubs/Geom/Point3d.rb +17 -17
- data/lib/sketchup-api-stubs/stubs/Geom/PolygonMesh.rb +6 -0
- data/lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb +1 -2
- data/lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb +3 -3
- data/lib/sketchup-api-stubs/stubs/Layout/AngularDimension.rb +4 -0
- data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinitions.rb +6 -13
- data/lib/sketchup-api-stubs/stubs/Layout/Document.rb +60 -4
- data/lib/sketchup-api-stubs/stubs/Layout/Entities.rb +6 -13
- data/lib/sketchup-api-stubs/stubs/Layout/Grid.rb +188 -0
- data/lib/sketchup-api-stubs/stubs/Layout/Image.rb +8 -3
- data/lib/sketchup-api-stubs/stubs/Layout/Label.rb +1 -2
- data/lib/sketchup-api-stubs/stubs/Layout/Layers.rb +6 -13
- data/lib/sketchup-api-stubs/stubs/Layout/LinearDimension.rb +5 -1
- data/lib/sketchup-api-stubs/stubs/Layout/Pages.rb +6 -13
- data/lib/sketchup-api-stubs/stubs/Layout/SketchUpModel.rb +147 -4
- data/lib/sketchup-api-stubs/stubs/Sketchup/Animation.rb +4 -0
- data/lib/sketchup-api-stubs/stubs/Sketchup/AppObserver.rb +3 -3
- data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionaries.rb +2 -2
- data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionary.rb +5 -0
- data/lib/sketchup-api-stubs/stubs/Sketchup/Behavior.rb +31 -57
- data/lib/sketchup-api-stubs/stubs/Sketchup/Camera.rb +109 -208
- data/lib/sketchup-api-stubs/stubs/Sketchup/Color.rb +23 -10
- data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentDefinition.rb +22 -7
- data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentInstance.rb +23 -12
- data/lib/sketchup-api-stubs/stubs/Sketchup/Curve.rb +15 -8
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionList.rb +60 -27
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb +5 -3
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionsObserver.rb +5 -3
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionLinear.rb +2 -8
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionObserver.rb +4 -0
- data/lib/sketchup-api-stubs/stubs/Sketchup/Drawingelement.rb +9 -3
- data/lib/sketchup-api-stubs/stubs/Sketchup/Edge.rb +7 -13
- data/lib/sketchup-api-stubs/stubs/Sketchup/Entities.rb +54 -25
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesObserver.rb +5 -3
- data/lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb +19 -14
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntityObserver.rb +5 -4
- data/lib/sketchup-api-stubs/stubs/Sketchup/ExtensionsManager.rb +8 -7
- data/lib/sketchup-api-stubs/stubs/Sketchup/Face.rb +8 -7
- data/lib/sketchup-api-stubs/stubs/Sketchup/Group.rb +46 -44
- data/lib/sketchup-api-stubs/stubs/Sketchup/Image.rb +8 -0
- data/lib/sketchup-api-stubs/stubs/Sketchup/ImageRep.rb +46 -6
- data/lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb +10 -11
- data/lib/sketchup-api-stubs/stubs/Sketchup/InputPoint.rb +32 -20
- data/lib/sketchup-api-stubs/stubs/Sketchup/InstanceObserver.rb +5 -3
- data/lib/sketchup-api-stubs/stubs/Sketchup/InstancePath.rb +4 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/Layer.rb +112 -69
- data/lib/sketchup-api-stubs/stubs/Sketchup/LayerFolder.rb +422 -0
- data/lib/sketchup-api-stubs/stubs/Sketchup/Layers.rb +224 -28
- data/lib/sketchup-api-stubs/stubs/Sketchup/LayersObserver.rb +117 -4
- data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyles.rb +1 -12
- data/lib/sketchup-api-stubs/stubs/Sketchup/Material.rb +7 -9
- data/lib/sketchup-api-stubs/stubs/Sketchup/Materials.rb +14 -7
- data/lib/sketchup-api-stubs/stubs/Sketchup/MaterialsObserver.rb +5 -4
- data/lib/sketchup-api-stubs/stubs/Sketchup/Menu.rb +8 -10
- data/lib/sketchup-api-stubs/stubs/Sketchup/Model.rb +122 -72
- data/lib/sketchup-api-stubs/stubs/Sketchup/ModelObserver.rb +4 -3
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsManager.rb +1 -2
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb +6 -6
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProviderObserver.rb +3 -3
- data/lib/sketchup-api-stubs/stubs/Sketchup/Page.rb +142 -39
- data/lib/sketchup-api-stubs/stubs/Sketchup/Pages.rb +21 -11
- data/lib/sketchup-api-stubs/stubs/Sketchup/PagesObserver.rb +5 -4
- data/lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb +36 -14
- data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptionsObserver.rb +4 -3
- data/lib/sketchup-api-stubs/stubs/Sketchup/Selection.rb +9 -4
- data/lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb +19 -19
- data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfo.rb +4 -4
- data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfoObserver.rb +5 -3
- data/lib/sketchup-api-stubs/stubs/Sketchup/Skp.rb +40 -0
- data/lib/sketchup-api-stubs/stubs/Sketchup/Styles.rb +8 -2
- data/lib/sketchup-api-stubs/stubs/Sketchup/Texture.rb +13 -21
- data/lib/sketchup-api-stubs/stubs/Sketchup/Tool.rb +30 -24
- data/lib/sketchup-api-stubs/stubs/Sketchup/Tools.rb +1 -1
- data/lib/sketchup-api-stubs/stubs/Sketchup/ToolsObserver.rb +5 -3
- data/lib/sketchup-api-stubs/stubs/Sketchup/UVHelper.rb +31 -21
- data/lib/sketchup-api-stubs/stubs/Sketchup/View.rb +72 -66
- data/lib/sketchup-api-stubs/stubs/Sketchup/ViewObserver.rb +5 -3
- data/lib/sketchup-api-stubs/stubs/UI/Command.rb +12 -5
- data/lib/sketchup-api-stubs/stubs/UI/HtmlDialog.rb +34 -3
- data/lib/sketchup-api-stubs/stubs/UI/Notification.rb +36 -10
- data/lib/sketchup-api-stubs/stubs/UI/WebDialog.rb +2 -2
- data/lib/sketchup-api-stubs/stubs/_top_level.rb +2 -0
- data/lib/sketchup-api-stubs/stubs/geom.rb +3 -0
- data/lib/sketchup-api-stubs/stubs/sketchup.rb +54 -22
- data/lib/sketchup-api-stubs/stubs/ui.rb +9 -8
- metadata +4 -16
@@ -78,10 +78,10 @@ class Sketchup::Color
|
|
78
78
|
# color = Sketchup::Color.new "AliceBlue"
|
79
79
|
# alpha = color.alpha = 255
|
80
80
|
#
|
81
|
-
# @param [Integer] alpha
|
81
|
+
# @param [Integer, Float] alpha
|
82
82
|
# The new opacity value.
|
83
83
|
#
|
84
|
-
# @return [Integer]
|
84
|
+
# @return [Integer, Float]
|
85
85
|
#
|
86
86
|
# @version SketchUp 8.0 M1
|
87
87
|
def alpha=(alpha)
|
@@ -133,10 +133,10 @@ class Sketchup::Color
|
|
133
133
|
# color = Sketchup::Color.new "AliceBlue"
|
134
134
|
# blue = color.blue = 200
|
135
135
|
#
|
136
|
-
# @param [Integer] blue
|
136
|
+
# @param [Integer, Float] blue
|
137
137
|
# The blue value for the color.
|
138
138
|
#
|
139
|
-
# @return [Integer]
|
139
|
+
# @return [Integer, Float]
|
140
140
|
#
|
141
141
|
# @version SketchUp 6.0
|
142
142
|
def blue=(blue)
|
@@ -164,10 +164,10 @@ class Sketchup::Color
|
|
164
164
|
# color = Sketchup::Color.new "AliceBlue"
|
165
165
|
# green = color.green = 200
|
166
166
|
#
|
167
|
-
# @param [Integer] green
|
167
|
+
# @param [Integer, Float] green
|
168
168
|
# The green value for the color.
|
169
169
|
#
|
170
|
-
# @return [Integer]
|
170
|
+
# @return [Integer, Float]
|
171
171
|
#
|
172
172
|
# @version SketchUp 6.0
|
173
173
|
def green=(green)
|
@@ -188,8 +188,6 @@ class Sketchup::Color
|
|
188
188
|
# face.material = color_from_rgba
|
189
189
|
# face.material.alpha = 0.5
|
190
190
|
#
|
191
|
-
# @note When assigning colors via a hexadecimal, R and B will be flipped.
|
192
|
-
#
|
193
191
|
# @overload initialize(red, green, blue, alpha = 255)
|
194
192
|
#
|
195
193
|
# @param [Integer] red A red value between 0 and 255.
|
@@ -198,6 +196,14 @@ class Sketchup::Color
|
|
198
196
|
# @param [Integer] alpha A alpha value between 0 and 255.
|
199
197
|
# @return [Sketchup::Color]
|
200
198
|
#
|
199
|
+
# @overload initialize(red, green, blue, alpha = 1.0)
|
200
|
+
#
|
201
|
+
# @param [Float] red A red value between 0.0 and 1.0.
|
202
|
+
# @param [Float] green A green value between 0.0 and 1.0.
|
203
|
+
# @param [Float] blue A blue value between 0.0 and 1.0.
|
204
|
+
# @param [Float] alpha A alpha value between 0.0 and 1.0.
|
205
|
+
# @return [Sketchup::Color]
|
206
|
+
#
|
201
207
|
# @overload initialize(name)
|
202
208
|
#
|
203
209
|
# @param [String] name A string name of a color that currently exists in
|
@@ -205,6 +211,13 @@ class Sketchup::Color
|
|
205
211
|
# info.
|
206
212
|
# @return [Sketchup::Color]
|
207
213
|
#
|
214
|
+
# @overload initialize(hex)
|
215
|
+
#
|
216
|
+
# @param [Integer] hex A hexadecimal color code.
|
217
|
+
# @return [Sketchup::Color]
|
218
|
+
# @note When assigning colors via a hexadecimal, R and B will be flipped.
|
219
|
+
# @note When assigning colors via a hexadecimal, Alpha is not supported.
|
220
|
+
#
|
208
221
|
# @version SketchUp 6.0
|
209
222
|
def initialize(*args)
|
210
223
|
end
|
@@ -231,10 +244,10 @@ class Sketchup::Color
|
|
231
244
|
# color = Sketchup::Color.new "AliceBlue"
|
232
245
|
# red = color.red=200
|
233
246
|
#
|
234
|
-
# @param [Integer] red
|
247
|
+
# @param [Integer, Float] red
|
235
248
|
# The red value for the color.
|
236
249
|
#
|
237
|
-
# @return [Integer]
|
250
|
+
# @return [Integer, Float]
|
238
251
|
#
|
239
252
|
# @version SketchUp 6.0
|
240
253
|
def red=(red)
|
@@ -389,6 +389,25 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
389
389
|
def invalidate_bounds
|
390
390
|
end
|
391
391
|
|
392
|
+
# The {#live_component?} method is used to identify Live Components and
|
393
|
+
# sub-definitions of Live Components.
|
394
|
+
#
|
395
|
+
# @example Skipping Live Components
|
396
|
+
# model = Sketchup.active_model
|
397
|
+
# model.definitions.each { |definition|
|
398
|
+
# next if definition.live_component?
|
399
|
+
# puts definition.name
|
400
|
+
# }
|
401
|
+
#
|
402
|
+
# @note These components are parametrically generated and API users should not
|
403
|
+
# modify them.
|
404
|
+
#
|
405
|
+
# @return [Boolean]
|
406
|
+
#
|
407
|
+
# @version SketchUp 2021.0
|
408
|
+
def live_component?
|
409
|
+
end
|
410
|
+
|
392
411
|
# The name method retrieves the name of the component definition.
|
393
412
|
#
|
394
413
|
# @example
|
@@ -426,18 +445,14 @@ class Sketchup::ComponentDefinition < Sketchup::Drawingelement
|
|
426
445
|
|
427
446
|
# The path method is used to retrieve the path where the component was loaded.
|
428
447
|
#
|
429
|
-
# Returns nil if it is an internal component.
|
430
|
-
#
|
431
448
|
# @example
|
432
|
-
# path = Sketchup.find_support_file
|
433
|
-
# "Components/Components Sampler/"
|
449
|
+
# path = Sketchup.find_support_file("Bed.skp", "Components/Components Sampler/")
|
434
450
|
# model = Sketchup.active_model
|
435
451
|
# definitions = model.definitions
|
436
|
-
# componentdefinition = definitions.load
|
452
|
+
# componentdefinition = definitions.load(path)
|
437
453
|
# path = componentdefinition.path
|
438
454
|
#
|
439
|
-
# @return [String
|
440
|
-
# unsuccessful
|
455
|
+
# @return [String] Returns empty string if it is an internal component.
|
441
456
|
#
|
442
457
|
# @version SketchUp 6.0
|
443
458
|
def path
|
@@ -218,6 +218,8 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
218
218
|
# instance2 = entities[1]
|
219
219
|
# result = instance1.intersect(instance2)
|
220
220
|
#
|
221
|
+
# @note This method is not available in SketchUp Make.
|
222
|
+
#
|
221
223
|
# @param [Sketchup::ComponentInstance] instance
|
222
224
|
# The instance to intersect this instance with.
|
223
225
|
#
|
@@ -263,7 +265,8 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
263
265
|
end
|
264
266
|
|
265
267
|
# The {#make_unique} method is used to create a component definition for this
|
266
|
-
# instance that is not used by any other instances.
|
268
|
+
# instance that is not used by any other instances. If the component is already
|
269
|
+
# unique in the model, nothing happens.
|
267
270
|
#
|
268
271
|
# @example
|
269
272
|
# point = Geom::Point3d.new(10,20,30)
|
@@ -300,8 +303,9 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
300
303
|
def manifold?
|
301
304
|
end
|
302
305
|
|
303
|
-
# The move! method is
|
304
|
-
#
|
306
|
+
# The {#move!} method is used to set the transformation of this component
|
307
|
+
# instance, similarly to {#transformation=} but without recording to the undo
|
308
|
+
# stack.
|
305
309
|
#
|
306
310
|
# This method is useful for moving entities inside of an animation or page
|
307
311
|
# transition.
|
@@ -312,15 +316,17 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
312
316
|
# transformation = Geom::Transformation.new([0,0,0])
|
313
317
|
# componentinstance = entities.add_instance(definition, transformation)
|
314
318
|
# new_transformation = Geom::Transformation.new([100,0,0])
|
315
|
-
# componentinstance.move!
|
319
|
+
# componentinstance.move!(new_transformation)
|
316
320
|
#
|
317
|
-
# @
|
318
|
-
#
|
321
|
+
# @note Despite the name being similar to {#transform!}, this method closer
|
322
|
+
# corresponds to {#transformation=}.
|
323
|
+
#
|
324
|
+
# @param [Geom::Transformation] transformation
|
319
325
|
#
|
320
326
|
# @return [Boolean] true if successful, false if unsuccessful
|
321
327
|
#
|
322
328
|
# @version SketchUp 6.0
|
323
|
-
def move!(
|
329
|
+
def move!(transformation)
|
324
330
|
end
|
325
331
|
|
326
332
|
# The name method is used to get the name of this instance.
|
@@ -438,6 +444,8 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
438
444
|
# instance2 = entities[1]
|
439
445
|
# result = instance1.split(instance2)
|
440
446
|
#
|
447
|
+
# @note This method is not available in SketchUp Make.
|
448
|
+
#
|
441
449
|
# @param [Sketchup::ComponentInstance, nil] instance
|
442
450
|
# The instance to split this instance with.
|
443
451
|
#
|
@@ -463,6 +471,8 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
463
471
|
# instance2 = entities[1]
|
464
472
|
# result = instance1.subtract(instance2)
|
465
473
|
#
|
474
|
+
# @note This method is not available in SketchUp Make.
|
475
|
+
#
|
466
476
|
# @param [Sketchup::ComponentInstance] instance
|
467
477
|
# The instance to subtract this instance from.
|
468
478
|
#
|
@@ -509,8 +519,8 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
509
519
|
def transformation
|
510
520
|
end
|
511
521
|
|
512
|
-
# The transformation= method is used to set the transformation
|
513
|
-
# instance.
|
522
|
+
# The {#transformation=} method is used to set the transformation of this
|
523
|
+
# component instance.
|
514
524
|
#
|
515
525
|
# @example
|
516
526
|
# entities = Sketchup.active_model.entities
|
@@ -521,9 +531,6 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
521
531
|
# componentinstance.transformation = new_transformation
|
522
532
|
#
|
523
533
|
# @param [Geom::Transformation] transformation
|
524
|
-
# A Transformation object to apply.
|
525
|
-
#
|
526
|
-
# @return [Sketchup::ComponentInstance] the transformed ComponentInstance
|
527
534
|
#
|
528
535
|
# @version SketchUp 6.0
|
529
536
|
def transformation=(transformation)
|
@@ -540,6 +547,8 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
540
547
|
# instance2 = entities[1]
|
541
548
|
# result = instance1.trim(instance2)
|
542
549
|
#
|
550
|
+
# @note This method is not available in SketchUp Make.
|
551
|
+
#
|
543
552
|
# @param [Sketchup::ComponentInstance] instance
|
544
553
|
# The instance to trim this instance against.
|
545
554
|
#
|
@@ -561,6 +570,8 @@ class Sketchup::ComponentInstance < Sketchup::Drawingelement
|
|
561
570
|
# instance2 = entities[1]
|
562
571
|
# result = instance1.union(instance2)
|
563
572
|
#
|
573
|
+
# @note This method is not available in SketchUp Make.
|
574
|
+
#
|
564
575
|
# @param [Sketchup::ComponentInstance] instance
|
565
576
|
# The instance to union this instance with.
|
566
577
|
#
|
@@ -50,7 +50,7 @@ class Sketchup::Curve < Sketchup::Entity
|
|
50
50
|
# edgearray = entities.add_circle centerpoint, vector2, 10
|
51
51
|
# edge = edgearray[0]
|
52
52
|
# curve = edge.curve
|
53
|
-
# curve.each_edge {|
|
53
|
+
# curve.each_edge {|edge| puts "Edge {edge.entityID}: {edge.length}" }
|
54
54
|
#
|
55
55
|
# @return edge - a variable that will hold each Edge object as
|
56
56
|
# they are found.
|
@@ -150,22 +150,29 @@ class Sketchup::Curve < Sketchup::Entity
|
|
150
150
|
# curve = edge.curve
|
151
151
|
# length = curve.length
|
152
152
|
#
|
153
|
-
# @return
|
154
|
-
# successful
|
153
|
+
# @return [Length]
|
155
154
|
#
|
156
155
|
# @version SketchUp 6.0
|
157
156
|
def length
|
158
157
|
end
|
159
158
|
|
160
|
-
# The
|
159
|
+
# The {#move_vertices} method moves the vertices in the curve to points.
|
161
160
|
#
|
162
161
|
# @example
|
163
|
-
#
|
162
|
+
# model = Sketchup.active_model
|
163
|
+
# entities = model.entities
|
164
|
+
# new_edges = entities.add_arc(ORIGIN, X_AXIS, Z_AXIS, 20.cm, 0, 270.degrees, 32)
|
165
|
+
# curve = new_edges.first.curve
|
166
|
+
# points = curve.vertices.map(&:position)
|
167
|
+
# points.each_with_index { |pt, i| pt.z = i * 1.cm }
|
168
|
+
# curve.move_vertices(points)
|
169
|
+
#
|
170
|
+
# @param [Array<Geom::Point3d>] point_array
|
164
171
|
#
|
165
|
-
# @
|
166
|
-
#
|
172
|
+
# @raise ArgumentError if the number of points doesn't match number of vertices
|
173
|
+
# in curve
|
167
174
|
#
|
168
|
-
# @return
|
175
|
+
# @return [Boolean]
|
169
176
|
#
|
170
177
|
# @version SketchUp 6.0
|
171
178
|
def move_vertices(point_array)
|
@@ -131,10 +131,8 @@ class Sketchup::DefinitionList < Sketchup::Entity
|
|
131
131
|
def count
|
132
132
|
end
|
133
133
|
|
134
|
-
# The each method is used to iterate through all of the component
|
135
|
-
# in the definition list.
|
136
|
-
#
|
137
|
-
# Throws an exception if there are no component definitions.
|
134
|
+
# The {#each} method is used to iterate through all of the component
|
135
|
+
# definitions in the definition list.
|
138
136
|
#
|
139
137
|
# @example
|
140
138
|
# model = Sketchup.active_model
|
@@ -142,6 +140,11 @@ class Sketchup::DefinitionList < Sketchup::Entity
|
|
142
140
|
# definitions.add("BedTraditional")
|
143
141
|
# number = definitions.each { |definition| puts definition.name }
|
144
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
|
+
#
|
145
148
|
# @return [nil]
|
146
149
|
#
|
147
150
|
# @version SketchUp 6.0
|
@@ -166,29 +169,55 @@ class Sketchup::DefinitionList < Sketchup::Entity
|
|
166
169
|
def length
|
167
170
|
end
|
168
171
|
|
169
|
-
# The load method is used to load a component from a file.
|
172
|
+
# The {#load} method is used to load a component from a file.
|
173
|
+
#
|
174
|
+
# @bug In SketchUp versions prior to SketchUp 2019 the application would crash
|
175
|
+
# if you tried to open a newer model instead of raising the expected
|
176
|
+
# +RuntimeError+.
|
170
177
|
#
|
171
178
|
# @example
|
172
|
-
# path=Sketchup.find_support_file
|
173
|
-
# "Components/Components Sampler/"
|
179
|
+
# path = Sketchup.find_support_file("Bed.skp",
|
180
|
+
# "Components/Components Sampler/")
|
174
181
|
# model = Sketchup.active_model
|
175
182
|
# definitions = model.definitions
|
176
|
-
#
|
183
|
+
# definition = definitions.load(path)
|
184
|
+
#
|
185
|
+
# @overload load(path)
|
186
|
+
#
|
187
|
+
# @param [String] path
|
188
|
+
# The path where the component definition file is located.
|
189
|
+
#
|
190
|
+
# @overload load(path, allow_newer: true)
|
191
|
+
#
|
192
|
+
# Starting with SketchUp 2021.0 SketchUp attempts to load newer SketchUp
|
193
|
+
# models. If a newer model is loaded some information might have been skipped
|
194
|
+
# and extensions should be careful to not save over the file they loaded from
|
195
|
+
# as information might be lost.
|
177
196
|
#
|
178
|
-
#
|
179
|
-
#
|
197
|
+
# @version SketchUp 2021.0
|
198
|
+
# @param [String] path
|
199
|
+
# The path where the component definition file is located.
|
200
|
+
# @param [Boolean] allow_newer
|
201
|
+
# Indicate that it is ok to load a model with of a newer version.
|
180
202
|
#
|
181
|
-
# @raise
|
182
|
-
#
|
203
|
+
# @raise IOError If the file is not a valid SketchUp model.
|
204
|
+
#
|
205
|
+
# @raise RuntimeError If the file is the same as the model being loaded into.
|
206
|
+
#
|
207
|
+
# @raise IOError If the file is an empty component.
|
208
|
+
#
|
209
|
+
# @raise RuntimeError If the file contains only screen text.
|
210
|
+
#
|
211
|
+
# @raise RuntimeError If the file is of a newer file version that the executing
|
212
|
+
# SketchUp version cannot open.
|
183
213
|
#
|
184
214
|
# @return [Sketchup::ComponentDefinition] the loaded ComponentDefinition
|
185
|
-
# object if successful
|
186
215
|
#
|
187
216
|
# @version SketchUp 6.0
|
188
|
-
def load(
|
217
|
+
def load(*args)
|
189
218
|
end
|
190
219
|
|
191
|
-
# The load_from_url method loads a component from a location specified by
|
220
|
+
# The {#load_from_url} method loads a component from a location specified by
|
192
221
|
# string url. This method throws an exception if an url string is not
|
193
222
|
# given, or an error occurs during retrieval from url and a
|
194
223
|
# load_handler was not given. Optional second parameter load_handler can be
|
@@ -201,11 +230,10 @@ class Sketchup::DefinitionList < Sketchup::Entity
|
|
201
230
|
#
|
202
231
|
# @example
|
203
232
|
# class LoadHandler
|
204
|
-
#
|
205
|
-
# attr :error
|
233
|
+
# attr_accessor :error
|
206
234
|
#
|
207
235
|
# def onPercentChange(percent)
|
208
|
-
# Sketchup::set_status_text("
|
236
|
+
# Sketchup::set_status_text("loading: #{percent.round}%")
|
209
237
|
# end
|
210
238
|
#
|
211
239
|
# def cancelled?
|
@@ -223,30 +251,35 @@ class Sketchup::DefinitionList < Sketchup::Entity
|
|
223
251
|
# self.error = error_message
|
224
252
|
# Sketchup::set_status_text('')
|
225
253
|
# end
|
226
|
-
#
|
227
254
|
# end
|
228
255
|
#
|
229
256
|
# # Replace this with a real URL...
|
230
257
|
# url = 'http://www.sketchup.com/model.skp'
|
231
258
|
# model = Sketchup.active_model
|
259
|
+
# load_handler = LoadHandler.new
|
232
260
|
# definition = model.definitions.load_from_url(url, load_handler)
|
233
261
|
#
|
234
262
|
# if definition.nil?
|
235
263
|
# puts "Error: #{load_handler.error}"
|
236
264
|
# end
|
237
265
|
#
|
238
|
-
# @
|
239
|
-
# URL to load a .skp file from.
|
266
|
+
# @overload load_from_url(url)
|
240
267
|
#
|
241
|
-
#
|
242
|
-
#
|
243
|
-
# as described in the load_from_url details.
|
268
|
+
# @param [String] url
|
269
|
+
# URL to load a .skp file from.
|
244
270
|
#
|
245
|
-
# @
|
246
|
-
#
|
271
|
+
# @overload load_from_url(url, load_handler)
|
272
|
+
#
|
273
|
+
# @param [String] url
|
274
|
+
# URL to load a .skp file from.
|
275
|
+
# @param [Object] load_handler
|
276
|
+
# Ruby object that has methods defined
|
277
|
+
# as described in the load_from_url details.
|
278
|
+
#
|
279
|
+
# @return [Sketchup::ComponentDefinition]
|
247
280
|
#
|
248
281
|
# @version SketchUp 7.0
|
249
|
-
def load_from_url(
|
282
|
+
def load_from_url(*args)
|
250
283
|
end
|
251
284
|
|
252
285
|
# The purge_unused method is used to remove the unused component definitions.
|
@@ -2,9 +2,11 @@
|
|
2
2
|
# License:: The MIT License (MIT)
|
3
3
|
|
4
4
|
# This observer interface is implemented to react to component definition
|
5
|
-
# events.
|
6
|
-
#
|
7
|
-
#
|
5
|
+
# events.
|
6
|
+
#
|
7
|
+
# @abstract To implement this observer, create a Ruby class of this type,
|
8
|
+
# override the desired methods, and add an instance of the observer to the
|
9
|
+
# definitions of interests.
|
8
10
|
#
|
9
11
|
# @example
|
10
12
|
# # This is an example of an observer that watches a specific definition
|