Ad

Monday, July 20, 2009

Run a Command not Using the Default Style – Station Offset

Sometimes you want to use an alignment station offset label which isn’t the default label style in the drawing. Yes, you could use the label dialog box, but if you are using the same station offset label over and over it can create extra steps. This post will use VBA and the cui to create a toolbar icon to use a different label to do a station offset label other than the default value.

The first step is to create a VBA macro that will change the default value to the label style we want. As a starting point I’m using the StartingPointProject.

image

The code sets the default label style as “Different Style” instead of the original one. Of course you would need to change the name to match the one you want to use. The first part of code makes sure Civil 3D is running.

Next a macro needs to be created to set the default style back to what it was originally.

image

The above code sets the style back to “Standard”. Of course you would want to change “Standard” to match your template.

We have to use two macros since we can’t pause a VBA macro, at least that I know of. So instead of doing it in one macro I’m going to use the cui to add the pause needed to place the label. To add the command to the cui type cui at the command prompt and then press the new command button.

image

Next give the command the name and add the macros to the command along with some pauses “\”.

image

The command is below:

^C^C-vbarun;"C:/Users/Christopher/Documents/Autodesk/AlignStaOffLabel.dvb!Module1.AlignOffLblChange";AddAlignOffLbl \\\;-vbarun;"C:/Users/Christopher/Documents/Autodesk/AlignStaOffLabel.dvb!Module1.AlignOffLblDefault";

Make note that the macro file location has the “\” reversed. Now when you run it should pause enough to place on label. Unfortunately you can’t place more than one label. You can add the command to a toolbar or the ribbon.

Here’s a quick video of it in action from a toolbar:

http://screencast.com/t/FuAxzJugo 

You can do the same for the other label commands. Just make sure to have enough \ to match the needed prompts to add the label and change the code to change the default label style.

No comments:

LinkWithin

Blog Widget by LinkWithin

Ad