Attributes (Advanced Text Capabilities) Changed in Version 2023.2 |
www.CAD6.com |
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 ScopesFour different of attribute scopes are available:
Global attributesGlobal 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 attributesLocal attributes are available to all kinds of entities. Their value is valid for the entity 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 New in Version 2021.0An outline attribute is locally connected to an individual outline inside an object such as a curve or surface. It must be located behind the starting point's datablock of the respective outline and before the next outline's starting point (or end of object). 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 New in Version 2021.0A point attribute is locally connected to an individual point inside an object such as a curve or surface. It must be located immediately behind the respective point's datablock. 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 entity, one outline, one point) is limited to MKI_ATTRIBS_PER_OBJECT 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. Use an enumeration such as MKI_EnumerateEntityAttrib or an explicit attribute retrieval command such as MKI_AttributeGetPoint instead.
The four attribute scopes form a hierarchy. Global attributes 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. This should be taken into account when you're working with outline and/or point attributes.
ExampleAn 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 TypesWhile attribute values are always stored and usually used in their plain textual form, three different types of attribute content are available for all scopes:
TextThe attribute's content is always used in its original, textual form. May contain any text.
NumberThe attribute's content is assumed to be a numerical value. During user input, the application check will check for validity.
URLThe 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 MKI_LENGTH_ATTRIBUTE characters including the terminating '\0' character).
Use Attributes in TextsAn attribute has to be enclosed in tilde characters ~ (Unicode 126) to be evaluated in texts or statements respectively, e.g. ~Variable~. The text
Price: ~Price~ Euro
contains an attribute named "Price". If the attribute "Price" exists in the current context, it is evaluated, i.e. the string "~Price~" is replaced by the value of the attribute "Price". For example, if the attribute has the value "29.95", the following text is created:
Price: 29.95 Euro
If a text contains an attribute that does not exist then this attribute cannot be evaluated. In such a case the attribute is replaced by the text (***UNDEFINED***) . For the example above the resulting text would be:
Price: (***UNDEFINED***) Euro
To output the explicit tilde character in a text, please use \~.
Display Attributes in BlocksIf you want to display attributes, you create any kind of text and include the name of the attribute enclosed in tilde characters ~. If you want to display an attribute's value within a block, you have to know this before creating 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 (Lettering > 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 once you place it, 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 AttributesImplicit 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~ New in Version 2023.2 Comment of the block or instance. ~*12~ New in Version 2023.2 Surface area of the object or hatching. ~*13~ New in Version 2023.2 Perimeter area of the object or hatching. ~*14~ New in Version 2023.2 Page assignment. ~*15~ New in Version 2023.2 Page comment. ~*16~ New in Version 2023.2 Layer name. ~*17~ New in Version 2023.2 Layer comment. ~*18~ New in Version 2023.2 Pen name. ~*19~ New in Version 2023.2 Pen comment. ~*20~ New in Version 2023.2 Line type. ~*21~ New in Version 2023.2 Line width in millimeters. ~*22~ New in Version 2023.2 Line color. ~*23~ New in Version 2023.2 Fill color.
Search for Attributes New in Version 6.60The 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.
ExampleCode 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 New in Version 2017.1Object attributes are text requests 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.
MiscellaneousFurther 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.
|
CAD6interface 2024.2 - Copyright 2024 Malz++Kassner® GmbH