Match Icon Check Boxes

Many years ago I created a MicroStation basic macro that would check the boxes of the match element command. At the time, MicroStation J did not save these settings, so every time you used the command you would have to check the boxes for the element attributes you wanted to change. In MicroStation V8i these settings are saved, so you only have to check the boxes one time. The basic macro (before VBA) was really simple and you could record it using the record macro dialog. VBA of course is just as easy – as we will see in a moment.

match01

Do we still need a macro like this one? If you want all options on, or all off then there may still be room in your toolbox for this macro.  It’s easy enough to record the action of checking these boxes (and unchecking the boxes). You can then add these new commands to your MicroStation menus. I like the idea of adding a couple of extra commands in my tasks menu, but adding new icons to the toolbox or pull down menu can work too.

To record the macro, open the VBA Project Manager dialog – Utilities | Macro | Project Manager.

match02

The project manager dialog will open.

match03

Before we record the check boxes we need to start the Match command. You can select the command from the Task menu, or type the keyin “match icon”.

The settings dialog changes to show the Match Element Attribute controls.

match04

To record, highlight the Default VBA and then click the red button in the Project Manager dialog. Check the boxes.

match05

Now, click the stop button (white square) in the Project Manager dialog.

match06

Open the Visual Basic Editor (icon that looks like a dialog box – to the right of the triangle).

match07

The visual basic editor will contain the macro you just recorded. It will look similar to the following.

match08

You can remove all of the Dim statements because these are not used. Remove the second last line too, CommandStatement.StartDefaultCommand. This command will stop the match command and select your default command (usually smart selector). Finally, remove all of the extra lines. The finished macro will look like this.

match09

Repeat these steps but uncheck the boxes. Or, copy and paste Macro1 (change the new sub name to Macro2). Replace the value -1 with 0. This new macro will uncheck all of the boxes.

match10

If you want a different name for a macro, just change the sub name. Instead of Macro1() you could replace that with MatchChkAll() and for Macro2() maybe this could be MatchChkNone().

To run the vba you can use the keyin, vba run Macro1. But, we also want to make sure tha the Match Element Attributes command has been started. So, use the following keyin,

match icon;vba run Macro1

Run this keyin from the keyin browser, add an icon to the Change Attributes toolbox and maybe create a new task. With just a little bit of effort you can optimize your workflows and create a more productive CAD environment.

About Mark Stefanchuk: Mark is a VP and senior consultant with CAD Management Resources, Inc. He divides his time between developing innovative custom software solutions and helping clients navigate complex design automation environments. If you would like to find out how he can assist you with your design technology he can be reached directly at mstefanchuk@cadmanage.com.

photoDGN Beta

Transparent Dialogs

by Mark Stefanchuk, cadmanage.com

I was playing around with MicroStation preferences the other day and something was bugging me. Turning on/off dialog transparency was clumsy. I know it’s a user preference and that it’s normally on or normally off, but opening the preferences dialog, finding the transparency preference seemed to be more cumbersome than it should be. It was definitely not quick. In this case I just want to switch on/off the dialog transparency without having to go through the steps of opening checking and clicking ok – just to turn transparency on. Call me lazy.

So, to shorten the steps, I used the VBA macro recorder to capture the actions needed to turn on transparency.

To record the macro, open the VBA Project Manager dialog – Utilities | Macro | Project Manager. The project manager dialog will open. Select the Default project in the VBA Project Manager. Click the red circle to start recording.

td01

Go to Workspace | Preferences | Look and Feel. Check the box, “All modeless dialogs use the same transparency”.

td02

Click OK. Click Stop in the VBA Project Manager (the square white button).

td03

I then cleaned up (deleted) all of the extra lines of code that the recorder adds. That is, the lines we don’t need.

This records the steps in your VBA. It creates a new Macro and a Macro Handler (to control the dialog box). The recording process adds a lot of extra code that we don’t need. You can remove the extra code. Your code will look similar to the following when you are done.

Sub Macro1() 'turn on dialog transparency
  Dim modalHandler As New Macro1ModalHandler
  AddModalDialogEventsHandler modalHandler
  CadInputQueue.SendCommand "MDL SILENTLOAD USERPREF"
  RemoveModalDialogEventsHandler modalHandler
End Sub

And the handler will look similar to the following.

Implements IModalDialogEvents
Private Sub IModalDialogEvents_OnDialogClosed _
  (ByVal DialogBoxName As String, _
  ByVal DialogResult As MsdDialogBoxResult)
End Sub
Private Sub IModalDialogEvents_OnDialogOpened _
(ByVal DialogBoxName As String, _
DialogResult As MsdDialogBoxResult)
  If DialogBoxName = "Preferences [untitled]" Then
    '   Set a variable associated with a dialog box
    SetCExpressionValue "savePrefs.addFlags.dialogsUseSameTranparency", 1, "USERPREF"
    '   Remove the following line to let the user close the dialog box.
    DialogResult = msdDialogBoxResultOK
  End If  ' Preferences [untitled]
End Sub

The Macro is saved in Module1 and the handler is saved in the Class Module folder of the VBA. The macro opens the preferences dialog. It also starts and stops the event handler. The handler does the work. It turns on the transparency. All of this is built for you when you record the macro. All you have to do is remove the code that you don’t need.

Next, we want a command to turn off the transparency. Just copy Macro1 and rename it as Macro2. Change Macro1ModalHandler to Macro2ModalHandler.

Sub Macro2() 'turn on dialog transparency
  Dim modalHandler As New Macro2ModalHandler
  AddModalDialogEventsHandler modalHandler
  CadInputQueue.SendCommand "MDL SILENTLOAD USERPREF"
  RemoveModalDialogEventsHandler modalHandler
End Sub

Now, create a new class module called Macro2ModalHandler. Copy the contents of Macro1ModalHandler to this new class module. Finally, in the line that starts with SetCExpressionValue, change the 1 to a 0 (i.e. on to off). Like this.

Private Sub IModalDialogEvents_OnDialogOpened _
(ByVal DialogBoxName As String, _
DialogResult As MsdDialogBoxResult)
  If DialogBoxName = "Preferences [untitled]" Then
    '   Set a variable associated with a dialog box
    SetCExpressionValue "savePrefs.addFlags.dialogsUseSameTranparency", 0, "USERPREF"
    '   Remove the following line to let the user close the dialog box.
    DialogResult = msdDialogBoxResultOK
  End If  ' Preferences [untitled]
End Sub

The last thing we want to do is add these commands to the UI so that we have and easy way to run the commands.To do this I added a new dgnlib to my workspace. I’m using the default untitled workspace, so I added the dgnlib to $(MS)\Workspace\projects\untitled\DGNLIB\. While in the dgnlib, open the Customize dialog box – Workspace | Customize. Add a new toolbox and two new tools. Change the names as shown in the image below.

td04

On the first tool change the Key-in to vba run macro1. This will run the macro that turns off dialog transparency. On the second tool change the Key-in to “vba run macro2”. I’ve also changed the icon. The default tool icon is the wrench. You can select any icon you want. I just took a couple of icons from ustation.rsc (tools I don’t use very often).

Now, right click on the new toolbox name and select “Open Tool Box”.This is what mine looks like.

td05

You can dock this on your MicroStation window. I dock mine at the top so that I can quickly access these buttons. So, now I can control dialog transparency without multiple clicks.

td06

td07

About Mark Stefanchuk: Mark is a VP and senior consultant with CAD Management Resources, Inc. He divides his time between developing innovative custom software solutions and helping clients navigate complex design automation environments. If you would like to find out how he can assist you with your design technology he can be reached directly at mstefanchuk@cadmanage.com.

photogeoDWG

VBA Custom Configs

by Mark Stefanchuk, cadmanage.com

I’m not really a big fan of increasing the number of MicroStation config variables. Where possible, try to use built in variables. For example, you can use CreateCellElement3

with just the name of the cell as long as the cell library is defined in MS_CELLLIST. You might have something that looks like this in your VB code.

oCell = MainForm.oMSApp.CreateCellElement3(MainForm.uc_o.txtCameraName.Text, Point, True)

This is from a VB.Net example, that’s why the MicroStation Application object is included.

Here’s how I might define MS_CELLLIST for use with photogeoDGN.

CADMANAGE = C:/ProgramData/Cadmanage/PhotogeoDGN/Contents/
MS_ADDINPATH < $(CADMANAGE)Windows/8.11/
MS_CELLLIST < $(CADMANAGE)Resources/*.cel

Sometimes however, it is necessary to identify a special folder or some other resource in your custom program. For example, your program might include a catalog file that provides some engineering data that your program will associate with a cell. You could decide to put this in a resources folder that is always in the install directory. But, a better solution might be to let the end user decide where she wants to save the resource. In this case the resource or file is one that MicroStation doesn’t know anything about, but your program has to be able to find. To fix that we could define the following,

CMRI_CATALOG = $(CADMANAGE)Resources/testcatalog.xml

Put the variable in one of MicroStation’s configuration files, like your UCF. Now, to access the variable from your custom VBA program you need to use ConfigurationVariableValue. Here’s how to do that in VBA.

Sub testConfig()
Debug.Print ActiveWorkspace.ConfigurationVariableValue("CMRI_CATALOG")
End Sub

The example will print the value of the configuration variable in the VBA IDE’s immediate window.

C:\ProgramData\Cadmanage\PhotogeoDGN\Contents\Resources\testcatalog.xml

Use this expansion to open the file, or in this case define your XML document object.

As long as the variable name is different than any other MicroStation config variable, you can use it, but I would recommend  including a prefix. In the previous example, I used CMRI (for CAD Management Resources, Inc). This just helps to avoid variable conflicts.

About Mark Stefanchuk: Mark is a VP and senior consultant with CAD Management Resources, Inc. He divides his time between developing innovative custom software solutions and helping clients navigate complex design automation environments. If you would like to find out how he can assist you with your design technology he can be reached directly at mstefanchuk@cadmanage.com.

photogeoDWG

photoDGN Beta

The National Map Viewer

There’s a great resource for those of you who use U.S. imagery in their projects. The National Map Viewer is a great resource. Also, be sure to check out Brian Hailey’s post from last year – An Alternative to Google Earth. He highlights the accuracy issue and provides some instruction for using the national map viewer (previously called seamless viewer). Brian includes a link in his article to a Being Civil post that provides detail for this issue. Check it out.

Spring FLUG!

SpringFlug_Banner

SpringFlug_Copy1

FLUG offers you the opportunity to make connections with industry peers, exhibitors, and even your own colleagues from other offices to solve a problem you recently encountered?

Engage in hands-on, face-to-face instruction with Industry experts who have faced similar challenges to yours.

  • Explore the many new product capabilities you aren’t using yet to determine how you can take advantage of them
  • Glean best practices and insider tips and tricks to create new efficiencies in your workflows
  • Collaborate with developers to extend the use of your software

For over 25 years, FLUG one of the countries longest running and most successful Users’ Conference and Training Events, offers you the tools to best leverage your software to better meet your strategic objectives, make the most of your resources, and stay ahead of your competition.

Check out our Agenda:

Visit our website, www.flugsite.com. Under the Main Menu portion of the webpage you will find a link to for the current Spring Agenda. A few highlights include….

  • Tips and Tricks in MicroStation V8i
  • DWG Interoperability with MicroStation V8i
  • Point Clouds
  • AECOsim Building Designer
  • Bentley Navigator
  • Corridor Modeling
  • Autodesk Revit Architecture
  • Civil 3D Plans Production
  • GEOPAK Terrain

How do I register to attend FLUG?

That is easy, visit our website, www.flugsite.com. Under the Main Menu portion of the webpage you will find a link to both the current Spring Agenda and to Registration. Click the Registration link and follow the guided registration process.

Hotel Information:
Radisson Resort at the Port
8701 Astronaut Blvd.
Cape Canaveral, FL 32920 Phone: (321) 784-0000 Visit us at http://www.radisson.com/capecanaveralfl The Radisson is using a new online registration system to reserve your discount FLUG rooms. For the FLUG Government Rate (ID required at check in) please use the following link, http://www.radisson.com/fluggovernment. For the FLUG Non Government Rate please use the following link, http://www.radisson.com/flugnongovernment.

PhotogeoDGN Beta Available for Download!

by Mark Stefanchuk, CADmanage.com

In case you missed it, we have uploaded PhotogeoDGN beta. The same features in the popular photogeoDWG are available in this MicroStation version. Help us out and be among the first users to test drive the new add-in.

photogeo_bnr_dgn_beta

Civil 3D Offset Alignments

by Seth Cohen, CADmanage.com

Civil 3D offest alignments are a great way to add transitions into your design that subassemblies can then target.

I have had many users get a little confused as to how to enter the stationing.  When you first start using offset alignments, you add the full offset width stations, and not the station to station limits of the transition area.  A very easy way to add the transition after you add the offset distance, is to simply select the Transition Grips.  To make the transition grips appear, select the offset alignment, and click the large circular grip.

Click to get Transition Grips

Click to get Transition Grips

Next, select one of the Transition Segment Length grips (make sure you have Dynamic Input turned on), and type the station where the transition should begin/end, depending on which grip you select.

Transition Segment Length Grip

Transition Segment Length Grip

It’s that easy.

“Now you know, and knowing is half the battle.”  …………G.I. Joe

Click Here to Get The best Training Ever

About Seth Cohen: Seth is Vice President of Training  at CAD Management Resources Inc., specializing in civil engineering and CAD applications including Civil 3D®, Map 3D, AutoCAD®, MicroStation®, and InRoads®. He has conducted many classes for CAD professionals ranging from commercial to  government organizations.  If you would like to find out how he can assist you with your training needs he can be reached by contacting us at info@cadmanage.com.