Archive | October 2012

Managing Usability

by Mark Stefanchuk,

[Update: Be sure to check out Kim’s comment – a great alternative using the F1 key and choose none. Thanks Kim!]

I’ve been debating whether or not to share this with my MicroStation peeps. I hesitate because I don’t like to admit that sometimes I don’t adjust to change as quickly as I should, but also because this example has some conflict with features in MicroStation V8i that we wouldn’t introduce normally, especially if we don’t have to. What am I talking about?

Earlier this year I was working with a client helping them upgrade from MicroStation 2004 to V8i SS2. Not as big of a jump from V7 to V8, but big enough. Things were missing and commands didn’t work the same way. Years ago we could rely on commands that were in the previous version to work the same way in the new version. Today, it’s not that way. And seriously, there are good reasons for change, like productivity gains. I’m all for that. In this case however, it was clear that the user base missed some of the key operations that made MicroStation, well MicroStation and not AutoCAD.

For example, in older versions of MicroStation when you were done with a selection created using power selector you would use the right mouse button to deselect (reset). In V8i you just use the right mouse button (a datapoint in the view). That’s seems pretty easy. But if you have been drafting for years using the same workflow not being able to use something so simple as the reset button to deselect a selection set can be really frustrating.

Now, I was the consultant and I really wanted my client to be happy so I fixed it. I built an MDL application that would watch for reset. When the user clicks reset any active selection set would be removed. The command is very primitive, but I thought I would share in case you might have a similar issue. There’s not much to it – comments below.

#include    <mdl.h> 
#include    <tcb.h> 
#include    <dlogitem.h> 
#include    <dlogids.h> 
#include    <rscdefs.h> 
#include    <mdlerrs.h> 
#include    <userfnc.h> 
#include    <global.h> 
#include    <mselems.h> 
#include    <accudraw.h> 
#include    <cexpr.h> 
#include    <math.h> 
#include    <string.h>

#include    "ps_resetcmd.h" 
#include    "ps_reset.h" 
#include    "fdf.fdf"

int goFlag; // a flag to watch for active commands that might conflict
// the event watcher
Private int monitorQueue ( Inputq_element *queueElementP ) 
    char sCmd[256];         
    sprintf(sCmd, "%S", mdlState_getCurrentCommandName());     

    // Element Selection Active     
    if (strcmp(sCmd, "Element Selection") == 0)
        goFlag = 0;  

    // a quick a dirty way to watch for active command - be careful with upgrades because this might not be
    // supported in the future. - not very elegant but it works - I'm a little bull headed that way.
    if ((strcmp(sCmd, "Dimension Element") == 0) || (strcmp(sCmd, "Dimension Linear Size") == 0) 
        ||   (strcmp(sCmd, "Dimension Angle Size") == 0) || (strcmp(sCmd, "Dimension Ordinates") == 0) 
        ||   (strcmp(sCmd, "Change Dimension") == 0) ||   (strcmp(sCmd, "Drop Dimension Element") == 0)
        ||   (strcmp(sCmd, "Dimension Size Perpendicular to Points") == 0) ||   (strcmp(sCmd, "Dimension Diameter") == 0) 
        ||   (strcmp(sCmd, "Label Point Coordinate") == 0) || (strcmp(sCmd, "Dimension Symmetric") == 0) 
        ||   (strcmp(sCmd, "Dimension Half") == 0) || (strcmp(sCmd, "Dimension Chamfer Angle") == 0) 
        ||   (strcmp(sCmd, "Dimension Diameter Perpendicular") == 0) || (strcmp(sCmd, "Dimension Radius (Extended Leader)") == 0) 
        ||   (strcmp(sCmd, "Place Center Mark") == 0) || (strcmp(sCmd, "Dimension Radius") == 0) 
        ||   (strcmp(sCmd, "Dimension Arc Distance") == 0))  
        goFlag = 1; // the active command is a dim command so dont deselect on reset
       goFlag = 0; // ok to reset - conflict mitigated  

    // user clicked reset and conflict minimized so go for it
    if (queueElementP->hdr.cmdtype == RESET)  
        if (goFlag == 0)    
            mdlInput_sendKeyin ("powerselector deselect", 0, 0, NULL);
    return INPUT_ACCEPT;

// command entry
int main () 
    RscFileHandle   rfHandle;  
    goFlag = 0;

    mdlResource_openFile (&rfHandle, NULL, FALSE);

    if (mdlParse_loadCommandTable (NULL) == NULL)  
        mdlOutput_rscPrintf (MSG_ERROR, NULL, 0, 4);

    mdlInput_setMonitorFunction (MONITOR_ALL, monitorQueue);
    return  SUCCESS; 

The conflict was created by sending a command, i.e. powerselector deselect, when commands that you didn’t want to terminate using reset were active – like dimension commands. The easiest way to work around this was to set a flag. If one of the dimension commands is active then don’t deselect on reset. The code and compiled is on Put the ma in your mdlapps folder so it will load when MicroStation is loaded. You can also use the keyin mdl load ps_reset to load this app.

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 by contacting us at

CAD Management – Resource Style

by Mark Stefanchuk,

Seth and I have been a somewhat focused on resources lately, but for good reason. Things like layers, blocks, and styles (lines, dimensions, tables) are assets that are created and recreated from project to project and it seems like this is a bit of extra work.

Of course we can use templates and standards, but there always seems to be a page setup or table style missing – one that we created for a project we were working on just last week. And boy wouldn’t it be great if I could get all of those things with a quick click.

The import of many of these assets is pretty straight forward code wise, so I’m going to “give away the store” (or just a small portion of the store) and show you how you can do this yourself. I’ll then introduce you to our next Exchange App that we expect will be ready by the end of November.

In this example I’m going to show you how to get text styles from an external DWT, DWS, or DWG file (the sourceDb) and bring these into the current DWG (the destDb). We will use VB.Net. Here’s the code listing. Comments embedded.

'use the following: 
Imports Autodesk.AutoCAD.Runtime 
Imports Autodesk.AutoCAD.ApplicationServices 
Imports CADAPP = Autodesk.AutoCAD.ApplicationServices.Application 
Imports Autodesk.AutoCAD.DatabaseServices 
Imports Autodesk.AutoCAD.EditorInput 

'string library_path => the file spec of the source dwt, dws, or dwg file 
'DuplicateRecordCloning clg => Replace or Ignore - how to handle text styles with the same name 
Private Sub cmr_getTextStyles(ByVal library_path As String, ByVal clg As DuplicateRecordCloning)
'connect to current database
Dim dm As DocumentCollection = CADAPP.DocumentManager
Dim doc As Document = dm.MdiActiveDocument
Dim ed As Editor = dm.MdiActiveDocument.Editor
Dim destDb As Database = dm.MdiActiveDocument.Database
Dim sourceDb As Database = New Database(False, True)

    Using dl As DocumentLock = doc.LockDocument()
    'connect to the external dwt, dws, or dwg
    sourceDb.ReadDwgFile(library_path, System.IO.FileShare.Read, True, "")

    'create a container for our text styles
    Dim textsToClone As ObjectIdCollection = New ObjectIdCollection()
    Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = sourceDb.TransactionManager

    'start a transaction with the external drawing
    Using tr As Transaction = tm.StartTransaction()

        'get the text style ids
        Dim ldt As TextStyleTable = TryCast(tm.GetObject(sourceDb.TextStyleTableId, _
            OpenMode.ForRead, False), TextStyleTable)

        'save the ids in an object collection
        For Each txtID As ObjectId In ldt

        ' Add text styles to the current drawing
        Dim mapping As IdMapping = New IdMapping()
        sourceDb.WblockCloneObjects(textsToClone, destDb.TextStyleTableId, mapping, clg, False)
        'commit the sourceDb transaction (even for read)
    End Using
End Using
Catch ex As Autodesk.AutoCAD.Runtime.Exception
End Try
End Sub

You can use this same pattern for dimension styles, multi-leader styles, table styles, line types, and page sets. Layers, and blocks are similar but require some extra effort.

So, what about that next app? Seth and I have been working on a new app for Autodesk Exchange and expect to have it published shortly. So, if you don’t want to tackle importing resources yourself then you can download our version. DWG Resource Importer consolidates these operations into a convenient palette allowing you to quickly import resources from templates, standard files, and drawing files. Here’s what you can expect to see.

Select the resources to import – layers, blocks, line styles, dimension, and more…

Import the resources and if you want to refer back to the report later you can save it.

There’s no reason anyone on your team should have to recreate resources from project to project. Whether you develop your own import palette or use one like DWG Resource Importer your team will save production hours.

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 by contacting us at

RevFiles, Cool App

by Seth Cohen,

Last month, we talked about resources.  Well Mark and I were thinking about resources and one of the problems that a CAD Manager, or single user managing CAD, encounter is that the list of resource files can get pretty big. And, what if you have files with the same name, and you want to navigate to where the conflict is?  No easy task.  So, we had this great idea of an AutoCAD App that would review the resource files for you, and we called it Review Files (REVFILES for short)

We’re still in-process of getting it up on Autodesk Exchange, but here’s a little preview of it.  RevFiles has a palette interface.  First, to load it up, click the icon in the Plug-ins tab.

Review Files App

Review Files App

When you first load it up, it shows all the files and their folder locations of files being used by your current AutoCAD profile. Below is a breakdown of the Review Files palette.

Review Files Palette

Review Files Palette

Whats really cool about the app is that you can export the list to a .CSV file (Comma Separated Values), and double-click any of the folders or files to navigate to (really cool, and time-saving).

Look for the RevFiles app on Autodesk Exchange coming soon!

“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