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
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
Answer Verified By: Stephanie Doherty
Robert,
If I understand this correctly, (and I've tested it) then the "MicroStation session is integrated with ProjectWise" (mcm.ma) only tells me that ProjectWise itegration is valid, not that the file has been opened from ProjectWise?
To test whether a file has been opened from PW I test for several indicators; the "MCMTB"; the PW DMS Folder Name; and the PW_WORKDIR.
I tested the first suggestion and it worked fine. Thanks, Bob.
I am running version V8i SS2 for ProjectWise and MicroStation. The "mcm.ma" has only worked reliably for us in identifying that integration exists. This alone has not proven reliable for identifying that a DGN was opened from ProjectWise. I would love to see a reliable mechanism provided by Bentley for this requirement.
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
cweber - yes mcm.ma is only letting you know that the MicroStatio ProjectWise integration (mcm.ma) is "active". Some MicroStation VBA apps should perform this check in a ProjectWise integrated environement and modify any file or metadata workflows accordingly. The aforementioned functions I referred to are only available in the ProjectWise API and can be used to determine if a document is in a checked out state on a certain computer. There are even more ProjectWise API functions available to help answer various other questions as well. e.g. You may want to check the audit trail history on a given document and present that information to the user for reporting or some additional context action. There is a lot you can do; however the current best practices are to create your ProjectWise specific customizations in their own stand-alone .dll (that would reside in the ..\ProjectWise\bin directory) and have your VBA or .NET code call your simplified "wrapper" functions that can easily be debugged accurately in Microsoft Visual debuggers (VBA or VisualStudio).
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?
John Drsek said:
mdlSystem_getTaskStatistics errors with Can't find DLL entry Point mdlSystem_getTaskStatistics in stdmdlbltin.dll.
@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:
String
StrPtr()