Field codes are special codes consisting of a name and content that can be assigned a value. They are used for data subject to change, for example for the current date or the number of pages in the document.

When printing a document, the field code is replaced by its value. For example, the field code Date is replaced by the current date.

The use of field codes is mainly useful in the realization of models or in the realization of projects consisting of several documents. For example, you can create text fields indicating the company, the designer and the project title in each document. Afterwards, to change the value of these fields, it will not be necessary to change all the documents, but you can simply set the values in the field code dialog box.

Some field codes are already defined, others can be defined by the user.

Field code hierarchy

Field codes cascade on the three hierarchical levels of data organization: Job » Project » Document. The value of a field code defined at the Job level will apply to all projects and documents unless it is redefined in an internal layer. Similarly, the value of a project-level defined field code will apply to all documents included in the project unless it is redefined in the document.

To set field codes

  1. The content of field codes can be changed in the following dialog boxes: Job properties, Project properties, Document properties.

    • To set field codes at the Job level, open the Job Properties dialog by selecting the Settings » Job Properties command or by using the CTRL+ALT+J key combination.

    • To set field codes at the Project level, open the Project Properties dialog by selecting the Settings » Project Properties command or by using the CTRL+ALT+P key combination.

    • To set the field codes at the Document level, open the Document Properties dialog by selecting the Settings » Document Properties command or by using the CTRL+ALT+D key combination.

  2. Click the Field codes tab.

  3. Do one of the following:

    • Click on the value field and set the content of the field code.

    • Click the Add button to add a new field code.

    • To delete a user-defined field code: select it from the list and click the Delete button.

Content of a field code

The content of a field code is a text string that overrides any default value. Field codes that do not have a default value must be assigned a value before they are used. Field codes with a default value should only be assigned a value if you want to customize their content.

The content of a field code varies by type. Field codes can be of two types: Text and Date-Time.

Syntax of field codes of type Text

The string consists of zero or more directives and common characters. All common characters are copied unchanged. The directives are as follows:

%s

It is used as a placeholder to indicate the position in which to insert any default value.

${attribute_name/category_name$format}

To display the value of an object attribute.

attribute_name

specifies the name of the attribute.

category_name

specifies the attribute category. It can be omitted if the object does not contain more than one attribute with the same name.

format

represents the format specifier to apply to the result of the expression. For numerical values you can also specify the format specifier %q that formats the numerical value using scale suffixes.

${expr$format}

The value is determined by the result of a numeric expression that has the attributes of an object as operands.

expr

represents a numerical expression. In the expression, attribute names must be enclosed in curly brackets.

format

represents the Format specificator to be applied to the expression result. For numerical values you can also specify the format specifier %q that formats the numerical value using scale suffixes.

Example 1:
If you want to customize the field code Progressive page number in the document so that the page number appears in the documents in the form: Pag (1). You must specify as value the string: Pag (%s).

Example 2:
If the component contains an attribute, called price, with the unit cost, the string to show the cost of the component is in the form: ${price$Euro %.2f}.

Example 3:
If the component contains a SPICE parameter named freq, the string to report the frequency of a generator in the drawing is in the form: ${freq/spice$Freq=%qHz}.

Example 4:
The string to return the absolute value of a numeric attribute in the drawing is in the form: ${abs({attribute_name})$%.3f}.

Syntax of field codes of type Date-Time

The syntax of the Date-Time fields is as follows:

DyyyymmddHhhmmss format

The first part is optional and allows you to specify both the date and time.

The second part represents the format and consists of zero or more specifiers and common characters. If the format is not specified, it is equivalent to %x for the date an d%X for the time.

A format specifiers consists of the character % followed by a character that determines the substitution that must take place. All common characters are copied unchanged. The format specifiers are as follows:

Specifier

Replaced with

Example

%%

A % sign

%

%a

Abbreviated weekday name

Thu

%A

Full weekday name

Thursday

%b

Abbreviated month name

Aug

%B

Full month name

August

%c

Date and time representation

Thu Aug 23 14:55:02 2001

%d

Day of month as decimal number (01 – 31)

23

%H

Hour in 24-hour format (00 – 23)

14

%I

Hour in 12-hour format (01 – 12)

02

%j

Day of the year (001-366)

235

%m

Month as decimal number (01 – 12)

08

%M

Minute as decimal number (00 – 59)

55

%p

Current A.M./P.M. indicator for 12-hour clock

AM

%S

Second (00-61)

02

%U

Week number with the first Sunday as the first day of week one (00-53)

33

%w

Weekday as a decimal number with Sunday as 0 (0-6)

4

%W

Week number with the first Monday as the first day of week one (00-53)

34

%x

Date representation

08/23/01

%X

Time representation

14:55:02

%y

Year, last two digits (00-99)

01

%Y

Year

2001

%Z

Time zone name, or no character if no time zone

CDT

Example 1:
If you want to display both the current date and time. You have to specify as value the string: %c.

Example 2:
If you want to display both the date and time set at 15:20 on 1 January 2017. You must specify the string as the value: D20170101H152000%c.

Example 3:
If you want to display the date of 1 January 2017. You must specify the string as the value: D20170101.

Example 4:
If you want to display the set time at 15:20. You must specify the string as the value: H152000.

See also