Field names |
To identify a Field name, it must start with the "#"
character. Generally, the Field name corresponds to the field name
in the database. For example, "#fil_title" corresponds to the mark
of the drawing in which the macro will be inserted. Some of these
fields are required to obtain a consistent result. The first field names that you must manage are corresponding to
the macro name and positions.
Table 1. Macro
Field
name |
Description |
Required |
#mac_name |
Name of the
macro |
Yes |
#mac_posx |
The X
coordinate where the macro will be
inserted |
Yes |
#mac_posy |
The Y
coordinate where the macro will be
inserted |
Yes |
#mac_insert |
If this
column is present, no hidden, contains a 0 or is
empty, the macro will not be processed. |
No |
About the other fields of database,
SOLIDWORKS Electrical only takes on fields for tables of drawing
("fil"), bundles ("bun"), locations ("loc") and functions
("fun").
The only field that is required
is #fil_title, which is the title of the drawing where the macro
will be inserted. But if you insert any other field like book,
location or function, then the tag of the corresponding table is
required. For instance, if you insert any location field, then
the field #loc_text is required.
The supported fields are
shown on the next table:
Table 2. Drawings
Field
name |
Description |
Required |
#fil_filename |
Name of the
file on the disk |
No |
#fil_title |
The mark of
the drawing |
Yes |
#fil_filetype |
The drawing
type (*) |
No |
#fil.tra_0.xx |
The
description of the drawing, where xx is language
code |
No |
#fil.use_data0 |
User data of
drawing |
No |
(*) Supported values for the file type are:
- 0: Schematic drawing
- 1: Line diagram drawing
- 5: Cover page
- 9: Cabinet layout drawing
- 12: Mixed scheme drawing
Table 3. Books
Field
name |
Description |
Required |
#bun_tag |
The mark of the
book |
Yes (if any
book is used) |
#bun.tra_0.xx |
The
description of the book where xx is the language
code |
No |
Table 4. Folders
Field
name |
Description |
Required |
#fol_name |
The mark of the
folder |
No (if any
folder is used) |
#fol.tra_0.xx |
The
description of the folder where xx is the language
code |
No |
Table 5. Locations
Field
name |
Description |
Required |
#loc_text |
The mark of the
location |
Yes (if any
location is used) |
#loc_tagpath |
Mark path
(full mark) |
No |
#loc_tagroot |
Root for
mark |
No |
#loc.tra_0.xx |
Description
of the location where xx is the language
code |
No |
Table 6. Functions
Field
name |
Description |
Required |
#fun_text |
The mark of the
function |
Yes (if any
function used) |
#fun_tagpath |
Mark path
(full mark) |
No |
#fun_tagroot |
Root for
mark |
No |
#fun.tra_0.xx |
Description
of the function where xx is the language
code |
No |
User data and translatable data can be also
added as a field, but as they are not directly in the object
table, the field definition is a bit different.
It is formatted in the following way for
translatable data: #ttt.tra_nn.xx
Where
- ttt: is to be replaced by the table
prefix (fil, bun, loc, fun).
- tra: is for translatable data (do not
modify)
- nn: is to replace by index of data you
need (0 for description). Up to 14 for translatable
data.
- .xx: is to replace by the language
code, usually.l1 (L1) for main electrical project
language. Supported language codes are:
- From electrical project
languages (L + 1 to 3): "l1", "l2", "l3"
- Standard language code: en, es,
fr, it, ru, ko, ja, pt..., zh, zh-tw
Example, for the description of the
file in the main language of the electrical project:
#fil.tra_0.l1
For user data, the syntax
is similar, but without specification for language: #ttt.use_datann
Where
- ttt: is to replace by the table prefix
(fil, bun, loc, fun).
- use_data: is for user data (do not
modify).
- nn: is to replace by index of data you
need, from 0 to 19 for user data.
Example, for file user data:
#fil.use_data0
|
Variables |
After you have specified all the data, you need to
say where to insert the macros (drawing, book, location, and
function) and you must specify the variables, which you want, to be
replaced by their values. To do this you can use two methods. The
first method consists of writing in the first available column
of the header, the tag "#mac_var_name" and on the next one
"#mac_var_value", and consecutively, as many pairs of columns as
you need. After that, for each row (for each macro you want to
insert), you want to write, on the first column, the name of the
variable and on the second column, the value of this variable.
For example:
#mac_name |
#mac_var_name |
#mac_var_value |
#mac_var_name |
#mac_var_value |
Test0 |
%motor1% |
M5 |
%motor2% |
M6 |
In this case, you insert the macro Test0, the variable
%motor1% is changed by M5 and the variable %motor2% is changed
by M6.
The second method is better if you use the same
names of the variables for all the macros. Then, in this method,
on the header you specify the name of the variable, for instance
%VAR1%, and on the different rows, the value that, this variable
has, for this inserted macro. For example:
#mac_name |
%var1% |
%var2% |
Test0 |
M5 |
M6 |
Test1 |
V3 |
V4 |
In this case, the first line inserts the macro Test0,
changes the variable %var1% by M5 and %var2% by M6 and on the
second line, the macro Test1 is inserted, changing in this case
the variable %var1% by V3 and variable %var2% by
V4.
The names of the variables are not case-sensitive
.
|
Using formula with the variables |
You can use a formula to automatically generate
the value during the automatic generation of drawing. The formula
will be identified by two characters '{ }', one at the beginning '{'
and the other at the end '}'. The content between those two
characters will be a formula, which can be like any formula we have
in the software. Variables in the formula must be formatted the same
way as the one in the Excel file (%VARIABLE%). For example, set
the mark of a component with this value: {"PP_" +
%VARIABLE% + "RR" + %VARIABLE2%}
When
inserting the macro twice, through Excel generation the result
will be PP_33RR12 the first time and PP_33RR13 the second
time.
If in the Excel file we have two lines
with:
%VARIABLE% set to 33 and %VARIABLE2% set to
12
%VARIABLE% set to 33 and %VARIABLE2% set to
13
|
Managing wire section |
In the Wire properties dialog
box of the macro, enter the variable %SECTION% for the
Section or gauge field. In Excel, you can
add an optional column, %SECTION% and input
the value of the wire size. |
Auto-connect wires |
To use this option, you must select
Auto-connect macros parameter in the
General tab in the electrical project
configuration. When you use the Excel Automation to create
schemes, you can automatically connect the wires or the symbols
between the existing scheme and the macro that you
insert.
The elements that you want to connect must be
aligned. You can connect wires to symbols or wires to
wires.
|
Managing Origin - destination arrows |
Consider two macros with an origin arrow placed in
one macro and a destination arrow placed in the other macro. When
you choose to insert both these macros using excel automation, you
can establish the connection between origin and destination arrows
in the two macros. In the macros, insert origin or destination
symbols in which you enter the same variable (for example:
%Group1%) as the group name.
In
the excel file, add a column using this variable. In this
column, enter the group name. All the symbols with the same
group name will be automatically associated.
|
Replacing a symbol while inserting a macro |
Consider a symbol inserted in a macro. When you
insert this macro from excel automation, you can replace this
symbol. Edit the macro and open the properties of the symbol.
Enter the variable, for example:
%SYMBOL_NAME% in the Excel
automation variable field.
in the excel
file, add a column using this variable
(%SYMBOL_NAME% in our example). In
this column, enter the name of the symbol that you want to
use.
#mac_name |
%SYMBOL_NAME% |
Test0 |
TR-EL002 |
Test0 |
TR-EL035 |
In this example, you insert the macro Test0, one time
with the TR-EL002 symbol and a second time with the symbol
TR-EL035, even if another symbol has been defined in the Test0
macro.
|