44# The Layer class contains methods modifying and extracting information for a
55# layer.
66#
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
89# layer. You can't delete or rename Layer 0. Unlike certain other CAD software
910# packages, entities associated with different layers in SketchUp still
1011# intersect with each other. (If you want collections of entities to not
1516# wall and roof entities different groups, associate layers with those groups,
1617# and then hide those layers so as to display just the floor plan in the model.
1718#
18- # You can programatically create a new layer by calling the Layers.add method.
19- #
2019# @example
2120# model = Sketchup.active_model
2221# 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".
2427#
2528# @version SketchUp 6.0
2629class Sketchup ::Layer < Sketchup ::Entity
@@ -31,8 +34,8 @@ class Sketchup::Layer < Sketchup::Entity
3134
3235 # Instance Methods
3336
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.
3639 #
3740 # @example
3841 # model = Sketchup.active_model
@@ -42,62 +45,53 @@ class Sketchup::Layer < Sketchup::Entity
4245 # layer2 = layers[1]
4346 # status = layer1 <=> layer2
4447 #
45- # @param layer2
46- # A Layer object.
48+ # @param [Sketchup::Layer] layer2
4749 #
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.
5152 #
5253 # @version SketchUp 6.0
5354 def <=>( layer2 )
5455 end
5556
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.
5758 #
5859 # @example
5960 # model = Sketchup.active_model
6061 # 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
6765 #
68- # @return status - true if layer1 and layer2 are equal. false if
69- # layer1 and layer2 are not equal.
66+ # @param [Object] other
7067 #
7168 # @version SketchUp 6.0
72- def ==( layer2 )
69+ def ==( other )
7370 end
7471
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.
7673 #
7774 # @example
7875 # model = Sketchup.active_model
7976 # layers = model.layers
8077 # new_layer = layers.add('Test layer')
8178 # color = new_layer.color
8279 #
83- # @return color - the color of the Layer object
80+ # @return [Sketchup::Color]
8481 #
8582 # @version SketchUp 2014
8683 def color
8784 end
8885
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.
9087 #
9188 # @example
9289 # model = Sketchup.active_model
9390 # layers = model.layers
9491 # new_layer = layers.add('Test layer')
9592 # new_layer.color = Sketchup::Color.new(192, 0, 0)
9693 #
97- # @param color
98- # The new color for the Layer object.
99- #
100- # @return color
94+ # @param [Sketchup::Color] color
10195 #
10296 # @version SketchUp 2014
10397 def color = ( color )
@@ -111,7 +105,7 @@ def color=(color)
111105 # new_layer = layers.add ("test layer")
112106 # name = new_layer.display_name
113107 #
114- # @return [String] the display name of the Layer object
108+ # @return [String]
115109 #
116110 # @see #name
117111 #
@@ -161,24 +155,21 @@ def line_style=(line_style)
161155 def name
162156 end
163157
164- # The name= method is used to set the name of a layer.
158+ # The {# name=} method is used to set the name of a layer.
165159 #
166160 # @example
167161 # model = Sketchup.active_model
168162 # layers = model.layers
169163 # new_layer = layers.add "test layer"
170164 # name = new_layer.name = "new test layer"
171165 #
172- # @param name
173- # The new name for the Layer object.
174- #
175- # @return name - the newly set name
166+ # @param [String] name
176167 #
177168 # @version SketchUp 6.0
178169 def name = ( name )
179170 end
180171
181- # The page_behavior method is used to retrieve the visibility behavior of the
172+ # The {# page_behavior} method is used to retrieve the visibility behavior of the
182173 # layer for new pages and existing pages. For example, you may want your layer
183174 # to be visible or hidden by default in any new pages (aka Scenes) created by
184175 # the user.
@@ -188,15 +179,25 @@ def name=(name)
188179 # determined by one of these values:
189180 #
190181 # The behaviour is composed of a combination of these flags:
191- # - LAYER_VISIBLE_BY_DEFAULT: 0x0000
192- # - LAYER_HIDDEN_BY_DEFAULT: 0x0001
193- # - LAYER_USES_DEFAULT_VISIBILITY_ON_NEW_PAGES: 0x0000
194- # - LAYER_IS_VISIBLE_ON_NEW_PAGES: 0x0010
195- # - LAYER_IS_HIDDEN_ON_NEW_PAGES: 0x0020
182+ #
183+ # [Default visibility]
184+ # These flags are used to set the value of {#page_behavior}. A page keeps
185+ # a list of layers that do not have their default behavior. If a layer
186+ # is not in that list, then it is set to its default visibility which
187+ # is determined by one of these flags.
188+ # - {LAYER_VISIBLE_BY_DEFAULT}: +0x0000+
189+ # - {LAYER_HIDDEN_BY_DEFAULT}: +0x0001+
190+ #
191+ # [Visibility on new pages]
192+ # You can also set this addition flag that controls the visibility of
193+ # a layer on newly created pages.
194+ # - {LAYER_USES_DEFAULT_VISIBILITY_ON_NEW_PAGES}: +0x0000+
195+ # - {LAYER_IS_VISIBLE_ON_NEW_PAGES}: +0x0010+
196+ # - {LAYER_IS_HIDDEN_ON_NEW_PAGES}: +0x0020+
196197 #
197198 # The default visibility for a layer is set by either
198- # <code> LAYER_VISIBLE_BY_DEFAULT</code> or
199- # <code> LAYER_HIDDEN_BY_DEFAULT</code> . This is what will be used when a page
199+ # { LAYER_VISIBLE_BY_DEFAULT} or
200+ # { LAYER_HIDDEN_BY_DEFAULT} . This is what will be used when a page
200201 # does not contain the visibility state of a layer.
201202 #
202203 # The remaining flags control the visibility of the layer for new pages.
@@ -208,8 +209,7 @@ def name=(name)
208209 # hidden_by_default = (layer.page_behavior & LAYER_HIDDEN_BY_DEFAULT) ==
209210 # LAYER_HIDDEN_BY_DEFAULT
210211 #
211- # @return pagebehavior - an integer representing the current
212- # behavior of the layer.
212+ # @return [Integer] an integer representing the current behavior of the layer.
213213 #
214214 # @version SketchUp 6.0
215215 def page_behavior
@@ -222,56 +222,61 @@ def page_behavior
222222 # visibility of the layer is used.
223223 #
224224 # The behavior is composed of a combination of these flags:
225- # [+LAYER_VISIBLE_BY_DEFAULT: 0x0000+]
226- # [+LAYER_HIDDEN_BY_DEFAULT: 0x0001+]
227- # [+LAYER_USES_DEFAULT_VISIBILITY_ON_NEW_PAGES: 0x0000+]
228- # [+LAYER_IS_VISIBLE_ON_NEW_PAGES: 0x0010+]
229- # [+LAYER_IS_HIDDEN_ON_NEW_PAGES: 0x0020+]
225+ #
226+ # [Default visibility]
227+ # These flags are used to set the value of {#page_behavior}. A page keeps
228+ # a list of layers that do not have their default behavior. If a layer
229+ # is not in that list, then it is set to its default visibility which
230+ # is determined by one of these flags.
231+ # - {LAYER_VISIBLE_BY_DEFAULT}: +0x0000+
232+ # - {LAYER_HIDDEN_BY_DEFAULT}: +0x0001+
233+ #
234+ # [Visibility on new pages]
235+ # You can also set this addition flag that controls the visibility of
236+ # a layer on newly created pages.
237+ # - {LAYER_USES_DEFAULT_VISIBILITY_ON_NEW_PAGES}: +0x0000+
238+ # - {LAYER_IS_VISIBLE_ON_NEW_PAGES}: +0x0010+
239+ # - {LAYER_IS_HIDDEN_ON_NEW_PAGES}: +0x0020+
240+ #
241+ # @bug 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.
230244 #
231245 # @example
232246 # layers = Sketchup.active_model.layers
233247 # layer = layers.add('Test Layer')
234248 # behavior = LAYER_HIDDEN_BY_DEFAULT | LAYER_IS_HIDDEN_ON_NEW_PAGES
235249 # layer.page_behavior = behavior
236250 #
237- # @note Prior to SketchUp 2014 the +LAYER_HIDDEN_BY_DEFAULT+ flag
238- # would trigger the validation check in SketchUp that would reset the
239- # {#page_behavior} of the layer.
240- #
241251 # @param [Integer] page_behavior
242252 #
243- # @return [Integer]
244- #
245253 # @version SketchUp 6.0
246254 def page_behavior = ( page_behavior )
247255 end
248256
249- # The visible= method is used to set if the layer is visible.
257+ # The {# visible=} method is used to set if the layer is visible.
250258 #
251259 # @example
252260 # model = Sketchup.active_model
253261 # layers = model.layers
254- # new_layer = layers.add "test layer"
262+ # layer = layers.add('Hello World')
263+ # layer.visible = false
255264 #
256- # # Hide the layer.
257- # new_layer.visible = false
258- #
259- # @param is_visible
260- # The new visibility setting.
265+ # @param [Boolean] visible
261266 #
262267 # @version SketchUp 6.0
263- def visible = ( is_visible )
268+ def visible = ( visible )
264269 end
265270
266- # The visible? method is used to determine if the layer is visible.
271+ # The {# visible?} method is used to determine if the layer is visible.
267272 #
268273 # @example
269274 # model = Sketchup.active_model
270275 # layers = model.layers
271- # new_layer = layers.add "test layer"
272- # UI.messagebox(new_layer. visible?)
276+ # layer = layers.add('Hello World')
277+ # layer. visible? # Returns: true
273278 #
274- # @return [Boolean] true if the layer is visible
279+ # @return [Boolean]
275280 #
276281 # @version SketchUp 6.0
277282 def visible?
0 commit comments