Class: Sketchup::Layer
Relationships | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Entity
|
|
Instance Chain:
self,
Comparable,
Entity
|
|
Inherits: |
Sketchup::Entity
|
Overview
As of SketchUp 2020 “Layers” were renamed to “Tags” in the ::UI
. The API retains the use of “Layer” for compatibility and is synonymous with “Tag”.
The Layer class contains methods modifying and extracting information for a layer.
By default, a SketchUp model has one layer, Layer
0 (Named “Untagged” in the ::UI
since SketchUp 2020), which is the base layer. You can’t delete or rename Layer
0. Unlike certain other CAD software packages, entities associated with different layers in SketchUp still intersect with each other. (If you want collections of entities to not intersect, place them in Groups instead.)
Layers
are commonly used to organize your model and control the visibility of related groups and components. For example, you could make all of your wall and roof entities different groups, associate layers with those groups, and then hide those layers so as to display just the floor plan in the model.
Instance Attribute Summary
-
#color ⇒ Sketchup::Color
rw
The #color method is used to retrieve the color of the layer.
-
#color=(color)
rw
The #color= method is used to set the name of a layer.
-
#folder ⇒ Sketchup::LayerFolder?
rw
The #folder method is used to return the parent layer folder of a layer.
-
#folder=(parent)
rw
The #folder= method is used to set the parent layer folder of a layer.
-
#line_style ⇒ Sketchup::LineStyle?
rw
The #line_style method retrieves the line style on this layer.
-
#line_style=(line_style) ⇒ Sketchup::Layer
rw
The #line_style= method lets you set a specific line style to a layer.
-
#name ⇒ String
rw
The #name method is used to retrieve the name of the layer.
-
#name=(name)
rw
The #name= method is used to set the name of a layer.
-
#page_behavior ⇒ Integer
rw
The #page_behavior method is used to retrieve the visibility behavior of the layer for new pages and existing pages.
-
#page_behavior=(page_behavior)
rw
The #page_behavior= method is used to control the layer’s visibility behavior on existing and new pages.
-
#visible=(visible)
rw
The #visible= method is used to set if the layer is visible.
-
#visible? ⇒ Boolean
rw
The #visible? method is used to determine if the layer is visible.
Entity
- Inherited
Instance Method Summary
-
#<=>(layer2) ⇒ Integer
The #<=> method is used to compare two layers based on their names.
-
#==(other)
The #== method is used to determine if two layers are the same.
-
#display_name ⇒ String
The #display_name method is used to retrieve the display name of the layer.
Entity
- Inherited
#add_observer | The add_observer method is used to add an observer to the current object. |
#attribute_dictionaries | The attribute_dictionaries method is used to retrieve the |
#attribute_dictionary | The attribute_dictionary method is used to retrieve an attribute dictionary with a given name that is attached to an |
#delete_attribute | The |
#entityID | The entityID method is used to retrieve a unique ID assigned to an entity. |
#get_attribute | The |
#inspect | The |
#model | The model method is used to retrieve the model for the entity. |
#parent | The parent method is used to retrieve the parent of the entity. |
#persistent_id | The |
#remove_observer | The remove_observer method is used to remove an observer from the current object. |
#set_attribute | The set attribute is used to set the value of an attribute in an attribute dictionary with the given name. |
#to_s | The |
#typename | The typename method retrieves the type of the entity, which will be a string such as “Face”, “Edge”, or “Group”. |
Instance Attribute Details
#color ⇒ Sketchup::Color (rw)
The #color
method is used to retrieve the color of the layer.
#color=(color) (rw)
The #color=
method is used to set the name of a layer.
#folder ⇒ Sketchup::LayerFolder? (rw)
The #folder
method is used to return the parent layer folder of a layer.
#folder=(parent) (rw)
The #folder=
method is used to set the parent layer folder of a layer.
This will trigger onParentFolderChanged
in normal cases and onLayerChanged
during undo/redo.
#line_style ⇒ Sketchup::LineStyle? (rw)
The #line_style
method retrieves the line style on this layer.
#line_style=(line_style) ⇒ Layer
(rw)
The #line_style=
method lets you set a specific line style to a layer
#name ⇒ String (rw)
The #name
method is used to retrieve the name of the layer.
#name=(name) (rw)
The #name=
method is used to set the name of a layer.
#page_behavior ⇒ Integer
(rw)
The #page_behavior
method is used to retrieve the visibility behavior of the layer for new pages and existing pages. For example, you may want your layer to be visible or hidden by default in any new pages (aka Scenes) created by the user.
A page keeps a list of layers that do not have their default behavior. If a layer is not in that list, then it is set to its default visibility determined by one of these values:
The behaviour is composed of a combination of these flags:
- Default visibility
-
These flags are used to set the value of
#page_behavior
. A page keeps a list of layers that do not have their default behavior. If a layer is not in that list, then it is set to its default visibility which is determined by one of these flags.-
LAYER_VISIBLE_BY_DEFAULT:
0x0000
-
LAYER_HIDDEN_BY_DEFAULT:
0x0001
-
- Visibility on new pages
-
You can also set this addition flag that controls the visibility of a layer on newly created pages.
-
LAYER_IS_VISIBLE_ON_NEW_PAGES:
0x0010
-
LAYER_IS_HIDDEN_ON_NEW_PAGES:
0x0020
The default visibility for a layer is set by either LAYER_VISIBLE_BY_DEFAULT or LAYER_HIDDEN_BY_DEFAULT. This is what will be used when a page does not contain the visibility state of a layer.
The remaining flags control the visibility of the layer for new pages.
#page_behavior=(page_behavior) (rw)
The #page_behavior=
method is used to control the layer’s visibility behavior on existing and new pages.
When you Update a page (as opposed to creating a new page) the current visibility of the layer is used.
The behavior is composed of a combination of these flags:
- Default visibility
-
These flags are used to set the value of #page_behavior. A page keeps a list of layers that do not have their default behavior. If a layer is not in that list, then it is set to its default visibility which is determined by one of these flags.
-
LAYER_VISIBLE_BY_DEFAULT:
0x0000
-
LAYER_HIDDEN_BY_DEFAULT:
0x0001
-
- Visibility on new pages
-
You can also set this addition flag that controls the visibility of a layer on newly created pages.
-
LAYER_IS_VISIBLE_ON_NEW_PAGES:
0x0010
-
LAYER_IS_HIDDEN_ON_NEW_PAGES:
0x0020
#visible=(visible) (rw)
The #visible=
method is used to set if the layer is visible.
#visible? ⇒ Boolean
(rw)
The #visible?
method is used to determine if the layer is visible.
Instance Method Details
#<=>(layer2) ⇒ Integer
The #<=>
method is used to compare two layers based on their names. This enables the Ruby Array#sort method to sort SketchUp layers.
#==(other)
The #==
method is used to determine if two layers are the same.
#display_name ⇒ String
The #display_name
method is used to retrieve the display name of the layer.