Skip to content

Commit 88de2db

Browse files
committed
Merge branch 'master' into staging
2 parents 56d5ac3 + 31a3653 commit 88de2db

10 files changed

Lines changed: 191 additions & 167 deletions

File tree

lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinitions.rb

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def index(auto_text)
129129
# @version LayOut 2018
130130
def length
131131
end
132+
alias_method :size, :length
132133

133134
# The {#remove} method removes an {Layout::AutoTextDefinition} from the
134135
# {Layout::Document}.
@@ -170,17 +171,4 @@ def length
170171
def remove(*args)
171172
end
172173

173-
# The {#length} method returns the number of {Layout::AutoTextDefinition}s.
174-
#
175-
# @example
176-
# doc = Layout::Document.open("C:/path/to/document.layout")
177-
# auto_texts = doc.auto_text_definitions
178-
# num_auto_texts = auto_texts.length
179-
#
180-
# @return [Integer]
181-
#
182-
# @version LayOut 2018
183-
def size
184-
end
185-
186174
end

lib/sketchup-api-stubs/stubs/Layout/Entities.rb

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def each(flags = {})
108108
# @version LayOut 2018
109109
def length
110110
end
111+
alias_method :size, :length
111112

112113
# The {#reverse_each} method iterates through all of the {Layout::Entity}s in
113114
# reverse order. When iterating over a {Layout::LayerInstance}'s
@@ -139,17 +140,4 @@ def length
139140
def reverse_each(*args)
140141
end
141142

142-
# The {#length} method returns the number of {Layout::Entity}s.
143-
#
144-
# @example
145-
# doc = Layout::Document.open("C:/path/to/document.layout")
146-
# entities = doc.shared_entities
147-
# num_entities = entities.length
148-
#
149-
# @return [Integer]
150-
#
151-
# @version LayOut 2018
152-
def size
153-
end
154-
155143
end

lib/sketchup-api-stubs/stubs/Layout/Layers.rb

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def index(layer)
153153
# @version LayOut 2018
154154
def length
155155
end
156+
alias_method :size, :length
156157

157158
# The {#remove} method deletes the given {Layout::Layer} from the
158159
# {Layout::Document}.
@@ -216,17 +217,4 @@ def remove(*args)
216217
def reorder(layer, new_index)
217218
end
218219

219-
# The {#length} method returns the number of {Layout::Layer}s.
220-
#
221-
# @example
222-
# doc = Layout::Document.open("C:/path/to/document.layout")
223-
# layers = doc.layers
224-
# num_layers = layers.length
225-
#
226-
# @return [Integer]
227-
#
228-
# @version LayOut 2018
229-
def size
230-
end
231-
232220
end

lib/sketchup-api-stubs/stubs/Layout/Pages.rb

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ def initial=(page)
142142
# @version LayOut 2018
143143
def length
144144
end
145+
alias_method :size, :length
145146

146147
# The {#remove} method deletes the given {Layout::Page} from the
147148
# {Layout::Document}.
@@ -200,17 +201,4 @@ def remove(page)
200201
def reorder(page, new_index)
201202
end
202203

203-
# The {#length} method returns the number of {Layout::Page}s.
204-
#
205-
# @example
206-
# doc = Layout::Document.open("C:/path/to/document.layout")
207-
# pages = doc.pages
208-
# num_pages = pages.length
209-
#
210-
# @return [Integer]
211-
#
212-
# @version LayOut 2018
213-
def size
214-
end
215-
216204
end

lib/sketchup-api-stubs/stubs/Sketchup/Layer.rb

Lines changed: 72 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
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
@@ -15,12 +16,14 @@
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
2629
class 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

Comments
 (0)