.SetVariable "MEASUREMENT", 0 'Sets units as imperial or metric for the current drawing only

.SetVariable "ANGDIR", 0 'Sets the direction of positive angles. Set to Counterclockwise

.SetVariable "ANGBASE", 0# ' Sets the base angle to 0 with respect to the current UCS.

.SetVariable "INSUNITS", 1 ' Specifies units for drag & dropped blocks or images. Set to Inches End With

setUnits = True

Exit FunctionErrorHandler: ' Insert error handler hereEnd Function

No real magic here, we're just setting a few system variables. Call the above routine with the following line:

If Not setUnits Then GoTo ErrorHandler

Now we can focus on layer modification. Layers can get a bit tricky so we have to be careful what we do. I found out the hard way that you can set a layer's colour to black and it will be invisible if your workspace background is black. Note to self: make a routine that loops through all layers and sets their colours to black to annoy coworkers. We'll also create a few helper routines to set a layer current, check if a layer already exists and if it is locked.

It seems more complicated than it should be (and it might be) but it works well. If you only use the base 16 or 255 colours, you can rip out the entire "setColor" section and just pass the routine a colour code. Call the above routine with the following line: