Class: Layout::Entity
- Inherits:
-
Object
- Object
- Layout::Entity
Overview
The base class for drawing entities. Objects created using Layout::Rectangle.new and similar methods do not belong to any document until added with Layout::Document#add_entity. Before addition, any set properties are written at the time of joining. After joining, each modification is a step in the undo history; accessing the object after deletion raises a TypeError, and undoing brings it back to a usable state.
Instance Method Summary # collapse
-
#bounds ⇒ Geom::Bounds2d
The bounding box after rotation, in paper inches.
-
#untransformed_bounds ⇒ Geom::Bounds2d
Unrotated bounds (x, y, width, height), paper inches.
-
#untransformed_bounds= ⇒ Geom::Bounds2d
Modify position and size, with one undo step. The rules are the same as for the layout: the view preserves scale on resize (default) when Layout::SketchUpModel#preserve_scale_on_resize? is true, otherwise it scales by height only; dimensions and leaders only move and do not scale. If they extend beyond the paper edge, they are clipped back within the paper.
-
#style ⇒ Layout::Style
A copy of the current style. Modifying the copy does not affect the object; use #style= to apply the changes.
-
#style= ⇒ Layout::Style
Apply the style, undoing one step. Only apply properties relevant to the object type (e.g., text ignoring line type).
-
#page ⇒ Layout::Page, nil
The current page; objects on shared layers or those not yet added to the document are nil.
-
#document ⇒ Layout::Document, nil
Belongs to a Layout::Entity document; is nil if not added yet.
-
#on_shared_layer? ⇒ Boolean
Returns true if the entity is on a shared layer.
-
#layer_instance ⇒ Layout::LayerInstance, nil
The layer it resides on; nil if not added yet.
-
#move_to_layer(layer, pages = nil) ⇒ Layout::Entity
Move to another layer, one undo step. Objects on a shared layer remain on their associated page when moved to a regular layer.
-
#rotation ⇒ Float
Rotation angle around the bounding box center (degrees).
-
#rotation= ⇒ Numeric
Rotate around the bounding box center, one step in undo. Dimensions and leaders do not accept rotation (they follow their endpoints).
-
#get_attribute(dictionary, key, default = nil) ⇒ Object
Read plugin data on the object. Plugins can use this to identify objects they generate, such as re-creating automatic leader and dimension annotations.
-
#set_attribute(dictionary, key, value) ⇒ Object
Save plugin data on the object with a single undo step. Values can only be types that JSON can represent (nil, true, false, numbers, strings, Array, Hash), and a single object should not exceed 64 KB.
-
#delete_attribute(dictionary) ⇒ Boolean
Delete a key or an entire dictionary.
-
#attribute_dictionary(name, create = false) ⇒ Hash, nil
A copy of a dictionary.
-
#locked? ⇒ Object
Unsupported: OpenSu does not support object-level locking (please lock the layer).
-
#locked= ⇒ Object
Unsupported: OpenSu does not support object-level locking (please lock the layer).
-
#transform!(transformation) ⇒ Object
Unsupported: OpenSu does not support Geom::Transformation2d. For translation, use #untransformed_bounds=, and for rotation, use #rotation=.
-
#group ⇒ Object
Does not support: OpenSu drawings cannot be grouped.
-
#== ⇒ Boolean
Returns whether the two references identify the same drawing entity.
-
#eql?(other) ⇒ Boolean
Like #==, used as a key in a Hash.
-
#hash ⇒ Integer
Hash value consistent with #eql?.
-
#inspect ⇒ String
A brief description.
Instance Method Details
entity.bounds ⇒ Geom::Bounds2d
The bounding box after rotation, in paper inches.
entity.untransformed_bounds ⇒ Geom::Bounds2d
Unrotated bounds (x, y, width, height), paper inches.
entity.untransformed_bounds = bounds
Modify position and size, with one undo step. The rules are the same as for the layout: the view preserves scale on resize (default) when Layout::SketchUpModel#preserve_scale_on_resize? is true, otherwise it scales by height only; dimensions and leaders only move and do not scale. If they extend beyond the paper edge, they are clipped back within the paper.
entity.style ⇒ Layout::Style
A copy of the current style. Modifying the copy does not affect the object; use #style= to apply the changes.
entity.style = style
Apply the style, undoing one step. Only apply properties relevant to the object type (e.g., text ignoring line type).
entity.page ⇒ Layout::Page, nil
The current page; objects on shared layers or those not yet added to the document are nil.
entity.document ⇒ Layout::Document, nil
Belongs to a Layout::Entity document; is nil if not added yet.
entity.layer_instance ⇒ Layout::LayerInstance, nil
The layer it resides on; nil if not added yet.
entity.move_to_layer(layer, pages = nil) ⇒ Layout::Entity
Move to another layer, one undo step. Objects on a shared layer remain on their associated page when moved to a regular layer.
entity.rotation ⇒ Float
Rotation angle around the bounding box center (degrees).
entity.rotation = degrees
Rotate around the bounding box center, one step in undo. Dimensions and leaders do not accept rotation (they follow their endpoints).
entity.get_attribute(dictionary, key, default = nil) ⇒ Object
Read plugin data on the object. Plugins can use this to identify objects they generate, such as re-creating automatic leader and dimension annotations.
entity.set_attribute(dictionary, key, value) ⇒ Object
Save plugin data on the object with a single undo step. Values can only be types that JSON can represent (nil, true, false, numbers, strings, Array, Hash), and a single object should not exceed 64 KB.
entity.delete_attribute(dictionary) ⇒ Booleanentity.delete_attribute(dictionary, key) ⇒ Boolean
Delete a key or an entire dictionary.
entity.attribute_dictionary(name, create = false) ⇒ Hash, nil
A copy of a dictionary.
entity.locked? ⇒ raises
Unsupported: OpenSu does not support object-level locking (please lock the layer).
entity.locked = locked ⇒ raises
Unsupported: OpenSu does not support object-level locking (please lock the layer).
entity.transform!(transformation) ⇒ raises
Unsupported: OpenSu does not support Geom::Transformation2d. For translation, use #untransformed_bounds=, and for rotation, use #rotation=.
entity.group ⇒ raises
Does not support: OpenSu drawings cannot be grouped.
entity == other ⇒ Boolean
Returns whether the two references identify the same drawing entity.
entity.eql?(other) ⇒ Boolean
Like #==, used as a key in a Hash.
entity.hash ⇒ Integer
Hash value consistent with #eql?.
entity.inspect ⇒ String
A brief description.