Would like to batch process the conversion of Tag Sets to Item Types

Background:

Running MicroStation CE Update 17.2  (10.17.02.61)

A client has hundreds of files in ProjectWise that we would like to convert the Tag Sets to Item Types.

My plan was to run Batch Process against the list of .dgn files within ProjectWise.  (This part is simple and works).

The Batch Process macro would call a VBA application that would convert the Tag Sets to Item Types.

There is a key-in that brings up the Upgrade Tag Sets dialog which is "dialog upgrade tag sets"

Issue:

The missing piece is I'm not able to check the "Select All" checkbox on the Upgrade Tag Sets dialog, nor can I click the "Upgrade" button.

What I tried:

The Upgrade Tag Sets dialog is a modal dialog, which means a simple key in without some additional code is not possible.

The typical way to deal with this in VBA is to create a class module and doing a macro record and promote to VBA does this for me:

(This code goes in a class.  In my case: clsTagsToItemTypes

Option Explicit

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 = "Upgrade Tag Sets" Then
        CadInputQueue.SendKeyin "ITEMTYPE DIALOG DESELECTALL "

        CadInputQueue.SendKeyin "ITEMTYPE DIALOG SELECT Upgraded Tag Sets"

    '   Remove the following line to let the user close the dialog box.
        DialogResult = msdDialogBoxResultOK
    End If  ' Upgrade Tag Sets
End Sub

The module code looks like this:

Option Explicit

Sub Convert_Tags_to_ItemTypes()
    Dim modalHandler As New clsTagsToItemTypes
    AddModalDialogEventsHandler modalHandler

'   The following statement opens modal dialog "Upgrade Tag Sets"
    CadInputQueue.SendKeyin "dialog upgrade tag sets shown"
    
'   Send a keyin that can be a command string
    CadInputQueue.SendKeyin "MDL KEYIN Bentley.CustomProperties, Bentley.CustomProperties DIALOG ITEMTYPE TOGGLE"

    RemoveModalDialogEventsHandler modalHandler
    CommandState.StartDefaultCommand
End Sub

The idea is that when the Upgrade Tag Sets dialog is loaded it calls the OnDialogOpened event inside of clsTagsToItemTypes.  That code sets the necessary field and clicks the Upgrade button.

What happens is the code in the class is never called.  I put a Breakpoint on the "If DialogBoxName = "Upgrade Tag Sets" Then" but we never hit that line of code.

It appears the Upgrade Tags Sets dialog does not initiate the modal Dialog event inside of MicroStation.

Questions:

1. If anyone sees that I'm doing something wrong I would appreciate knowing what it is.

2. If VBA won't work for this is there a way to call Upgrade Tag Sets directly within the C# Add-In (MDL) methodology.

There are VBA functions that deal with Item Types and I'm sure .NET functions that would deal with Item Types but not aware of a simple: Upgrade Tag Sets call.

Thanks for any, and all, help on this.

Mike

  • Hi Mike,

    1. If anyone sees that I'm doing something wrong I would appreciate knowing what it is.

    Well, I think you are not doing anything wrong as far as "steps done" are concerned, but the problem is in the target itself: As was discussed many times, it is generally impossible to interact with model dialog content (regardless what tool is used).

    2. If VBA won't work for this is there a way to call Upgrade Tag Sets directly within the C# Add-In (MDL) methodology.

    Different technology does not solve the problem. I checked how the discussed tool is implemented (and because it is in NET, based on standard MVVM pattern, it can be done ;-), and the process is very simple and "hidden from outside": The key-in opens model dialog and everything (content initialization, and the conversion, when button is pressed) is done inside.

    But what the dialog does is extremely simple, in fact it (only) collects the setting. The conversion itself is not the tool mechanism, but API functionality ... which is fortunate and unusual a bit, because often API is quite low-level and the process is implemented inside the tool.

    There are VBA functions that deal with Item Types and I'm sure .NET functions that would deal with Item Types but not aware of a simple: Upgrade Tag Sets call.

    Sure there are NET ItemTypes-related method (and API is very rich ;-)

    In NET API, ItemTypeLibrary class offers UpgradeTags method, so it is possible to implement own tool (not complex) with key-in, so it can be called in batch process.

    With regards,

      Jan

  • Hi Jan,

    Thank you for the reply.  I was teaching this week so slow to respond.

    In Item 1 above you mentioned: "model dialog content".  I'm thinking this was meant to be "modal dialog content".   You are correct that it is difficult to work with modal dialogs.  However, it can be done to a certain extent using the IModalDialogEvents.  Apparently, this works with some modal dialogs and not others.

    If I understand correctly from the rest of your explanation that, in this case I'm fortunate that the UpgradeTags is a method in the NET API and is actually what is directly called by the modal dialog.  This is perfect and what I was looking for.  Been a while since I wrote a NET add-on for MicroStation but in this case should be easy enough.  

    Thanks again for taking your time to respond.  It's very much appreciated.

    Regards,

    Mike