Asset Documents are a specialized type of smile2 documents. Their main purpose is, to be included (referenced) from other documents.
Cases, where this is useful are:
- A piece of geometry or a functional unit (eg a transistor design), should be included in many documents. Ideally, one would also like change in the individual references, without modifications of the original object. Additionally, one might want to make improvements to the source and propagate these to all references.
- More than one person is working on a structure design in parallel, and the different tasks should be separated such that they do not interfere.
The difference of asset document in comparison to normal smile2 documents is:
- Asset documents have no document modes and can be opened and edited only in edit mode.
- Asset documents have no write field or any write settings.
- Asset documents do not contain a task list or task entries.
- Assets can include special points, that can act as control ports in the reference.
Creating Asset Documents¶
There are two ways to create an asset document:
Referencing Asset Documents¶
After an asset document has been created, one can start to create references (asset objects in other smile2 documents. To to this, the Load Asset (addAsset) command located in the main menu under , can be used.
Beside a file name, this command has options to specify how the asset should be displayed and how the layers from the asset should be treated. This options can also be changed any time later on, in the Shape property sheet, found in the attribute editor.
After the asset reference has been created, one can treat it like any other object in smile2.
After creating the asset reference (or the asset object), the content of the asset appears as a single object that cannot be changed. In cases where you want to reference an copy, without any internal changes, this is fine.
However in many cases, one would like to make changes to the referenced geometry (eg. changing the width of a contact, changing the position of an element, etc.). For this purpose, assets offer a concept called interface.
Using the Interface¶
The following example demonstrates an asset object that references an asset file containing a simple interface:
The interface control points behave like an other vertices (eg. corners of a polygon). Eg. point snapping or tools like the Attach Points Tool can be used to attach “outer world” objects to asset elements.
If the asset provides Interface Attributes (see next chapter), these attributes are located in the “Interface Attribute” section of the asset shape property sheet. These attributes can also be used to numerically control internal aspects of the asset. Eg. the asset shown above, exposes a Bar Width attribute:
Creating an Interface¶
Only point shapes can act as interface points. To turn a normal point into an interface point, the Interface Layer attribute needs to be switched on:
Additionally, an “Interface Label” text and draw style for the “handle” can be specified.
These attributes are only available in asset documents.
As next, one can use the interface points, to implement the functionality. One could constrain components to it by using the Attach Points Tool, or with the Python API. One could also parenting other object or groups to it, or create connections from it’s position plug to the desired control plug (possibly using expression node(s) in-between). To set up connections, either the node editor or the connection features of the attribute editor can be used.
Creating Interface Attributes¶
Sometimes it is more convenient to control settings by an (numerical) input control instead of a handle (eg. the “width” of the bar in the example above).
To create an interface attribute, do the following:
Add a dynamic attribute to the asset document:
Add a dynamic attribute to the document node.
Create an input connection from the desired plug you want to control to the newly created plug:
The connection and/or required nodes, can also be created using the Python API.
That’s it. The newly created and connected plug will appear as interface attribute in the asset shape settings.