Class: Layout::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/sketchup-api-stubs/stubs/Layout/Document.rb

Overview

This is the interface to a LayOut document. A Document is the 2D drawing that the user is working with, and it serves as the “entry point” for most Ruby API interactions. The Document.open method gives you a handle to a Document, and from there you can use the document-level methods to start getting information and making changes.

Examples:

# Grab a handle to an existing LayOut document.
doc = Layout::Document.open("C:/path/to/document.layout")

# Grab other handles to commonly used collections inside the model.
layers = doc.layers
pages = doc.pages
entities = doc.shared_entities

# Now that we have our handles, we can start pulling objects and making
# method calls that are useful.
first_entity = entities[0]

number_pages = pages.count

Version:

  • LayOut 2018

Constant Summary collapse

DECIMAL_CENTIMETERS =

Constants

nil
DECIMAL_FEET =

Stub value.

nil
DECIMAL_INCHES =

Stub value.

nil
DECIMAL_METERS =

Stub value.

nil
DECIMAL_MILLIMETERS =

Stub value.

nil
DECIMAL_POINTS =

Stub value.

nil
FRACTIONAL_INCHES =

Stub value.

nil
VERSION_1 =

Stub value.

nil
VERSION_2 =

Stub value.

nil
VERSION_2013 =

Stub value.

nil
VERSION_2014 =

Stub value.

nil
VERSION_2015 =

Stub value.

nil
VERSION_2016 =

Stub value.

nil
VERSION_2017 =

Stub value.

nil
VERSION_2018 =

Stub value.

nil
VERSION_2019 =

Stub value.

nil
VERSION_2020 =

Stub value.

nil
VERSION_3 =

Stub value.

nil
VERSION_CURRENT =

Stub value.

nil

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLayout::Document #initialize(template_path) ⇒ Layout::Document

The #initialize method creates a new Layout::Document. Passing a path to an existing Layout::Document will use that file as a template. The new Layout::Document won’t have a path until it is saved for the first time.

Examples:

doc = Layout::Document.new
doc2 = Layout::Document.new("/path/to/template.layout")

Overloads:

Raises:

  • (RuntimeError)

    if there was an error reading the template file

  • (ArgumentError)

    if the template file could not be found

Version:

  • LayOut 2018



210
211
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 210

def initialize(*args)
end

Class Method Details

.open(path) ⇒ Layout::Document

The open method creates a new Layout::Document by loading an existing .layout file.

Examples:

filename = File.join(ENV['Home'], 'Desktop', 'template.layout')
doc = Layout::Document.open(filename)

Parameters:

  • path (String)

    The path to the .layout file on disk.

Returns:

Raises:

  • (ArgumentError)

    if the file does not exist

Version:

  • LayOut 2018



70
71
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 70

def self.open(path)
end

Instance Method Details

#==(other) ⇒ Boolean

The #== method checks to see if the two Layout::Documents are equal. This checks whether the Ruby Objects are pointing to the same internal object.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
document = doc.pages.first.document
doc == document

Parameters:

Returns:

  • (Boolean)

Version:

  • LayOut 2018



89
90
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 89

def ==(other)
end

#add_entity(entity, layer, page) ⇒ Object #add_entity(entity, layer) ⇒ Object

The #add_entity method adds an Entity to the Layout::Document and places it on the given Layer and Page. If layer is a shared Layer then page may be ommitted. The Entity must not already belong to a Layout::Document. If the Entity is a Group, then the Group along with all of its children will be added to the Layout::Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
rect = Layout::Rectangle.new([[1, 1], [2, 2]])
all_layers = doc.layers
all_pages = doc.pages
doc.add_entity(rect, all_layers.first, all_pages.first)

Overloads:

Raises:

  • (ArgumentError)

    if no Page is passed in and layer is non-shared

  • (ArgumentError)

    if page does not belong to the Layout::Document

  • (ArgumentError)

    if layer does not belong to the Layout::Document

  • (ArgumentError)

    if entity already belongs to a Layout::Document

Version:

  • LayOut 2018



130
131
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 130

def add_entity(*args)
end

#auto_text_definitionsLayout::AutoTextDefinitions

The #auto_text_definitions method returns an array of AutoTextDefinition‘s in the Layout::Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
defs = doc.auto_text_definitions

Returns:

Version:

  • LayOut 2018



143
144
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 143

def auto_text_definitions
end

#gridLayout::Grid

The #grid method returns the Grid for a Layout::Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
grid = doc.grid

Returns:

Version:

  • LayOut 2018



155
156
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 155

def grid
end

#grid_snap_enabled=(enabled) ⇒ Object

The #grid_snap_enabled= method sets whether or not grid snap is enabled in the Layout::Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
doc.grid_snap_enabled = true

Parameters:

  • enabled (Boolean)

    true for enabled false for disabled

Version:

  • LayOut 2018



169
170
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 169

def grid_snap_enabled=(enabled)
end

#grid_snap_enabled?Boolean

The #grid_snap_enabled? method returns whether or not grid snap is enabled in the Layout::Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
enabled = doc.grid_snap_enabled?

Returns:

  • (Boolean)

Version:

  • LayOut 2018



182
183
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 182

def grid_snap_enabled?
end

#layersLayout::Layers

The #layers method returns the Layers of the Layout::Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
layers = doc.layers

Returns:

Version:

  • LayOut 2018



222
223
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 222

def layers
end

#object_snap_enabled=(enabled) ⇒ Object

The #object_snap_enabled= method enables or disables inference in the Layout::Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
doc.object_snap_enabled = false

Parameters:

  • enabled (Boolean)

    true for enabled false for disabled

Version:

  • LayOut 2018



236
237
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 236

def object_snap_enabled=(enabled)
end

#object_snap_enabled?Boolean

The #object_snap_enabled? method returns whether or not inference is enabled in the Layout::Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
enabled = doc.object_snap_enabled?

Returns:

  • (Boolean)

Version:

  • LayOut 2018



249
250
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 249

def object_snap_enabled?
end

#page_infoLayout::PageInfo

The #page_info method returns a reference to the PageInfo settings of the Layout::Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
page_info = doc.page_info

Returns:

Version:

  • LayOut 2018



262
263
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 262

def page_info
end

#pagesLayout::Pages

The #pages method returns the Pages of the Layout::Document.

@example:

doc = Layout::Document.open("C:/path/to/document.layout")
doc_pages = doc.pages

Returns:

Version:

  • LayOut 2018



275
276
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 275

def pages
end

#pathString

The #path method returns the full path of the Layout::Document file. An empty string is returned for a new Layout::Document (one which has not been saved and opened).

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
path = doc.path

Returns:

Version:

  • LayOut 2018



289
290
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 289

def path
end

#precisionFloat

The #precision method returns the precision for the Layout::Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
precision = doc.precision

Returns:

Version:

  • LayOut 2018



302
303
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 302

def precision
end

#precision=(precision) ⇒ Object

Note:

LayOut only allows for a finite set of precision values for each units setting, so it will set the precision to the closest valid setting for the specified units. See the “Units” section of LayOut’s “Document Setup” dialog for a reference of the available precisions for each units setting.

The #precision= method sets the precision for the Layout::Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
doc.precision = 0.0001

Parameters:

  • precision (Float)

    The double specifying the precision for the Layout::Document

Version:

  • LayOut 2018



321
322
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 321

def precision=(precision)
end

#remove_entity(entity) ⇒ Object

The #remove_entity method removes an Entity from the Layout::Document. If entity is a Group, then the Group and all of its children will be removed from the Layout::Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
shared_entities = doc.shared_entities
# Remove the first entity in the document
doc.remove_entity(shared_entities.first)

Parameters:

Raises:

Version:

  • LayOut 2018



340
341
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 340

def remove_entity(entity)
end

#saveObject #save(path, version = Layout::Document::VERSION_CURRENT) ⇒ Object

The #save method saves the Layout::Document to a file at the given path. Passing an empty path string will save the Layout::Document at its current path.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
# Save the model using the current Layout format
filename = File.join(ENV['Home'], 'Desktop', 'mydoc.layout')
status = doc.save(filename)
# Save the document to the current file using the current LayOut format
status = doc.save
# Save the document to the current file in LayOut 3 format
status = doc.save(Layout::Document::VERSION_3)
# Save the document in LayOut 2013 format
filename = File.join(ENV['Home'], 'Desktop', 'mydoc_v2013.layout')
status = doc.save(filename, Layout::Document::VERSION_2013)

Overloads:

  • #saveObject

    path yet

    Raises:

  • #save(path, version = Layout::Document::VERSION_CURRENT) ⇒ Object

    Parameters:

    • path (String)

      The path to the .layout file on disk.

    • version (Integer) (defaults to: Layout::Document::VERSION_CURRENT)

      LayOut file format to save.

Raises:

  • (ArgumentError)

    if version is not a valid version

  • (ArgumentError)

    if saving failed. This may be due to the LayOut file being open in the LayOut application

Version:

  • LayOut 2018



376
377
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 376

def save(*args)
end

#shared_entitiesLayout::Entities

The #shared_entities method returns the Entities that exist on shared Layers in the Layout::Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
entities = doc.shared_entities

Returns:

Version:

  • LayOut 2018



389
390
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 389

def shared_entities
end

#time_createdTime

The #time_created method returns the time when the Layout::Document was created.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
created_time = doc.time_created

Returns:

Version:

  • LayOut 2018



402
403
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 402

def time_created
end

#time_modifiedTime

The #time_modified method returns the last time the Layout::Document was modified.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
mod_time = doc.time_modified

Returns:

Version:

  • LayOut 2018



415
416
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 415

def time_modified
end

#time_publishedTime

The #time_published method returns the time when the Layout::Document was published.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
pub_time = doc.time_published

Returns:

Version:

  • LayOut 2018



428
429
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 428

def time_published
end

#unitsInteger

The #units method returns the units for the Layout::Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
units = doc.units

Returns:

Version:

  • LayOut 2018



440
441
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 440

def units
end

#units=(units_format) ⇒ Object

The #units= method sets the units for the Layout::Document.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
units_format = LAYOUT::DOCUMENT::DECIMAL_MILLIMETERS
doc.units = units_format

Parameters:

Raises:

  • (ArgumentError)

    if units format is not a valid format

Version:

  • LayOut 2018



456
457
# File 'lib/sketchup-api-stubs/stubs/Layout/Document.rb', line 456

def units=(units_format)
end