LayOut Ruby API
The LayOut Ruby API provides an interface for reading and writing data to and from LayOuts (.layout files) via an intuitive and easy to learn programming language, Ruby. It can create new s as well as read or modify existing s.
LayOut Ruby API Documentation
The documentation contains reference material for all functions, data structures, constants, and enumerations in the LayOut Ruby API.
The online Ruby API documentation can be found here: LayOut Ruby API Online Documentation
Using the LayOut Ruby API in SketchUp
The LayOut Ruby API is included in the SketchUp application, meaning developers may utilize the LayOut Ruby API from within their SketchUp application via the console, or in their SketchUp Ruby extension without being required to include it. For an example of how to use the LayOut Ruby API from within a SketchUp extension, see the RubyExampleCreateLayOut sample.
Things To Know About The LayOut Ruby API
LayOut's Coordinate System
LayOut uses a 2D coordinate system fors, whose origin is at the top-left corner of the page. The positive X axis extends to the right, and the positive Y axis extends downward. The units for all objects are inches. All 2D lengths and radii are also specified in inches, unless the function documentation specifies otherwise.
objects are used for certain functions that interact with a . objects specify model-space coordinates within a .
Shared and Non-Shared Groups
Amay not contain a mix of s on both shared and non-shared . This is enforced when creating s (see ) as well as when moving s into a (see ). Also, functions that cause an 's sharedness to change may have the side effect of splitting s (see ). In general, these operations follow the same behavior as the LayOut application itself.
To traverse the hierarchicalstructure of a , it is important to understand that due to the rule about shared and non-shared s, there are multiple structures in a . Each has its own structure that contains all of the s on non-shared for that (see ). Likewise, the has a structure that contains all of the s on shared s for the entire (see ). These functions provide access to an object, , which is a list of objects at the top of the hierarchy. Furthermore, the function provides an inlet to recursively traverse the structure.
Iterating Over Entities On A Page
In cases where you need to iterate over all thes that are visible on a , including the s on both shared and non-shared layers, you can use the method. This method returns a list that, when iterated over, will visit s in exactly the same order they are drawn by LayOut.
Anyin LayOut can be individually locked or unlocked via the method. Locked s cannot be moved, rotated, scaled, or modified in any way, besides being unlocked.
Locked and Hidden Layers
In LayOut, the locked state of ais a -wide setting, whereas the visible state of a is a per- setting. LayOut has a rule that there must always be at least one unlocked, visible on every . This rule is enforced by the LayOut Ruby API by methods such as , , and .
There Must Be At Least One Page And One Layer In A Document
There must be at least onein a , and there must be at least one . and enforce this. Also, new s created by will create a blank that starts out with one and one .
Explicit Transforms and Untransformed Bounds
Only somes in LayOut have explicit : , , , and will always have an explicit . These are the only s that will return a value for . will work on any type, regardless of whether the has an explicit or not. It is important to note that LayOut will attempt to simplify the , which may affect both the untransformed bounds as well as the explicit of the . Due to this, it is likely that the transform returned by will be different than the one that was applied. Also, the bounds returned by will likely be different from the 's initial untransformed bounds.
Paths Must Have At Least Two Points
enforces the rule that every must contain at least two points. This is because a 0 or 1-point is not visible and cannot be selected (or deleted) in the LayOut application.
Text Cannot Be Empty
The functions forenforce the rule that the content of the text cannot be empty. This is because an empty text box is not visible and cannot be selected (or deleted) in the LayOut application.