Attributes (Advanced Text Capabilities)

www.CAD6.com

Malz++Kassner CAD6 supports "attributes" which are values locally defined within all kinds of entities in the current drawing or in a library block. They consist of a name and a value that is to be interpreted as a text, a number, or a link. The value may contain references to Variables and other attributes, as well as Statements.

 

 

Attribute Scopes

Four different of attribute scopes are available:

 

Global attributes

Global attributes are only available within blocks (and within embedded instances). Their value is valid for the block itself and all of its instances. It can be logically overwritten in any instance by a local attribute of the same name.

Global attributes are maintained within the application, i.e. they will be copied along with any block or instance.

 

Local attributes

Local attributes are available to all kinds of units. Their value is valid for the unit itself and any outlines and points therein. In blocks, they also serve as a templates for any instance to be created of that block. In case of an instance, a local attribute will logically overwrite a possible referenced block's global attribute of the same name. In case of an object such as a curve or surface, it can be logically overwritten by an outline or point attribute of the same name.

Local attributes are maintained within the application, i.e. they will be copied and combined along with any entity.

 

Outline attributes

An outline attribute is locally connected to an individual outline inside an object such as a curve or surface. Its value is valid for that outline and all of that outline's points. For each of the outline's points, it can be logically overwritten by a point attribute of the same name.

Outline attributes are usually maintained within the application if the outline remains "whole". When resolving or transforming objects, however, outline attributes will usually get lost without any warning.

 

Point attributes

A point attribute is locally connected to an individual point inside an object such as a curve or surface. Its value is only valid for that point.

Point attributes are usually maintained within the application if its containing object remains "whole". When resolving, transforming, trimming, or cutting objects, however, point attributes will usually get lost without any warning.

 

The total number of attributes of each type (global + local, outline, point) per respective element (one unit, one outline, one point) is limited to 200 per type.

 

Since any one object may contain multiple outline and point attributes of the same name (but for different outlines and points), those types of attributes usually cannot be unambiguously identified by textual means like variables (enclosed in ~ characters) or by means of object attribute requests.

 

The four attribute scopes form a hierarchy. Global attribute are the defaults. Local attributes logically overwrite them for the respective entity. Outline properties overwrite any global or local attribute for the specific outline. Point attributes overwrite any global, local, or outline attribute for the specific point.

 

Example

An object of type "Surface" has three outlines.

 

The first and the second outline both have an outline attribute named "Width" with a value of "10.0". The second outline has additional point attributes named "Width" with a value of "5.0" for each of its points. And the object as a whole has a local attribute named "Width" with a value of "20.0".

 

When determining the "final" attribute values for any one point of the first outline, your search should yield an attribute "Width" with a value of 10.0 (coming from the outline's outline attribute). For the second outline, your search should yield an attribute "Width" with a value of 5.0 (coming from the point's point attribute). And for the third outline, the result should be 20.0 (coming from the object's local attribute).

 

 

Attribute Content Types

While attribute values are always stored and usually used in their plain textual form, three different types of attribute content are available for all scopes:

 

Text

The attribute's content is always used in its original, textual form. May contain any text.

 

Number

The attribute's content is assumed to be a numerical value. During user input, the application check will check for validity.

 

URL

The attribute's content is assumed to be a URL (either an internet links or a file name). During user input, the application will offer a "Choose"-Button allowing the user to select a file name.

 

The maximum content length is the same for all three content types (at most 4.000 characters).

 

 

Use Attributes in Texts

A variable has to be enclosed in tilde characters ~ (Ansi 126) to be evaluated in texts or statements respectively, e.g. ~Variable~. The text

Price: ~Price~ Euro

 

contains a variable named "Price". If the variable "Price" exists it is evaluated, i.e. the string "~Price~" is replaced by the value or the content of the variable "Price". For example, if the variable has the value 29.95 the following text is created:

Price: 29.95 Euro

 

If a text contains a variable that does not exist then this variable cannot be evaluated. In such a case the variable is replaced by the text (***UNDEFINED***). For the example above the resulting text would be:

<Price: (***UNDEFINED***) Euro

 

To output the explicit tilde character please use \~.

 

 

Display Attributes in Blocks

If you want to display attributes of a block, you have to know this before you create that block. Let's assume you want to create a block containing the symbolic representation of an electric resistor. This symbol should contain a text that displays the resistor's resistance.

 

The resistance will be stored in a local attribute of the block to be created, as this local attribute may have different values for each instance of the block. In our example, this attribute shall be called "Resistance".

 

Now, let's create the block. First, draw the resistor itself. A rectangle and maybe two line for the connections will do. Then, create a standard text (Annotate > Text > Standard) containing just the following short text:

~Resistance~

 

Place this text inside the resistor's rectangle. Please note that this text will also be rotated and scaled if you rotate or move the block itself later on! So make sure the text's position will still make sense then.

 

After you have created all components of the resistor symbol, create a block using Library > Block > Create (Insertion Point). In the dialog appearing, set the "Edit Attributes" check box. After entering a name for the block and pressing "OK", another dialog appears. Here, add a local attribute named "Resistance" to this block. Initialize it with any useful value, e.g. "100 ohm".

 

After you have created this block, you are ready to use the resistor symbol. Create multiple instances of this block using the Library > Block > Insert command. Be sure that the "Copy Attributes" check box is set in the block selection dialog!

 

You will see that all resistor symbol placed display the same text "100 ohm". Now, choose the Modify > Edit > Text / Attribute command and identify one of these resistor symbols. In the appearing dialog, change the value of the "Resistance" attribute to "10 kohm". After pressing "OK", the identified resistor symbol will display "10 kohm" instead of "100 ohm".

 

If you want to edit the attribute's value for each block you place, you can simply set the "Edit Attributes" check box in the block selection dialog of the Library > Block > Insert command. This will display the "Edit Attributes" dialog each time you place a symbol.

 

 

Implicit Attributes

Implicit attributes are a special kind of local attributes. Based on its type, any entity owns a different set of them, even though they are not visible to the user and are usually used for parts lists. They store internal information such as the block name, library name, position, etc.

 

The following implicit attributes are available:

~*00~

The name of the block itself.

~*01~

The name of the library the block resides in.

~*04~

X-coordinate of the start point / insertion point according to the current coordinate system.

~*05~

Y-coordinate of the start point / insertion point according to the current coordinate system.

~*06~

Rotation in degrees.

~*07~

Horizontal scaling relative to 1.

~*08~

Vertical scaling relative to 1.

~*09~

Horizontal distortion (shearing) in degrees.

~*10~

Position number range.

~*11~

Comment of the block or instance.

~*12~

Surface area of the object or hatching.

~*13~

Perimeter area of the object or hatching.

~*14~

Page assignment.

~*15~

Page comment.

~*16~

Layer name.

~*17~

Layer comment.

~*18~

Pen name.

~*19~

Pen comment.

~*20~

Line type.

~*21~

Line width in millimeters.

~*22~

Line color.

~*23~

Fill color.

 

 

Search for Attributes

The global search for attributes allows you to access attributes from different instances throughout the current drawing.

 

A search for attributes has one of the following forms:

~%(LibraryName)(BlockName)"AttributeName"~

Gets the value of the attribute AttributeName in the first matching instance found.

~%(LibraryName)(BlockName)*ImplicitAttribute~

Gets the value of the specified implicit attribute ImplicitAttribute (see section below) in the first matching instance found.

~%(LibraryName)(BlockName)"AttributeName","FindText"@"FindAttributeName"~

Gets the value of the attribute AttributeName in the first matching instance found that has an attribute FindAttributeName with the value FindText. Both attribute names may be the same, i.e. you can search for a partial match and retrieve the exact value. If FindAttributeName is empty, the text will be searched in any attribute. If FindText is empty, the existence of an attribute with the given name will suffice. If both are empty, they will be ignored (analogous to the first form).

~%(LibraryName)(BlockName)*ImplicitAttribute,"FindText"@"FindAttributeName"~

Gets the value of the the specified implicit attribute ImplicitAttribute (see section below) in the first matching instance found that has an attribute FindAttributeName with the value FindText. Both attribute names may be the same, i.e. you can search for a partial match and retrieve the exact value. If FindAttributeName is empty, the text will be searched in any attribute. If FindText is empty, the existence of an attribute with the given name will suffice. If both are empty, they will be ignored (analogous to the second form).

 

If LibraryName or BlockName are empty, every instance matches. If LibraryName contains only an asterisk '*', it matches internal blocks. If LibraryName, BlockName, AttributeName, FindText, or FindAttributeName start with an asterisk ‘*’, the search method will be case-insensitive, partial match. If not, the search method will be case-sensitive, complete match. To use the double-quote character inside quoted names or texts, please use \". The same applies to parentheses and brackets if the text is delimited by those.

 

Example

Code sequence in the text:

~%(Products)()"Price","*Motor"@"Description"~

 

Possibly displayed text:

29.95

 

Explanation:

Technically, the application scans through all instances of blocks from the library "Products" in the current drawing, searching for an attribute with the name "Description", containing the partial value "Motor". If found, it searches for another attribute in that instance with then name "Price" and returns its value.

In plain English: The application searches for the price of the first instantiated product whose description contains the word "Motor".

 

 

Object Attributes

Object attributes are variables allowing to access attributes of specific objects by means of their unique ID.

 

The following object attributes are available:

~*a(UniqueID)AttributeName~

Attribute AttributeName of the specified object.

 

If the object attribute is used within a text or dimension that is linked to another object by means of its LinkedID member, the unique ID inside the brackets can be omitted and the application will automatically use LinkedID instead. If the unique ID is omitted and the text or dimension is not linked to another object, the application will use the top-level object (block or group) in which the text or dimension resides.

 

 

Miscellaneous

Further text requests are used by the application for internal purposes:

~#AutoPosNum~

An automatically generated position number.

 

Starting with Version 2019.1, all texts, names, variables, and attributes are Unicode-enabled. In memory, they are stored in UTF-16 format, in the CAD6 file format in UTF-8 format.

 

CAD6studio Release 2024.1 - Copyright 2024 Malz++Kassner® GmbH