请选择 进入手机版 | 继续访问电脑版

01BIM社区

 找回密码
 立即注册

扫一扫,访问微社区

查看: 494|回复: 4

Sketchup LayOut API

[复制链接]

113

主题

268

帖子

1084

积分

金牌会员

Rank: 6Rank: 6

积分
1084
发表于 2019-7-13 20:56:50 | 显示全部楼层 |阅读模式
本帖为密码帖 ,请输入密码 
回复

使用道具 举报

113

主题

268

帖子

1084

积分

金牌会员

Rank: 6Rank: 6

积分
1084
 楼主| 发表于 2019-7-13 20:59:49 | 显示全部楼层
本帖最后由 tzbm123456 于 2019-7-13 21:03 编辑

Class: Layout:ocument
Inherits:
    Object
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:ocument.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 #
    Layout:ocument::VERSION_1
    Layout:ocument::VERSION_2
    Layout:ocument::VERSION_3
    Layout:ocument::VERSION_2013
    Layout:ocument::VERSION_2014
    Layout:ocument::VERSION_2015
    Layout:ocument::VERSION_2016
    Layout:ocument::VERSION_2017
    Layout::Document::VERSION_2018
    Layout::Document::VERSION_2019
    Layout::Document::VERSION_CURRENT
    Layout::Document::FRACTIONAL_INCHES
    Layout::Document::DECIMAL_INCHES
    Layout::Document::DECIMAL_FEET
    Layout::Document::DECIMAL_MILLIMETERS
    Layout::Document::DECIMAL_CENTIMETERS
    Layout::Document::DECIMAL_METERS
    Layout::Document::DECIMAL_POINTS
Class Method Summary #
.open(path) ⇒ Layout::Document
    The Document.open method creates a new Document by loading an existing .layout file.
Instance Method Summary #
#==(other) ⇒ Boolean
    The #== method checks to see if the two Documents are equal.
#add_entity(*args) ⇒ Object
    The #add_entity method adds an Entity to the Document and places it on the given Layer and Page.
#auto_text_definitions ⇒ Layout::AutoTextDefinitions
    The #auto_text_definitions method returns an array of AutoTextDefinition's in the Document.
#grid ⇒ Layout::Grid
    The #grid method returns the Grid for a Document.
#grid_snap_enabled=(enabled) ⇒ Object
    The #grid_snap_enabled= method sets whether or not grid snap is enabled in the Document.
#grid_snap_enabled? ⇒ Boolean
    The #grid_snap_enabled? method returns whether or not grid snap is enabled in the Document.
#initialize(*args) ⇒ Object constructor
    The #initialize method creates a new Document.
#layers ⇒ Layout:ayers
    The #layers method returns the Layers of the Document.
#object_snap_enabled=(enabled) ⇒ Object
    The #object_snap_enabled= method enables or disables inference in the Document.
#object_snap_enabled? ⇒ Boolean
    The #object_snap_enabled? method returns whether or not inference is enabled in the Document.
#page_info ⇒ Layout:ageInfo
    The #page_info method returns a reference to the PageInfo settings of the Document.
#pages ⇒ Layout:ages
    The #pages method returns the Pages of the Document.
#path ⇒ String
    The #path method returns the full path of the Document file.
#precision ⇒ Float
    The #precision method returns the precision for the Document.
#precision=(precision) ⇒ Object
    The #precision= method sets the precision for the Document.
#remove_entity(entity) ⇒ Object
    The #remove_entity method removes an Entity from the Document.
#save(*args) ⇒ Object
    The #save method saves the Document to a file at the given path.
#shared_entities ⇒ Layout::Entities
    The #shared_entities method returns the Entities that exist on shared Layers in the Document.
#time_created ⇒ Time
    The #time_created method returns the time when the Document was created.
#time_modified ⇒ Time
    The #time_modified method returns the last time the Document was modified.
#time_published ⇒ Time
    The #time_published method returns the time when the Document was published.
#units ⇒ Integer
    The #units method returns the units for the Document.
#units=(units_format) ⇒ Object
    The #units= method sets the units for the Document.

回复 支持 反对

使用道具 举报

113

主题

268

帖子

1084

积分

金牌会员

Rank: 6Rank: 6

积分
1084
 楼主| 发表于 2019-7-13 21:06:20 | 显示全部楼层
本帖最后由 tzbm123456 于 2019-7-13 21:21 编辑

Constructor Details
#initialize ⇒ Layout:ocument
#initialize(template_path) ⇒ Layout:ocument
The #initialize method creates a new Layout:ocument. Passing a path to an existing Layout:ocument will use that file as a template. The new Layout:ocument won't have a path until it is saved for the first time.
Examples:
doc = Layout:ocument.new
doc2 = Layout:ocument.new("/path/to/template.layout")
Overloads:
#initialize ⇒ Layout:ocument
Returns an empty Layout:ocument with one Layer and one Page
#initialize(template_path) ⇒ Layout:ocument
Returns an unsaved Layout::Document based on the template
Parameters:
template_path (String) — The path to the Layout::Document to use as a template
Raises:
(RuntimeError) — if there was an error reading the template file
(ArgumentError) — if the template file could not be found
Version:
LayOut 2018
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:
(Layout::Document) — The Layout::Document created from the .layout file.
Raises:
(ArgumentError) — if the file does not exist
Version:

LayOut 2018
Instance Method Details
◆1        #==(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:
other (Layout::Document)
Returns:(Boolean)
Version:LayOut 2018
◆2        #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:
#add_entity(entity, layer, page) ⇒ Object
Parameters:
entity (Layout::Entity) — The Entity to be added
layer (Layout:ayer) — The Layer to add the Entity to
page (Layout:age) — The Page to add the Entity to

#add_entity(entity, layer) ⇒ Object
Parameters:
entity (Layout::Entity) — The Entity to be added
layer (Layout:ayer) — The shared Layer to add the Entity to
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
◆3#auto_text_definitions ⇒ Layout::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:(Layout::AutoTextDefinitions)
Version:LayOut 2018
◆4#grid ⇒ Layout::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:(Layout::Grid)
Version:LayOut 2018
◆5#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
回复 支持 反对

使用道具 举报

113

主题

268

帖子

1084

积分

金牌会员

Rank: 6Rank: 6

积分
1084
 楼主| 发表于 2019-7-13 21:16:50 | 显示全部楼层
本帖最后由 tzbm123456 于 2019-7-13 21:19 编辑

◆6        #grid_snap_enabled? ⇒ Boolean
The #grid_snap_enabled? method returns whether or not grid snap is enabled in the Layout:ocument.
Examples:
doc = Layout:ocument.open("C:/path/to/document.layout")
enabled = doc.grid_snap_enabled?
Returns:
(Boolean)
(Boolean)
Version:
LayOut 2018
◆7        #layers ⇒ Layout:ayers
The #layers method returns the Layers of the Layout:ocument.
Examples:
doc = Layout:ocument.open("C:/path/to/document.layout")
layers = doc.layers
Returns:
(Layout:ayers)
Version:
LayOut 2018
◆8        #object_snap_enabled=(enabled) ⇒ Object
The #object_snap_enabled= method enables or disables inference in the Layout:ocument.
Examples:
doc = Layout:ocument.open("C:/path/to/document.layout")
doc.object_snap_enabled = false
Parameters:
enabled (Boolean) — true for enabled false for disabled
Version:
LayOut 2018
◆9        #object_snap_enabled? ⇒ Boolean
The #object_snap_enabled? method returns whether or not inference is enabled in the Layout:ocument.
Examples:
doc = Layout:ocument.open("C:/path/to/document.layout")
enabled = doc.object_snap_enabled?
Returns:
(Boolean)
(Boolean)
Version:
LayOut 2018
◆10        #page_info ⇒ Layout:ageInfo
The #page_info method returns a reference to the PageInfo settings of the Layout:ocument.
Examples:
doc = Layout:ocument.open("C:/path/to/document.layout")
page_info = doc.page_info
Returns:
(Layout:ageInfo)
Version:
LayOut 2018
◆11        #pages ⇒ Layout:ages
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:
(Layout:ages) — The Pages for the Layout::Document.
Version:
LayOut 2018
◆12        #path ⇒ String
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:
(String)
Version:
LayOut 2018
◆13        #precision ⇒ Float
The #precision method returns the precision for the Layout::Document.
Examples:
doc = Layout::Document.open("C:/path/to/document.layout")
precision = doc.precision
Returns:
(Float) — the number specifying the precision for the Layout::Document
Version:
LayOut 2018
◆14        #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
◆15        #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:
entity (Layout::Entity) — The Entity to be removed
Raises:
(ArgumentError) — if entity does not belong to the Layout::Document
Version:
LayOut 2018
回复 支持 反对

使用道具 举报

113

主题

268

帖子

1084

积分

金牌会员

Rank: 6Rank: 6

积分
1084
 楼主| 发表于 2019-7-13 21:17:32 | 显示全部楼层
本帖最后由 tzbm123456 于 2019-7-13 21:18 编辑

◆16#save ⇒ Object
·#save(path, version = Layout:ocument::VERSION_CURRENT) ⇒ Object
The #save method saves the Layout:ocument to a file at the given path. Passing an empty path string will save the Layout:ocument at its current path.
Examples:
doc = Layout:ocument.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:ocument::VERSION_3)
# Save the document in LayOut 2013 format
filename = File.join(ENV['Home'], 'Desktop', 'mydoc_v2013.layout')
status = doc.save(filename, Layout:ocument::VERSION_2013)
Overloads:
#save ⇒ Object
Raises:
(ArgumentError) — if the Layout:ocument hasn't been saved with a path yet

·#save(path, version = Layout:ocument::VERSION_CURRENT) ⇒ Object
Parameters:
path (String) — The path to the .layout file on disk.
version (Integer) (defaults to: Layout:ocument::VERSION_CURRENT) — LayOut file format to save.
Raises:
(ArgumentError) — if version is not a valid version
Version:
LayOut 2018
◆17#shared_entities ⇒ Layout::Entities
The #shared_entities method returns the Entities that exist on shared Layers in the Layout:ocument.
Examples:
doc = Layout::Document.open("C:/path/to/document.layout")
entities = doc.shared_entities
Returns:
(Layout::Entities)
Version:
LayOut 2018
◆18#time_created ⇒ Time
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:
(Time) — time when the Layout::Document was created
Version:
LayOut 2018
◆19        #time_modified ⇒ Time
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:
(Time) — time when the Layout::Document was last modified
Version:
LayOut 2018
◆20#time_published ⇒ Time
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:
(Time) — time when the Layout::Document was published
Version:
LayOut 2018
◆21#units ⇒ Integer
The #units method returns the units for the Layout::Document.
Examples:
doc = Layout::Document.open("C:/path/to/document.layout")
units = doc.units
Returns:
(Integer) — The unit format of the Layout::Document
Version:
LayOut 2018
◆22#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:
units_format (Integer) — The format of the units in the Layout::Document
Raises:
(ArgumentError) — if units format is not a valid format
Version:
LayOut 2018

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|01BIM社区 - 最专业的BIM技术交流平台 ( 渝ICP备15000873号 )

GMT+8, 2019-10-20 19:32 , Processed in 0.081554 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表