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.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sketchup-api-stubs/sketchup.rb +2 -0
  3. data/lib/sketchup-api-stubs/stubs/Geom/BoundingBox.rb +14 -10
  4. data/lib/sketchup-api-stubs/stubs/Geom/Bounds2d.rb +4 -4
  5. data/lib/sketchup-api-stubs/stubs/Geom/LatLong.rb +4 -4
  6. data/lib/sketchup-api-stubs/stubs/Geom/Point2d.rb +4 -5
  7. data/lib/sketchup-api-stubs/stubs/Geom/Point3d.rb +17 -17
  8. data/lib/sketchup-api-stubs/stubs/Geom/PolygonMesh.rb +6 -0
  9. data/lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb +1 -2
  10. data/lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb +3 -3
  11. data/lib/sketchup-api-stubs/stubs/Layout/AngularDimension.rb +4 -0
  12. data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinitions.rb +6 -13
  13. data/lib/sketchup-api-stubs/stubs/Layout/Document.rb +60 -4
  14. data/lib/sketchup-api-stubs/stubs/Layout/Entities.rb +6 -13
  15. data/lib/sketchup-api-stubs/stubs/Layout/Grid.rb +188 -0
  16. data/lib/sketchup-api-stubs/stubs/Layout/Image.rb +8 -3
  17. data/lib/sketchup-api-stubs/stubs/Layout/Label.rb +1 -2
  18. data/lib/sketchup-api-stubs/stubs/Layout/Layers.rb +6 -13
  19. data/lib/sketchup-api-stubs/stubs/Layout/LinearDimension.rb +5 -1
  20. data/lib/sketchup-api-stubs/stubs/Layout/Pages.rb +6 -13
  21. data/lib/sketchup-api-stubs/stubs/Layout/SketchUpModel.rb +147 -4
  22. data/lib/sketchup-api-stubs/stubs/Sketchup/Animation.rb +4 -0
  23. data/lib/sketchup-api-stubs/stubs/Sketchup/AppObserver.rb +3 -3
  24. data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionaries.rb +2 -2
  25. data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionary.rb +5 -0
  26. data/lib/sketchup-api-stubs/stubs/Sketchup/Behavior.rb +31 -57
  27. data/lib/sketchup-api-stubs/stubs/Sketchup/Camera.rb +109 -208
  28. data/lib/sketchup-api-stubs/stubs/Sketchup/Color.rb +23 -10
  29. data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentDefinition.rb +22 -7
  30. data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentInstance.rb +23 -12
  31. data/lib/sketchup-api-stubs/stubs/Sketchup/Curve.rb +15 -8
  32. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionList.rb +60 -27
  33. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb +5 -3
  34. data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionsObserver.rb +5 -3
  35. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionLinear.rb +2 -8
  36. data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionObserver.rb +4 -0
  37. data/lib/sketchup-api-stubs/stubs/Sketchup/Drawingelement.rb +9 -3
  38. data/lib/sketchup-api-stubs/stubs/Sketchup/Edge.rb +7 -13
  39. data/lib/sketchup-api-stubs/stubs/Sketchup/Entities.rb +54 -25
  40. data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesObserver.rb +5 -3
  41. data/lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb +19 -14
  42. data/lib/sketchup-api-stubs/stubs/Sketchup/EntityObserver.rb +5 -4
  43. data/lib/sketchup-api-stubs/stubs/Sketchup/ExtensionsManager.rb +8 -7
  44. data/lib/sketchup-api-stubs/stubs/Sketchup/Face.rb +8 -7
  45. data/lib/sketchup-api-stubs/stubs/Sketchup/Group.rb +46 -44
  46. data/lib/sketchup-api-stubs/stubs/Sketchup/Image.rb +8 -0
  47. data/lib/sketchup-api-stubs/stubs/Sketchup/ImageRep.rb +46 -6
  48. data/lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb +10 -11
  49. data/lib/sketchup-api-stubs/stubs/Sketchup/InputPoint.rb +32 -20
  50. data/lib/sketchup-api-stubs/stubs/Sketchup/InstanceObserver.rb +5 -3
  51. data/lib/sketchup-api-stubs/stubs/Sketchup/InstancePath.rb +4 -1
  52. data/lib/sketchup-api-stubs/stubs/Sketchup/Layer.rb +112 -69
  53. data/lib/sketchup-api-stubs/stubs/Sketchup/LayerFolder.rb +422 -0
  54. data/lib/sketchup-api-stubs/stubs/Sketchup/Layers.rb +224 -28
  55. data/lib/sketchup-api-stubs/stubs/Sketchup/LayersObserver.rb +117 -4
  56. data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyles.rb +1 -12
  57. data/lib/sketchup-api-stubs/stubs/Sketchup/Material.rb +7 -9
  58. data/lib/sketchup-api-stubs/stubs/Sketchup/Materials.rb +14 -7
  59. data/lib/sketchup-api-stubs/stubs/Sketchup/MaterialsObserver.rb +5 -4
  60. data/lib/sketchup-api-stubs/stubs/Sketchup/Menu.rb +8 -10
  61. data/lib/sketchup-api-stubs/stubs/Sketchup/Model.rb +122 -72
  62. data/lib/sketchup-api-stubs/stubs/Sketchup/ModelObserver.rb +4 -3
  63. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsManager.rb +1 -2
  64. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb +6 -6
  65. data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProviderObserver.rb +3 -3
  66. data/lib/sketchup-api-stubs/stubs/Sketchup/Page.rb +142 -39
  67. data/lib/sketchup-api-stubs/stubs/Sketchup/Pages.rb +21 -11
  68. data/lib/sketchup-api-stubs/stubs/Sketchup/PagesObserver.rb +5 -4
  69. data/lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb +36 -14
  70. data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptionsObserver.rb +4 -3
  71. data/lib/sketchup-api-stubs/stubs/Sketchup/Selection.rb +9 -4
  72. data/lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb +19 -19
  73. data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfo.rb +4 -4
  74. data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfoObserver.rb +5 -3
  75. data/lib/sketchup-api-stubs/stubs/Sketchup/Skp.rb +40 -0
  76. data/lib/sketchup-api-stubs/stubs/Sketchup/Styles.rb +8 -2
  77. data/lib/sketchup-api-stubs/stubs/Sketchup/Texture.rb +13 -21
  78. data/lib/sketchup-api-stubs/stubs/Sketchup/Tool.rb +30 -24
  79. data/lib/sketchup-api-stubs/stubs/Sketchup/Tools.rb +1 -1
  80. data/lib/sketchup-api-stubs/stubs/Sketchup/ToolsObserver.rb +5 -3
  81. data/lib/sketchup-api-stubs/stubs/Sketchup/UVHelper.rb +31 -21
  82. data/lib/sketchup-api-stubs/stubs/Sketchup/View.rb +72 -66
  83. data/lib/sketchup-api-stubs/stubs/Sketchup/ViewObserver.rb +5 -3
  84. data/lib/sketchup-api-stubs/stubs/UI/Command.rb +12 -5
  85. data/lib/sketchup-api-stubs/stubs/UI/HtmlDialog.rb +34 -3
  86. data/lib/sketchup-api-stubs/stubs/UI/Notification.rb +36 -10
  87. data/lib/sketchup-api-stubs/stubs/UI/WebDialog.rb +2 -2
  88. data/lib/sketchup-api-stubs/stubs/_top_level.rb +2 -0
  89. data/lib/sketchup-api-stubs/stubs/geom.rb +3 -0
  90. data/lib/sketchup-api-stubs/stubs/sketchup.rb +54 -22
  91. data/lib/sketchup-api-stubs/stubs/ui.rb +9 -8
  92. metadata +4 -16
@@ -3,6 +3,14 @@
3
3
 
4
4
  # An Image object represents a raster image placed in the Model.
5
5
  #
6
+ # @example Create material from image (SU 2018 and later)
7
+ # model = Sketchup.active_model
8
+ # entities = model.active_entities
9
+ # image = entities.grep(Sketchup::Image).first
10
+ # img_rep = image.image_rep
11
+ # material = model.materials.add("New Name")
12
+ # material.texture = img_rep
13
+ #
6
14
  # @version SketchUp 6.0
7
15
  class Sketchup::Image < Sketchup::Drawingelement
8
16
 
@@ -3,6 +3,12 @@
3
3
 
4
4
  # References an image representation object.
5
5
  #
6
+ # @example
7
+ # # Get the color of the center of the first material texture found in model.
8
+ # texture = Sketchup.active_model.materials.map(&:texture).compact.first
9
+ # image_rep = texture.image_rep
10
+ # color = image_rep.color_at_uv(0.5, 0.5)
11
+ #
6
12
  # @version SketchUp 2018
7
13
  class Sketchup::ImageRep
8
14
 
@@ -23,7 +29,8 @@ class Sketchup::ImageRep
23
29
  end
24
30
 
25
31
  # The {#color_at_uv} method returns a color corresponding to the UV texture
26
- # coordinates
32
+ # coordinates. +0.0, 0.0+ maps to the bottom left and +1.0, 1.0+ to the top
33
+ # right of the image.
27
34
  #
28
35
  # @example
29
36
  # image_rep = Sketchup::ImageRep.new
@@ -69,6 +76,8 @@ class Sketchup::ImageRep
69
76
  # byte_string = image_rep.data
70
77
  # byte_string.each_byte { |byte| puts byte, ' ' }
71
78
  #
79
+ # @note The byte order of the pixels are RGB(A) on macOS and BGR(A) on Windows.
80
+ #
72
81
  # @return [String, nil]
73
82
  #
74
83
  # @version SketchUp 2018
@@ -93,6 +102,7 @@ class Sketchup::ImageRep
93
102
  #
94
103
  # @example Default constructor
95
104
  # image_rep = Sketchup::ImageRep.new
105
+ # # Use #set_data or #load_file to add image data.
96
106
  #
97
107
  # @example Construct from file
98
108
  # image_rep = Sketchup::ImageRep.new("/path/to/image.jpg")
@@ -155,15 +165,45 @@ class Sketchup::ImageRep
155
165
  def save_file(filepath)
156
166
  end
157
167
 
158
- # The {#set_data} method sets the pixel data of the {Sketchup::ImageRep}.
168
+ # The {#set_data} method discards any existing data and sets new pixel data for
169
+ # the {Sketchup::ImageRep}.
159
170
  #
160
171
  # @example Setting new data
161
172
  # image_rep = Sketchup::ImageRep.new
162
- # image_rep.load_file("/path/to/image.jpg")
163
- # new_image_rep = image_rep.set_data(800, 600, 24, 0, pixel_data)
173
+ # width = 800
174
+ # height = 600
175
+ # bpp = 24
176
+ # pixel = [127, 127, 127].pack("C*")
177
+ # pixels = pixel * width * height
178
+ # image_rep.set_data(width, height, bpp, 0, pixels)
179
+ # image_rep.save_file(UI.savepanel)
180
+ #
181
+ # @example Handling system color differences
182
+ # # Generates red image on Mac and blue on Windows.
183
+ # image_rep = Sketchup::ImageRep.new
184
+ # color = Sketchup::Color.new("Red")
185
+ # rgba = color.to_a # Red, green , blue, alpha
186
+ # color_data = rgba.pack("C*")
187
+ # image_rep.set_data(1, 1, 32, 0, color_data)
188
+ # image_rep.save_file(UI.savepanel)
189
+ #
190
+ # # Generates red image on both systems.
191
+ # image_rep = Sketchup::ImageRep.new
192
+ # color = Sketchup::Color.new("Red")
193
+ # color_code = color.to_a # Red, green, blue, alpha
194
+ # if Sketchup.platform == :platform_win
195
+ # # Change order to Blue, green, red, alpha on Windows.
196
+ # color_code = color_code.values_at(2, 1, 0, 3)
197
+ # end
198
+ # color_data = color_code.pack("C*")
199
+ # image_rep.set_data(1, 1, 32, 0, color_data)
200
+ # image_rep.save_file(UI.savepanel)
201
+ #
202
+ # @note The byte order of the pixels are RGB(A) on macOS and BGR(A) on Windows.
164
203
  #
165
204
  # @note The encoding of the pixel_data {String} parameter should be ASCII-8BIT.
166
- # Any other encoding could corrupt the binary data.
205
+ # Any other encoding could corrupt the binary data. Using
206
+ # `Array#pack("C*")` gives correct encoding.
167
207
  #
168
208
  # @param [Integer] width
169
209
  # The width of the pixel data. Must be greater than 0.
@@ -179,7 +219,7 @@ class Sketchup::ImageRep
179
219
  # @param [Integer] row_padding
180
220
  # The row padding for the pixel data which is
181
221
  # sized in bytes. Row padding is used to pad each row with zeros so that each
182
- # scanline on the pixel data will end on the data-type boundry.
222
+ # scanline on the pixel data will end on the data-type boundary.
183
223
  #
184
224
  # @param [String] pixel_data
185
225
  # The binary string containing the pixel data
@@ -53,7 +53,8 @@
53
53
  # # processing the file.
54
54
  # def load_file(file_path, status)
55
55
  # UI.messagebox(file_path)
56
- # return 0 # 0 is the code for a successful import
56
+ #
57
+ # return Sketchup::Importer::ImportSuccess
57
58
  # end
58
59
  # end
59
60
  #
@@ -68,7 +69,6 @@ class Sketchup::Importer
68
69
  ImportFail = nil # Stub value.
69
70
  ImportFileNotFound = nil # Stub value.
70
71
  ImportSuccess = nil # Stub value.
71
- ImporterNotFound = nil # Stub value.
72
72
 
73
73
  # Instance Methods
74
74
 
@@ -144,20 +144,19 @@ class Sketchup::Importer
144
144
  # File object and processing it in whatever way you need.
145
145
  #
146
146
  # You must return an integer success code to SketchUp when you are done.
147
- # These are the codes that SketchUp understands and what will happen when
148
- # SketchUp receives each key.
147
+ # These are the codes that SketchUp understands:
149
148
  #
150
- # - 0 = Import Success (no additional dialog shown)
151
- # - 1 = Import Failed (no additional dialog shown)
152
- # - 2 = Import Cancelled by User (SketchUp will show a "cancelled" dialog)
153
- # - 4 = Import File not Found (SketchUp will show a "not found" dialog)
154
- # - 5 = SketchUp version not supported (no additional dialog shown)
149
+ # - Sketchup::Importer::ImportSuccess
150
+ # - Sketchup::Importer::ImportFail
151
+ # - Sketchup::Importer::ImportCanceled - SketchUp will show a "cancelled" dialog
152
+ # - Sketchup::Importer::ImportFileNotFound - SketchUp will show a "not found" dialog
155
153
  #
156
154
  # @example
157
155
  # def load_file(file_path, status)
158
156
  # # Here is where you would open the file and process it.
159
- # UI.messagebox(file_path)
160
- # return 0 # Success
157
+ # puts file_path
158
+ #
159
+ # return Sketchup::Importer::ImportSuccess
161
160
  # end
162
161
  #
163
162
  # @param file_path
@@ -1,14 +1,23 @@
1
1
  # Copyright:: Copyright 2020 Trimble Inc.
2
2
  # License:: The MIT License (MIT)
3
3
 
4
- # The InputPoint used to pick entities that reside under the current cursor
5
- # location. InputPoint and PickHelper are similar, but InputPoint also uses
6
- # inferencing. Only tools react to cursor location. Therefore, most of the
7
- # methods in this class are only useful in the context of a tool you are
8
- # writing. For example, if you want to determine the entity that you just
9
- # clicked on with the mouse, you would use InputPoint.pick from within your
10
- # onLMouseButton method in a tool. See the example script linetool.rb for
11
- # examples of using the InputPoint class.
4
+ # The {Sketchup::InputPoint} class is used to pick 3d points and/or entities
5
+ # that reside under the current cursor location, similar to native Line tool
6
+ # and other drawing tools. Unlike {Sketchup::PickHelper},
7
+ # {Sketchup::InputPoint} uses inference, i.e. "snaps" to vertices and other
8
+ # entities when the cursor is close to them.
9
+ #
10
+ # Only {Sketchup::Tool}s react to cursor location and most of these methods are
11
+ # only useful in the context of a tool. For example, if you want to determine
12
+ # the 3d point you just moved the cursor over, you would use
13
+ # {#pick} from within your {Sketchup::Tool#onMouseMove} method.
14
+ # {Sketchup::InputPoints} are best picked from mouse move, as you want them to
15
+ # draw them to the view.
16
+ #
17
+ # For an example, see https://github.com/SketchUp/sketchup-ruby-api-tutorials/tree/master/examples/02_custom_tool.
18
+ #
19
+ # To lock inference similar to native SketchUp tools, see
20
+ # {View#lock_inference}.
12
21
  #
13
22
  # @version SketchUp 6.0
14
23
  class Sketchup::InputPoint
@@ -188,10 +197,8 @@ class Sketchup::InputPoint
188
197
  def edge
189
198
  end
190
199
 
191
- # The face method retrieves the face if the input point is getting its
192
- # position from a face.
193
- #
194
- # Otherwise it returns nil.
200
+ # The face method retrieves the face at or behind the input point. This can be
201
+ # used to determine a plane, similar to what native Rotate tool does.
195
202
  #
196
203
  # @example
197
204
  # view = Sketchup.active_model.active_view
@@ -200,8 +207,10 @@ class Sketchup::InputPoint
200
207
  # ip1 = view.inputpoint x,y
201
208
  # f = ip1.face
202
209
  #
203
- # @return face - a Face object if successful, or nil if
204
- # unsuccessful
210
+ # @note The InputPoint doesn't necessarily lie on the face, but can be e.g. on
211
+ # an edge in front of the face.
212
+ #
213
+ # @return [Sketchup::Face, nil]
205
214
  #
206
215
  # @version SketchUp 6.0
207
216
  def face
@@ -220,15 +229,18 @@ class Sketchup::InputPoint
220
229
  # sub-class {Sketchup::InputPoint} due to a bug in how SketchUp initialized
221
230
  # the class.
222
231
  #
223
- # @param pt_or_vertex
224
- # An optional Point3d or Vertex where the new InputPoint
225
- # should be created.
232
+ # @overload initialize()
226
233
  #
227
- # @return inputpoint - the newly created InputPoint object if
228
- # successful
234
+ # @return [Sketchup::InputPoint]
235
+ #
236
+ # @overload initialize(pt_or_vertex)
237
+ #
238
+ # @param pt_or_vertex [Geom::Point3d, Sketchup::Vertex] An optional Point3d
239
+ # or Vertex where the new InputPoint should be created.
240
+ # @return [Sketchup::InputPoint]
229
241
  #
230
242
  # @version SketchUp 6.0
231
- def initialize(pt_or_vertex)
243
+ def initialize(*args)
232
244
  end
233
245
 
234
246
  # The {#instance_path} method retrieves the instance path for the picked point.
@@ -2,13 +2,15 @@
2
2
  # License:: The MIT License (MIT)
3
3
 
4
4
  # This observer interface is implemented to react to component instance
5
- # events. To implement this observer, create a Ruby class of this type,
6
- # override the desired methods, and add an instance of the observer to the
7
- # objects of interests.
5
+ # events.
8
6
  #
9
7
  # Note that you may also attach {Sketchup::InstanceObserver}s to
10
8
  # {Sketchup::Group}s.
11
9
  #
10
+ # @abstract To implement this observer, create a Ruby class of this type,
11
+ # override the desired methods, and add an instance of the observer to the
12
+ # objects of interests.
13
+ #
12
14
  # @example
13
15
  # # This is an example of an observer that watches a specific instance
14
16
  # # for open edit actions and shows a messagebox.
@@ -30,7 +30,7 @@ class Sketchup::InstancePath
30
30
  def ==(other)
31
31
  end
32
32
 
33
- # The elements of an instance path can be accessed like an array.
33
+ # The elements of an instance path can be accessed similarly to an array.
34
34
  #
35
35
  # @example
36
36
  # model = Sketchup.active_model
@@ -40,6 +40,9 @@ class Sketchup::InstancePath
40
40
  # path[0] == group # returns true
41
41
  # path[1] == edge # returns true
42
42
  #
43
+ # @note This method does not accept negative indices. For the exact behavior
44
+ # of an array, use +{#to_a}+.
45
+ #
43
46
  # @param [Integer] index
44
47
  #
45
48
  # @raise [IndexError] if the given index is out of bounds
@@ -4,7 +4,8 @@
4
4
  # The Layer class contains methods modifying and extracting information for a
5
5
  # layer.
6
6
  #
7
- # By default, a SketchUp model has one layer, Layer 0 (zero), which is the base
7
+ # By default, a SketchUp model has one layer, Layer 0 (Named "Untagged" in the
8
+ # UI since SketchUp 2020), which is the base
8
9
  # layer. You can't delete or rename Layer 0. Unlike certain other CAD software
9
10
  # packages, entities associated with different layers in SketchUp still
10
11
  # intersect with each other. (If you want collections of entities to not
@@ -15,12 +16,14 @@
15
16
  # wall and roof entities different groups, associate layers with those groups,
16
17
  # and then hide those layers so as to display just the floor plan in the model.
17
18
  #
18
- # You can programatically create a new layer by calling the Layers.add method.
19
- #
20
19
  # @example
21
20
  # model = Sketchup.active_model
22
21
  # layers = model.layers
23
- # new_layer = layers.add "test layer"
22
+ # new_layer = layers.add('Doors')
23
+ #
24
+ # @note As of SketchUp 2020 "Layers" were renamed to "Tags" in the UI.
25
+ # The API retains the use of "Layer" for compatibility and is synonymous with
26
+ # "Tag".
24
27
  #
25
28
  # @version SketchUp 6.0
26
29
  class Sketchup::Layer < Sketchup::Entity
@@ -31,8 +34,8 @@ class Sketchup::Layer < Sketchup::Entity
31
34
 
32
35
  # Instance Methods
33
36
 
34
- # The <=> method is used to compare two layers based on their names. You could
35
- # use this for sorting if you're building a list of layer names.
37
+ # The {#<=>} method is used to compare two layers based on their names. You
38
+ # could use this for sorting if you're building a list of layer names.
36
39
  #
37
40
  # @example
38
41
  # model = Sketchup.active_model
@@ -42,37 +45,31 @@ class Sketchup::Layer < Sketchup::Entity
42
45
  # layer2 = layers[1]
43
46
  # status = layer1 <=> layer2
44
47
  #
45
- # @param layer2
46
- # A Layer object.
48
+ # @param [Sketchup::Layer] layer2
47
49
  #
48
- # @return status - -1 if layer1 is less than layer2. 1 if layer2
49
- # is less than layer1. 0 if layer1 and layer2 are
50
- # equal.
50
+ # @return [Integer] -1 if layer1 is less than layer2. 1 if layer2
51
+ # is less than layer1. 0 if layer1 and layer2 are equal.
51
52
  #
52
53
  # @version SketchUp 6.0
53
54
  def <=>(layer2)
54
55
  end
55
56
 
56
- # The == method is used to determine if two layers are the same.
57
+ # The {#==} method is used to determine if two layers are the same.
57
58
  #
58
59
  # @example
59
60
  # model = Sketchup.active_model
60
61
  # layers = model.layers
61
- # layer1 = layers.add "test layer 1"
62
- # layer2 = layers.add "test layer 2"
63
- # status = layer1 == layer2
64
- #
65
- # @param layer2
66
- # A Layer object.
62
+ # layer1 = layers.add("Test layer 1")
63
+ # layer2 = layers.add("Test layer 2")
64
+ # equal = layer1 == layer2
67
65
  #
68
- # @return status - true if layer1 and layer2 are equal. false if
69
- # layer1 and layer2 are not equal.
66
+ # @param [Object] other
70
67
  #
71
68
  # @version SketchUp 6.0
72
- def ==(layer2)
69
+ def ==(other)
73
70
  end
74
71
 
75
- # The color method is used to retrieve the color of the layer.
72
+ # The {#color} method is used to retrieve the color of the layer.
76
73
  #
77
74
  # @example
78
75
  # model = Sketchup.active_model
@@ -80,13 +77,13 @@ class Sketchup::Layer < Sketchup::Entity
80
77
  # new_layer = layers.add('Test layer')
81
78
  # color = new_layer.color
82
79
  #
83
- # @return color - the color of the Layer object
80
+ # @return [Sketchup::Color]
84
81
  #
85
82
  # @version SketchUp 2014
86
83
  def color
87
84
  end
88
85
 
89
- # The color= method is used to set the name of a layer.
86
+ # The {#color=} method is used to set the name of a layer.
90
87
  #
91
88
  # @example
92
89
  # model = Sketchup.active_model
@@ -94,10 +91,7 @@ class Sketchup::Layer < Sketchup::Entity
94
91
  # new_layer = layers.add('Test layer')
95
92
  # new_layer.color = Sketchup::Color.new(192, 0, 0)
96
93
  #
97
- # @param color
98
- # The new color for the Layer object.
99
- #
100
- # @return color
94
+ # @param [Sketchup::Color] color
101
95
  #
102
96
  # @version SketchUp 2014
103
97
  def color=(color)
@@ -111,7 +105,7 @@ class Sketchup::Layer < Sketchup::Entity
111
105
  # new_layer = layers.add ("test layer")
112
106
  # name = new_layer.display_name
113
107
  #
114
- # @return [String] the display name of the Layer object
108
+ # @return [String]
115
109
  #
116
110
  # @see #name
117
111
  #
@@ -119,8 +113,46 @@ class Sketchup::Layer < Sketchup::Entity
119
113
  def display_name
120
114
  end
121
115
 
122
- # Layer Group methods
123
- def layer_group
116
+ # The {#folder} method is used to return the parent layer folder of a layer.
117
+ #
118
+ # @api TagFolder
119
+ #
120
+ # @example
121
+ # model = Sketchup.active_model
122
+ # layers = model.layers
123
+ # folder1 = layers.add('Folder1')
124
+ # parent_folder = folder1.folder # Returns: nil
125
+ #
126
+ # folder2 = folder1.add('Folder2')
127
+ # parent_folder = folder2.folder # Returns: folder1
128
+ #
129
+ # @return [Sketchup::LayerFolder, nil] +nil+ if the folder is a direct child to
130
+ # the layer manager.
131
+ #
132
+ # @version SketchUp 2021.0
133
+ def folder
134
+ end
135
+
136
+ # The {#folder=} method is used to set the parent layer folder of a layer.
137
+ #
138
+ # This will trigger +onParentFolderChanged+ in normal cases and
139
+ # +onLayerChanged+ during undo/redo.
140
+ #
141
+ # @api TagFolder
142
+ #
143
+ # @example
144
+ # model = Sketchup.active_model
145
+ # layers = model.layers
146
+ # folder = layers.add_folder('Hello')
147
+ # layer = layers.add_layer('World')
148
+ # layer.folder = folder
149
+ #
150
+ # @param [Sketchup::LayerFolder, nil] parent
151
+ # +nil+ will make the layer a
152
+ # direct child to the layer manager.
153
+ #
154
+ # @version SketchUp 2021.0
155
+ def folder=(parent)
124
156
  end
125
157
 
126
158
  # The {#line_style} method retrieves the line style on this layer.
@@ -165,7 +197,7 @@ class Sketchup::Layer < Sketchup::Entity
165
197
  def name
166
198
  end
167
199
 
168
- # The name= method is used to set the name of a layer.
200
+ # The {#name=} method is used to set the name of a layer.
169
201
  #
170
202
  # @example
171
203
  # model = Sketchup.active_model
@@ -173,16 +205,13 @@ class Sketchup::Layer < Sketchup::Entity
173
205
  # new_layer = layers.add "test layer"
174
206
  # name = new_layer.name = "new test layer"
175
207
  #
176
- # @param name
177
- # The new name for the Layer object.
178
- #
179
- # @return name - the newly set name
208
+ # @param [String] name
180
209
  #
181
210
  # @version SketchUp 6.0
182
211
  def name=(name)
183
212
  end
184
213
 
185
- # The page_behavior method is used to retrieve the visibility behavior of the
214
+ # The {#page_behavior} method is used to retrieve the visibility behavior of the
186
215
  # layer for new pages and existing pages. For example, you may want your layer
187
216
  # to be visible or hidden by default in any new pages (aka Scenes) created by
188
217
  # the user.
@@ -192,15 +221,25 @@ class Sketchup::Layer < Sketchup::Entity
192
221
  # determined by one of these values:
193
222
  #
194
223
  # The behaviour is composed of a combination of these flags:
195
- # - LAYER_VISIBLE_BY_DEFAULT: 0x0000
196
- # - LAYER_HIDDEN_BY_DEFAULT: 0x0001
197
- # - LAYER_USES_DEFAULT_VISIBILITY_ON_NEW_PAGES: 0x0000
198
- # - LAYER_IS_VISIBLE_ON_NEW_PAGES: 0x0010
199
- # - LAYER_IS_HIDDEN_ON_NEW_PAGES: 0x0020
224
+ #
225
+ # [Default visibility]
226
+ # These flags are used to set the value of {#page_behavior}. A page keeps
227
+ # a list of layers that do not have their default behavior. If a layer
228
+ # is not in that list, then it is set to its default visibility which
229
+ # is determined by one of these flags.
230
+ # - {LAYER_VISIBLE_BY_DEFAULT}: +0x0000+
231
+ # - {LAYER_HIDDEN_BY_DEFAULT}: +0x0001+
232
+ #
233
+ # [Visibility on new pages]
234
+ # You can also set this addition flag that controls the visibility of
235
+ # a layer on newly created pages.
236
+ # - {LAYER_USES_DEFAULT_VISIBILITY_ON_NEW_PAGES}: +0x0000+
237
+ # - {LAYER_IS_VISIBLE_ON_NEW_PAGES}: +0x0010+
238
+ # - {LAYER_IS_HIDDEN_ON_NEW_PAGES}: +0x0020+
200
239
  #
201
240
  # The default visibility for a layer is set by either
202
- # <code>LAYER_VISIBLE_BY_DEFAULT</code> or
203
- # <code>LAYER_HIDDEN_BY_DEFAULT</code>. This is what will be used when a page
241
+ # {LAYER_VISIBLE_BY_DEFAULT} or
242
+ # {LAYER_HIDDEN_BY_DEFAULT}. This is what will be used when a page
204
243
  # does not contain the visibility state of a layer.
205
244
  #
206
245
  # The remaining flags control the visibility of the layer for new pages.
@@ -212,8 +251,7 @@ class Sketchup::Layer < Sketchup::Entity
212
251
  # hidden_by_default = (layer.page_behavior & LAYER_HIDDEN_BY_DEFAULT) ==
213
252
  # LAYER_HIDDEN_BY_DEFAULT
214
253
  #
215
- # @return pagebehavior - an integer representing the current
216
- # behavior of the layer.
254
+ # @return [Integer] an integer representing the current behavior of the layer.
217
255
  #
218
256
  # @version SketchUp 6.0
219
257
  def page_behavior
@@ -226,11 +264,25 @@ class Sketchup::Layer < Sketchup::Entity
226
264
  # visibility of the layer is used.
227
265
  #
228
266
  # The behavior is composed of a combination of these flags:
229
- # [+LAYER_VISIBLE_BY_DEFAULT: 0x0000+]
230
- # [+LAYER_HIDDEN_BY_DEFAULT: 0x0001+]
231
- # [+LAYER_USES_DEFAULT_VISIBILITY_ON_NEW_PAGES: 0x0000+]
232
- # [+LAYER_IS_VISIBLE_ON_NEW_PAGES: 0x0010+]
233
- # [+LAYER_IS_HIDDEN_ON_NEW_PAGES: 0x0020+]
267
+ #
268
+ # [Default visibility]
269
+ # These flags are used to set the value of {#page_behavior}. A page keeps
270
+ # a list of layers that do not have their default behavior. If a layer
271
+ # is not in that list, then it is set to its default visibility which
272
+ # is determined by one of these flags.
273
+ # - {LAYER_VISIBLE_BY_DEFAULT}: +0x0000+
274
+ # - {LAYER_HIDDEN_BY_DEFAULT}: +0x0001+
275
+ #
276
+ # [Visibility on new pages]
277
+ # You can also set this addition flag that controls the visibility of
278
+ # a layer on newly created pages.
279
+ # - {LAYER_USES_DEFAULT_VISIBILITY_ON_NEW_PAGES}: +0x0000+
280
+ # - {LAYER_IS_VISIBLE_ON_NEW_PAGES}: +0x0010+
281
+ # - {LAYER_IS_HIDDEN_ON_NEW_PAGES}: +0x0020+
282
+ #
283
+ # @bug Prior to SketchUp 2014 the +LAYER_HIDDEN_BY_DEFAULT+ flag
284
+ # would trigger the validation check in SketchUp that would reset the
285
+ # {#page_behavior} of the layer.
234
286
  #
235
287
  # @example
236
288
  # layers = Sketchup.active_model.layers
@@ -238,44 +290,35 @@ class Sketchup::Layer < Sketchup::Entity
238
290
  # behavior = LAYER_HIDDEN_BY_DEFAULT | LAYER_IS_HIDDEN_ON_NEW_PAGES
239
291
  # layer.page_behavior = behavior
240
292
  #
241
- # @note Prior to SketchUp 2014 the +LAYER_HIDDEN_BY_DEFAULT+ flag
242
- # would trigger the validation check in SketchUp that would reset the
243
- # {#page_behavior} of the layer.
244
- #
245
293
  # @param [Integer] page_behavior
246
294
  #
247
- # @return [Integer]
248
- #
249
295
  # @version SketchUp 6.0
250
296
  def page_behavior=(page_behavior)
251
297
  end
252
298
 
253
- # The visible= method is used to set if the layer is visible.
299
+ # The {#visible=} method is used to set if the layer is visible.
254
300
  #
255
301
  # @example
256
302
  # model = Sketchup.active_model
257
303
  # layers = model.layers
258
- # new_layer = layers.add "test layer"
304
+ # layer = layers.add('Hello World')
305
+ # layer.visible = false
259
306
  #
260
- # # Hide the layer.
261
- # new_layer.visible = false
262
- #
263
- # @param is_visible
264
- # The new visibility setting.
307
+ # @param [Boolean] visible
265
308
  #
266
309
  # @version SketchUp 6.0
267
- def visible=(is_visible)
310
+ def visible=(visible)
268
311
  end
269
312
 
270
- # The visible? method is used to determine if the layer is visible.
313
+ # The {#visible?} method is used to determine if the layer is visible.
271
314
  #
272
315
  # @example
273
316
  # model = Sketchup.active_model
274
317
  # layers = model.layers
275
- # new_layer = layers.add "test layer"
276
- # UI.messagebox(new_layer.visible?)
318
+ # layer = layers.add('Hello World')
319
+ # layer.visible? # Returns: true
277
320
  #
278
- # @return [Boolean] true if the layer is visible
321
+ # @return [Boolean]
279
322
  #
280
323
  # @version SketchUp 6.0
281
324
  def visible?