VBA test if dgn checked out from ProjectWise

I am writing a microstation vba that is only intended to operate on the active dgn file if it hasn't been checked out of ProjectWise. Although I could look at the full filename of the activedgn, that only indicates the path, (like c:\pwise\....) and someone could conceivably copy out a file, or just have a file created in one of the PW working subdirectories. Is there a configuration variable, or some other way I can find out if it the dgn file has been checked out?

 

Thanks,

Stephanie

Parents
  • Stephanie,

    There are two cases typically involed with with MicroStation and ProjectWise integration from a VBA perspective.

    One is how to tell if your MicroStation session is integrated with ProjectWise so your VBA code can react accordingly.

    The first case is rather easy to do by check to see if ProjectWise's MicroStation integration is actively loaded (mcm.ma).  Here is some code to do that check:

    Sub TEST_MDLIsLoaded()
    
       Dim bResult As Boolean
       bResult = MDLIsLoaded("mcm")
       Debug.Print "MDLIsLoaded: " & bResult
    
    End Sub
    
    Public Function MDLIsLoaded(sAppName As String) As Boolean
    
       Dim strExpr As String
    
       ' Find MDL application by name
       strExpr = "mdlSystem_findMdlDesc(""" & sAppName & """)"
       MDLIsLoaded = MicroStationDGN.Application.GetCExpressionValue(strExpr)
    
    End Function

    The second is to call/declare Native code C functions from the ProjectWise API in VBA.  This gets tricky since you will likely be declaring quite a bit of C code to call in VBA.  In fact, most developers in this situation end up coding simple wrapper functions in a C/C++ library (.dll) that can be called from VBA in a simple and more straight-forward sense w/o needing to declare as many external functions and types that will be required.  It also makes debugging your code and the ProjectWise API much more simple and straight-forward.

    WRT your more specific question.  Currently there is no MicroStation (or ProjectWise) configuration variable stating which document(s) are checked out on a client.  Depending on the workflow and/or restrictions, this could be a very large number of documents and their respective paths.  In the ProjectWise API you could use: aaApi_IsDocumentCheckedOutToMe() where you can provide a project number and computer node, or you can check the active MicroStation design file currently open to see if it is checked out (to you) using mdmMain_getActiveMDocument().

    HTH,

    Bob

    Sub TEST_MDLIsLoaded()
       Dim bResult As Boolean
       bResult = MDLIsLoaded("mcm")
       Debug.Print "MDLIsLoaded: " & bResult
    End Sub
    
    Public Function MDLIsLoaded(sAppName As String) As Boolean
       Dim strExpr As String
    
       ' Find MDL application by name
       strExpr = "mdlSystem_findMdlDesc(""" & sAppName & """)"
       MDLIsLoaded = MicroStationDGN.Application.GetCExpressionValue(strExpr)
    End Function



    Answer Verified By: Stephanie Doherty 

  • Unknown said:

    strExpr = "mdlSystem_findMdlDesc(""" & sAppName & """)"

       MDLIsLoaded = MicroStationDGN.Application.GetCExpressionValue(strExpr)

    A simpler test uses mdlSystem_getTaskStatistics.  Here's VBA example IsMdlLoaded.

     
    Regards, Jon Summers
    LA Solutions

  • both GetCExpressionValue and the mdlSystem_getTaskStatistics are not working with MicroStation Connect vba. (I added ptrsafe in the declare)

    the mdlSystem_getTaskStatistics errors with Can't find DLL entry Point mdlSystem_getTaskStatistics in stdmdlbltin.dll.

    also the link above it dead... I found it here

    http://www.la-solutions.co.uk/content/V8/mvba/MVBA-IsMdlLoaded.htm

    do you have anything for test this for microstation connect vba?

  • mdlSystem_getTaskStatistics errors with Can't find DLL entry Point mdlSystem_getTaskStatistics in stdmdlbltin.dll.

    also the link above it dead... I found it here

    @Robert Hook helped to find the problem.  To compound the confusion, you were looking on our web page for MicroStation V8i.  Here's the page to visit for the CONNECT version of IsMdlAppLoaded.  Note the changes to the MDL function declaration:

    1. The DLL where the function is implemented differs from the 32-bit declaration
    2. The app. name String has to be wrapped in undocumented VBA function StrPtr() because the call to an MDL function doesn't automatically cast the C++ Unicode string correctly

     
    Regards, Jon Summers
    LA Solutions

Reply
  • mdlSystem_getTaskStatistics errors with Can't find DLL entry Point mdlSystem_getTaskStatistics in stdmdlbltin.dll.

    also the link above it dead... I found it here

    @Robert Hook helped to find the problem.  To compound the confusion, you were looking on our web page for MicroStation V8i.  Here's the page to visit for the CONNECT version of IsMdlAppLoaded.  Note the changes to the MDL function declaration:

    1. The DLL where the function is implemented differs from the 32-bit declaration
    2. The app. name String has to be wrapped in undocumented VBA function StrPtr() because the call to an MDL function doesn't automatically cast the C++ Unicode string correctly

     
    Regards, Jon Summers
    LA Solutions

Children
No Data