Substitutions

По-русски

Substitutions are used in the Data Table, Sawing Table, Material Table, Lay, Mark, NC Prepare, DXF Export, Numbering and Smart Leader plug-ins. That is, wherever you need to insert some properties of drawing objects into the text. Substitutions are a system similar to AutoCAD fields. The substitution shows A>V>C> programs where to paste the part information in the text. For example, you need the title of the part to contain the line "Part No. 1, Layer Chipboard", where 1 is the name of the part, and Chipboard is the name of the part layer. Then you use two substitutions in the calculation settings: "Part No.%name%, Layer %layer%". And the program will substitute for each part the name of the part where %name% is written and the part layer, so where %layer% is written.

You can always insert the substitutions into the program settings using the insertion substitution dialog. But you can not open a dialog, but write a substitution yourself. Therefore, it makes sense to figure out how to write your own permutations.

If you cannot set up substitutions yourself, then contact technical support or Telegram-chat. Small consultations are provided free of charge.

Writing substitutions

Each substitution begins and ends with the % percent symbol and can consist of a one or several property names, then an index number and then a format:

%namenamenameN:Format%

The names of substitution are case sensitive - it is usually necessary to write in small English letters, or as it is called attribute, drawing property. Some data can be substituted by short substitution or long (e.g. %n% or %name%) - there is no difference. 

The substitution name can be composite. For example, face means that it is necessary to substitute some property of solid surface. Behind face we specify which one: facearea - area, facemat - surface coverage material. And after mat may be also a property of this material. facematprice - the price of the material of covering the solid surface. All these parts should be written in small letters without spaces.   

%facematprice2:#.##'$'%

Here you can see inside the substitution not only its three-part name, but also its index and format. The index is used only to indicate the number of the painted surface or the number of the edge. In this case "2" means that you have to substitute the material price for the second (back) side of the part. And you need to format the price with the cents and the dollar symbol at the end. And for example, %edgematart1% is an article (art) of edge material (mat) on the first (longest) edge (end) of the part.

Substitution formats

The substitution format is written after the name and index and separated by a colon. The format redefines the standard formatting of numbers, sizes, areas. The format allows you to specify how many digits of the fractional part of the number you want to output. The same format allows you to specify any text in quotes. This text will be substituted only if the value of number/length/area/volume is not zero. You can use this to output units. For string substitution, the format string allows you to substitute some input words, but only if the value of the substitution is not an empty string. Since I use C# for my plugins, you can see the format string descriptions for C# and use them in substitution.

%info:\PInformation: {0}%.

This substitution will turn into an empty line if the information about the part is empty. And if it is not empty, the line break will be inserted (in AutoCAD is encoded by the characters \P ) then the word Information with a colon and only then the detail description will be inserted.

Do not try to substitute another number between the curly braces instead of 0. This will cause a program error.


Then each substitution will be described with its type. Based on this, you can choose the acceptable formats.

substr function

The substr function allows you to extract part of a string (a substring). The function name should be written in small letters. After the function name, write two integers separated by commas: the starting position and the length of the substring. The first number is the character number in the source string, starting from 1. You can skip this number, write a comma at once, and then the substring will be extracted from the beginning of the string, from the first character. The second number indicates the number of characters to be extracted. If the length is set to be greater than the length of the source string, or if the second number is not specified, then all characters up to the end of the source string are extracted. Examples:

%name:substr3,4%.

This example extracts the name of the object (for example, the name of the old block in the AsmNew command), and then the substr function extracts 4 characters from the name, starting with the third. For example, if the name was "A#9876B", then only "9876" would be substituted.

Other examples:

%name:substr3% - extract the substring from the third character to the end of the string - "9876B".

%name:substr,4% - extract a substring of 4 characters starting from the first (start not specified = 1) - "A#98".

Mathematical Expressions

Many substitution commands allow you to evaluate mathematical expressions involving numbers and numeric substitutions. In particular, you can write a mathematical formula in the settings of any column of any table command: Data Tables, Sawing Tables, and so on. To calculate the formula, you need to start the text with the = symbol.

For example, to calculate the area of the overall rectangle of a part, you can create a column in the Sawing Table with the value "= %length% * %width% / 1000000". In this case, the length and width values will first be substituted, and then they will be multiplied and converted from mm to square meters.

You can use the following functions in mathematical expressions:

Operators:

+ - / ÷ * × % ^

Functions:

exp log ln sqrt fpart round ceil floor fac sfac abs

Trigonometric functions:

cos sin tan cotan acos asin atan acotan cosh sinh tanh

Comparison operators (return 0 or 1):

> < == != >= <=

Logical operators:

&& || !

Constants:

euler, pi, nan, infinity, true, false


The priority of operations is taken into account, but it can be changed using parentheses (). If some symbols (units or degrees) are displayed when formatting the substitution, the expression will not be evaluated. You will have to force format some substitutions that output extra characters by default.

Please note that in Excel and in the dwg table the result will be written, not the formula (if only it can be calculated). If an unevaluated expression falls into a table cell, AutoCAD will try to evaluate the expression itself and will most likely show an error (cell with #### symbols).

Substitution Selection Dialog

Each substitution-enabled text box has a button to open a substitution selection dialog. To see this button, click on the field. Or double-click to enter the text editing mode in the table (in the list of fields of the Data Table). Before calling the dialog, position the cursor in the desired position in the text. A substitution will be inserted at this location.

In the settings dialog, all substitutions are grouped by objects from which data can be extracted. The substitution Format can be entered in a separate input field. And this field remembers the last formats you entered and contains examples - you can select them from the drop-down list. If the substitution allows an index, an Index entry field will appear. At the bottom of the form, you will see a field with the resulting substitution code. It can be corrected. Here, too, there is a list of recent substitutions - it may be easier for you to choose a substitution from this list. Click OK to insert the substitution. Or close the dialog with a cross so that you don’t insert anything.

Common properties

At all objects of the drawing it is possible to receive and substitutes in the text some standard properties. Here substitutions for them:

Name of objects

If you are using the A>V>C> Palette, you get access to substitutions:


You can order adding any text properties to objects. Development of one property - $50. They can also be substituted by their name inside the %% symbols, respecting the case of letters.


In addition, all properties of the current drawing can be retrieved from any object. For objects from xrefs, the properties of the main drawing will be retrieved, not from he links.

For objects extracted from assembly-blocks, you can retrieve the properties of the owner-block and its constant attributes. To do this, write the word "block" in the substitution and then the desired property. Note that objects do not know through which block reference they were received and therefore the block reference properties are not available. Also, parameters of dynamic blocks and variable attributes are not available.

Solids

In addition to the standard properties of solids, you can substitute properties:

If you are using the A>V>C> Palette, you get access to substitutions:

Solid Metric

If you run the Lay, Saw, Mark or SolSize commands, then its metric will be written to solid xData. You can get this data using substitutions:

Solid edge indexes

Edge of solids in edge, bandings & slopes substitutions are listed in clockwise order around the front surface, starting from the lower left corner of the part (meaning that the part has already been laid out in the XY plane with the Lay command). Thus, for a rectangular part on the layout, end number 

There are not necessarily 4 edges - they can be any number. And they are not necessarily flat. 

If corners are cut off or there are cutouts on a rectangular part, then the end numbers are confused and you will not be able to display the right end by its index; it is no longer the third, but, for example, 6. To solve this problem, you can use 4 special end indices:

This refers to the directions on the parts laid out with the Layout (LAY) command. The initial position of the part in the assembly does not matter; the part can be turned over during laying out.

If in the table you need to first specify the columns of the top and bottom edges, and then the left and right (as required by import into the OptiCut program), then use the following column order: 2000, 4000, 1000, 3000.

A part can have several edges with one special index (part with a cutout). Data about them will be combined and it may listing multiple values or subsitute *varies*.

The part may not have any of these 4 edges (triangular part, arc, circle). N/A will be substituted.

Special indexes only work with rectangular parts. Ends inside cutouts, windows, diagonals of triangular parts, curved ends - all these ends can only be displayed using regular numbering in order, but not with special indices.

It is these four main directions of the edges that can be called the letters L, T, R, B or arrows if you enable this option in Common Options.

Blocks

All standard properties are available to Block Reference. Plus:


In addition, the properties of the block defenition (BlockTableRecord) are available:


Attributes and parameters are also available. Both constant (from a Block Table Record) and mutable (from a Block Reference). Their name must be enclosed between the % characters. It is important to observe the case of letters as the attribute tag is written, and to write in the substitution. Substitution of attributes and parameters can be formatted as a string. Integer and real parameters can be formatted as a number.

Virtual attributes (set in the settings of the AVC Properties Palette) will be available for substitution for all blocks.

Curves

All lines, polylines, multi-lines, arcs, circles, flat splines, ellipses are added to the standard substitutions:

Polyline & Polyline2d

Adds to curve substitutions:

Arc

Adds to curve substitutions:

Circle

Adds to curve substitutions:

Text & MText

Adds to standard substitutions:

MLeader

Adds to standard substitutions:

Dimensions

Adds to standard substitutions:

Table

Adds to standard substitutions:

Viewport

Group

By groups we mean groups of jointly selected model space objects. Groups are usually not available on their own; they must be obtained as a property of visible drawing objects via the %groupNNN% substitution. AutoCAD allows you to assign one object to many groups, but AVC programs will select one (the first) group. Instead of NNN, you can write one of the following group property substitutions:

Layout

Sheet (Layout) property substitutions are only available in the settings of the Detailing Drawings command (DDraw). In addition to the properties of the sheet itself, you can substitute the properties of the viewport or the details visible in the viewport. To do this, use the 'view' prefix. For example %viewstandardscale% is the scale of the viewport. If there are several viewports on the sheet, then all variants of the property will be substituted. Part properties are substituted first, even if the viewport has the same property. For example, %viewlayer% is the layer of the detail shown in the viewport, not the layer of the viewport itself.

Layer

Layers are usually not accessible by themselves, they should be retrieved as a property of visible drawing objects via the %layerNNN% substitution, where instead of NNN you can write one of the following layer property substitutions:

Details

When the commands Data Table, Lay and Sawing Table group the same objects and count the number of the same, then in these commands, the detail property substitutions are available:


If geometric comparison of objects is enabled, but the separation of mirror parts into separate records is not enabled, then the following substitutions make sense:


If the search for objects inside assembly blocks is enabled or the multiplier (product series) is greater than 1, then additional substitutions can be used:

Detail properties are not saved in object and therefore not available in Smart Leader and Mark.

Materials

If you use the A>V>C> Palette, you can customize new material properties. And after that you can use the substitutions (after name mat ) :

In the Material Table command, you can use material calculation substitutions for selected parts:

Drawing property

For any object you can use DWG drawing property substitutions:

You can also substitute custom drawing properties. To do this, place the substitution in the form of %customdp.My_property_name% Do not forget the point before the name. It is important to write the name in that case of letters as in the properties of the drawing.  All drawing properties except dates are formatted as a string.

Current time

You can use date and time substitutions for any object.

All substitutions of the current time are calculated at the moment of launching the commands and cannot be converted to fields.

Contours of parts for CNC

The contour preparation commands for CNC (Outside loop, NC_Prepare and DXF Export) are able to use substitutions when creating new layers. These substitutions can use the data on the contours of the part, which is necessary for assigning processing parameters to the part. The same substitutions can be used in the Drill Table and on the face tilt angle leaders.

View name

The Lay program can lay out parts face or backwards. With the special substitution %view%, you can display the name of the view in the title of the part. Substitution is also available in the DXF export command.

Unknown properties

If you wrote a substitution with an error or the object does not have such a property or the block does not have the required attribute, then the substitution system will return the value "n/a". You can reconfigure this string - write down another value in the Common options in the Substitution section in the "No available" field. You can substitute an empty string too.

In the summary values and totals, the unknown substitution will be considered as zero.

Fields

AutoCAD fields are also substitutions of a special kind. They are inserted by the _Field command into any text (multitexts, multileaders, attributes, tables) that allow you to display the properties of the drawing or objects. Conveniently, the fields are updated automatically, almost immediately after you change the property of the object. 

Updating the fields can occur when the image is regenerated (command _Regen), change the sheets, before printing or manually using the _UpdateField and AVCUpdate commands. Field updates are configured by the FieldEval system variable.

Commands from A>V>C> plugins can create fields and replace substitutions for fields. This can be convenient, because many object changes on Smart Leaders even without calling the LeaderUpdate command. But there are a number of limitations and peculiarities:

Creating fields is easy to disable in the Common Options - see the "Use Fields" checkbox.

In the Common Options, you can set the display format for numbers/sizes. This setting also applies to fields. But there is a restriction - you can not add characters and texts to the format string.

In the Common Options, you can adjust names of textures and technologies.