Class: ModraUp::Layers
- Inherits:
-
ModraUp::Entity
- Object
- ModraUp::Entity
- ModraUp::Layers
- Includes:
- Enumerable
Overview
Model layer table. Obtain it from ModraUp::Model#layers. Index 0 is the default "Layer0".
Instance Method Summary # collapse
-
#add ⇒ ModraUp::Layer
Add a layer. If a layer with the same name already exists, return the existing object. If the name is omitted, use #unique_name (base name + "Tag").
-
#add_folder(name) ⇒ ModraUp::LayerFolder
Create a folder under the root of the Layers table, or move an existing folder to the root. Folder names can be duplicated, but they must not be empty.
-
#remove(layer) ⇒ Boolean
Remove layers. Cannot delete Layer0. Geometry defaults to being attached to Layer0; if remove_geometry is true, edges and faces on the layer are deleted.
-
#remove_folder(folder) ⇒ nil
Remove the folder from the root of the layers table. The sub-content moves up one level.
-
#purge_unused ⇒ Integer
Remove layers that are not referenced by any geometry and are not the current layer.
-
#[] ⇒ ModraUp::Layer, nil
Retrieve a layer by name or index. Returns nil if not found.
-
#size ⇒ Integer
The number of layers (including the default Layer0).
-
#each ⇒ self, Enumerator
Iterate through layers.
-
#each_layer ⇒ self, Enumerator
Iterate through the layers that are not in the folder.
-
#layers ⇒ Array<ModraUp::Layer>
Layers not in the folder.
-
#count_layers ⇒ Integer
The number of layers not in the folder.
-
#folders ⇒ Array<ModraUp::LayerFolder>
Direct subfolders under the root of the Layers table.
-
#count_folders ⇒ Integer
Number of folders directly under the root.
-
#each_folder ⇒ self, Enumerator
Iterate through direct subfolders.
-
#purge_unused_folders ⇒ Integer
Remove empty folders that have no subfolders or layers.
-
#unique_name ⇒ String
Returns a unique name that is not yet in use in the table. Omit the base name and it will use "Tag" (since SketchUp 2020).
-
#parent ⇒ ModraUp::Model
The model it belongs to.
-
#add_observer(observer) ⇒ Boolean
Register a ModraUp::LayersObserver. Adding the same object a second time returns false.
-
#remove_observer(observer) ⇒ Boolean
Remove layer table observers.
Inherited from ModraUp::Entity
-
#typename ⇒ String
Type name (e.g., Face / Edge / Group).
-
#entityID ⇒ Integer
Entity ID within the current session: A small integer starting from 1 that increments and remains constant for the lifetime of the entity, unchanged by undo/redo operations. This ID is not preserved when saving the file; it will be renumbered upon reopening the model. For cross-session identification, use #persistent_id. Copied entities will receive new IDs.
-
#persistent_id ⇒ Integer
Number assigned with the model: A unique, incrementing small integer starting from 1 that persists across model saves and reloads, independent of #entityID. Copied entities receive new numbers, and deleted entities do not reuse their numbers. Edges, faces, vertices, curves, groups, component instances/definitions, dimensions, leader lines/points, section planes, materials, layers, layer folders, and drawing sheets have assigned numbers; all others (rings, EdgeUses, attribute dictionaries, line types, sets, etc.) return 0.
-
#model ⇒ ModraUp::Model
The model it belongs to.
-
#to_s ⇒ String
String form. Returns "#<Deleted Entity>” when the entity has been deleted.
-
#inspect ⇒ String
Same as #to_s.
-
#attribute_dictionaries ⇒ ModraUp::AttributeDictionaries, nil
Collection of attribute dictionaries. Returns nil (evaluates to false) if there are no dictionaries.
-
#attribute_dictionary(name) ⇒ ModraUp::AttributeDictionary, nil
Retrieve an attribute dictionary by name. If none exists, return nil; if create is true, create an empty dictionary. ModraUp::Loop / ModraUp::EdgeUse / ModraUp::Curve always return nil.
-
#valid? ⇒ Boolean
Returns true if the entity is valid, meaning it has not been deleted from the model. Revoked entities are false; even if new geometry is drawn occupying its original position, this object remains an invalid entity (still false). Repeating the action to restore it makes it valid again.
-
#deleted? ⇒ Boolean
Opposite of #valid?.
-
#set_attribute(dict_name, key, value) ⇒ Object
Write attribute values. Materials, groups, component instances, faces, and edges are supported. When dict_name and key are Symbols, they are converted to strings. The type of data written is the same type that will be read back.
-
#get_attribute(dict_name, key, default = nil) ⇒ Object
Read the attribute. If dict_name and key are Symbols, convert them to strings (similar to SketchUp). If the dictionary or key does not exist, return default. The return value type is the same as what is written by #set_attribute.
-
#delete_attribute(dict_name) ⇒ Boolean
Delete a key, or delete the entire dictionary when the key is omitted.
Instance Method Details
layers.add ⇒ ModraUp::Layerlayers.add(name) ⇒ ModraUp::Layer
Add a layer. If a layer with the same name already exists, return the existing object. If the name is omitted, use #unique_name (base name + "Tag").
layers.add_folder(name) ⇒ ModraUp::LayerFolderlayers.add_folder(folder) ⇒ ModraUp::LayerFolder
Create a folder under the root of the Layers table, or move an existing folder to the root. Folder names can be duplicated, but they must not be empty.
layers.remove(layer) ⇒ Booleanlayers.remove(layer, remove_geometry) ⇒ Boolean
Remove layers. Cannot delete Layer0. Geometry defaults to being attached to Layer0; if remove_geometry is true, edges and faces on the layer are deleted.
layers.remove_folder(folder) ⇒ nil
Remove the folder from the root of the layers table. The sub-content moves up one level.
layers.purge_unused ⇒ Integer
Remove layers that are not referenced by any geometry and are not the current layer.
layers[name] ⇒ ModraUp::Layer, nillayers[index] ⇒ ModraUp::Layer, nil
Retrieve a layer by name or index. Returns nil if not found.
layers.size ⇒ Integer
The number of layers (including the default Layer0).
layers.each {|layer| } ⇒ selflayers.each ⇒ Enumerator
Iterate through layers.
layers.each_layer {|layer| } ⇒ selflayers.each_layer ⇒ Enumerator
Iterate through the layers that are not in the folder.
layers.layers ⇒ Array<ModraUp::Layer>
Layers not in the folder.
layers.count_layers ⇒ Integer
The number of layers not in the folder.
layers.folders ⇒ Array<ModraUp::LayerFolder>
Direct subfolders under the root of the Layers table.
layers.count_folders ⇒ Integer
Number of folders directly under the root.
layers.each_folder {|folder| } ⇒ selflayers.each_folder ⇒ Enumerator
Iterate through direct subfolders.
layers.purge_unused_folders ⇒ Integer
Remove empty folders that have no subfolders or layers.
layers.unique_name ⇒ Stringlayers.unique_name(base_name) ⇒ String
Returns a unique name that is not yet in use in the table. Omit the base name and it will use "Tag" (since SketchUp 2020).
layers.parent ⇒ ModraUp::Model
The model it belongs to.
layers.add_observer(observer) ⇒ Boolean
Register a ModraUp::LayersObserver. Adding the same object a second time returns false.
layers.remove_observer(observer) ⇒ Boolean
Remove layer table observers.