Thursday, December 20, 2012

Instrumentation symbols with automated numbers...(diesel macro)

Working in the Process and Mechanical field you come across a lot of things that need to be automated so that it makes things a little easier on you as a designer.  So, one of the latest Diesel macros that I wrote is for automated ISA Instrumentation symbols.  The good thing is that this code can be used to create user commands for all instrumentation symbols and it will flow seamlessly with each symbol placed. 

Okay, now to the code...

*^c^c$M=$(+,$(getvar,USERR1),$(getvar,USERR2));setvar;USERR1;
$M=$(+,$(getvar,USERR1),$(getvar,USERR2));-insert;
DISCRETE-PRIMARY;\1;1;\$(GETVAR,USERR1);LIT;;;

The first portion of the code prior to the insert command is doing the math to increment the variables in the symbol.  In this example you can see that we are using USERR1 & USERR2; where USERR1 is the initial number that you want to use, and then USERR2 is the variable that increases the value of USERR1. 

The coding for the insert command may vary, but for mine after I call the symbol name I have a \1;1;\.  This is the order of that bit of code...insertion point, scale x-coordinate, scale y-coordinate, rotation.

Once you go through that then the first attribute that is being filled in is the number; so, we tell it to get the USERR1 variable, and then the next one you can leave it as a user input by substituting "LIT" with "\".  Then depending on how many other attributes you have attached to the symbol you will need a semicolon for each attribute after the "LIT" for it to be able to repeat the command properly.

No comments:

Post a Comment