Often it is desired to add information what an AutoCAD drawing is printed or viewed. This is often the date it is printed, but it could be the user, file name or other information. This can be a static line that is output on all prints or dynamic based on the file, user or date.

Tailor Made Software’s AutoXChange has two methods for adding information to the output:

1: System Variables
2: Customer Watermark


The parameters necessary to define a Customer Watermark can be extensive, so it is usually better to use the JSON Parameter facility. An article about the JSON Parameters will be forthcoming, but for now you can look at the AutoXChange Technical Documentation.

Note: Some of the features listed here were added in AutoXChange V22.12.64

System Variables

AutoXChange allows the user to use certain System Variables in text strings. These were originally defined for use with MicroStation DGN files, but they work just fine with AutoCAD files too.

System Variables start and end with either three dollar signs ($$$) or three percentage signs %%%.

Since AutoCAD utilizes %% for special characters, it is really better to use $$$, but MicroStation allows either so AutoXChange does too. The same special code must be used front and back, so "$$$sysdate%%%" would not work.

Note: Non-Latin ASCII special characters, such as $ , can be obscured during data transfer. It is therefore safer to give them their corresponding HEX code preceeded with a % symbol. For example "$" is thus coded as "%24". Please reference the full ASCII Code Table.

The following System Variables are allowed in text strings:

Variable           Usage
sysdate Current system data (DD-MMM-YY, so 15-Jan-20)
systime Current system time (DD-MMM-YY HH:MM:SS)
dgnspec Full path name of input drawing
dwgspec Full path name of input drawing

Note: dgnspec and dwgspec are identical but it looks strange using “dgnspec” in an AutoCAD drawing and v.v.




Usage

System Variables are not a parameter driven item (except, see below for use with Customer Watermarks). Instead they are used as some or all of the content of a text element (either normal Text or MText) in an AutoCAD or MicroStation drawing.

Customer Watermark

A Customer Watermark is a text string defined by the customer (as opposed to the splash watermark you get when using a demo version of AutoXChange). The user can set the content, position, angle, color, etc. at runtime. A limited amount of on-the-fly customization is allowed using the same capability as defined above in System Variables.

The text string can be single or multiple line text. To create a multiple line string then use a line feed, /P, in the string.

The basic call for the Customer Watermark:

-wm_con="Plot created on/P$$$sysdate$$$" -wm_layout=plan  -wm_anchor=90B23A5 -wm_height=6 -wm_x=10 -wm_y=5 -wm_angle=30d 



Parameter            JSON Name            Usage
-wm_con[tent] WM_Content Content
-wm_lay[out] WM_Layout AutoCAD Layout, default is ModelSpace
-wm_anc[hor] WM_Anchor Handle of line or point to define position
-wm_x WM_X Horizontal (X) position
-wm_y WM_Y Vertical (Y) position
-wm_height WM_Height Text height
-wm_angle WM_Angle Text angle (assume radians, append a 'd' for degrees)
-wm_fontstyle WM_TextStyle Font Style to use
-wm_col[or] WM_Color AutoCAD Color Index
-wm_rgb WM_RGB Color by RGB values

Note: for parameters listed with [] in the command, the part before the brackets is required, but pretty much anything could be used after the requires part and still work. So -wm_continent would work for Content, since it starts with the required -wm_con.

Note: Parameters and JSON Names are case non-sensitive

Position

The position of the watermark can be based on:


1: Defined x and y absolute coordinates
2: Percentage of height and width of the drawing
3: Lower left coordinates of a line or point
4: Relative coordinates from a line or point


The wm_x and wm_y parameters define the lower left coordinate of the watermark.

If a percent sign follows the value (“wm_x=45%”) then the width or height of the drawing is used to calculate the position. Positive percentages are from the left or bottom of the drawing, while negative percentages are from the right or top.

-wm_x=400 -wm_y=20

The position will be (400,20).

-wm_x=40% -wm_y=-20%

If the drawing is 200 wide and 100 high, then the position is be 40% in from the left side (160) and 20% down from the top (20).

When using the Anchor command, the position is based on the position of a line or point whose Entity Handle is listed. If the Entity Handle is not present in the file or if it is something other than a point or line, then it is ignored and the Customer Watermark will not be added.

-wm_anchor=90B23A5

It is also possible to define the position relative to the anchor.

-wm_anchor=90B23A5 -wm_x=20 -wm_y=10

The position will be the anchor position plus 20 in the x and 10 in the y. Percentages CANNOT be used to define relative offsets.

Angle

The angle the Watermark is rotated by is given in Radians by default. If degrees are desired, then append a small “d” to the measurement. Zero is the horizontal axis. Angles are defined counter-clockwise, so 90 degrees (1.5708 radians) would be vertical.

-wm_angle=1.5708
-wm-angle=90d

Both parameters would define 90 degrees or 1.5708 radians.

Text Style

The wm_textstyle or wm_style parameter lists a Text Style from the input file to be used. If the Text Style is not found, the default Text Style is used instead.

For backwards compatibility, the parameter wm_font will also work for Text Style but was misnamed. This is the Text Style, not the actual font name.

-wm_textstyle=Standard

Color

There are two Color Modes supported:

1: AutoCAD Color Index
2: Nearest AutoCAD Color Index based on RGB value


The first is very straightforward. The value listed is the AutoCAD Color Index and the AutoCAD Palette is based on the DWG file being converted. The values range from 0 to 255.

-col=3

That would use AutoCAD Color Index 3, or Green.

The second method takes the RGB value listed (where Red, Green and Blue are listed in that order and each ranges from 0 to 255 - (0,0,0) being Black and (255,255,255) being White) and figures out the closest AutoCAD Color Index. So the RGB value may not be matched precisely but rather the nearest ACI is used.

-wm_rgb=(0,55,102)

This would match to a Dark Blue, probably ACI 176 or 186.

Note: Color and RGB are mutually exclusive

Defining Customer Watermark via JSON

There are a lot of parameters to set to define a Customer Watermark. For this reason it is often preferable to use a JSON Parameter File to define the parameters. You can define some via JSON and others via the normal parameters if there are some that are static and others that change for different file conversions.

The parameter to use a JSON Parameter File is simple:

-json=<parameter_file_name>.json

A sample JSON Parameter File to just define the Customer Watermark parameters:

{
	"General": {
		"wm_contents" : "Plot created on/P$$$sysdate$$$",
		"wm_layout" : "plan",
		"wm_anchor" : "90B23A5",
		"wm_height" : 6,
		"wm_x" : 10,
		"wm_y" : 5,
		"wm_angle" : "30d"
	}
}


A sample JSON Parameter File to define the Customer Watermark parameters, but using the %HEX code instead of $ sign:

{
	"General": {
		"wm_contents" : "Plot created on/P%24%24%24sysdate%24%24%24",
		"wm_layout" : "plan",
		"wm_anchor" : "90B23A5",
		"wm_height" : 6,
		"wm_x" : 10,
		"wm_y" : 5,
		"wm_angle" : "30d"
	}
}




Do Download the Article!

ENJOY - and get in touch!