Hi all,
Does anyone know of a method in VBA to detect if the active design file has Design History enabled or not?
The mdl wrapper method i found in old posts crashes in CE and the Property Handler method always results in a negative result.
Regards,
Mark
Mark Shamoun said:Does anyone know of a method in VBA to detect if the active design file has Design History enabled or not?
VBA help example Design File Properties includes a few statements that concern Design History.
ShowValue oPH, "DesignRevisionCount", False, False If oPH.GetValue > 0 Then ' Design History properties ShowValue oPH, "DesignRevisions[0].Number", False, False ShowValue oPH, "DesignRevisions[0].Date", False, False ShowValue oPH, "DesignRevisions[0].Author", False, False ShowValue oPH, "DesignRevisions[0].Note", False, False End If
Regards, Jon Summers LA Solutions
hmm no matter what i do I get 0 for "DesignRevisionCount". I'm betting this worked in v8i...
OpenRoads Designer 2023 | Microstation 2023.2 | ProjectWise 2023
never mind, it looks like having the Design History Browse option set to 0 in your config also "blocks" Design History visibility to vba and Named Expressions
Mark Shamoun said:it looks like having the Design History Browse option set to 0 in your config also "blocks" Design History visibility to vba and Named Expression
It makes sense to me, because when MS_DESIGN_HISTORY with browse=0, it says "do not provide access to the history a design file". And it should be applied both to GUI (user access) and VBA, because VBA is primarily user tool.
Mark Shamoun said:The mdl wrapper method i found in old posts
What the wrapper for V8i was?
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
I meant using the mdl function mdlHistory_exists(mdlModelRef_getDgnFile(mdlModelRef_getActive()) in CE Update 14 results in a crash, but that was while the browse option was disabled. I'll check it again with briwse enabled when I get a chance out of curiosity.
Mark Shamoun said:results in a crash
A question is how C function is declared in VBA code.
Mark Shamoun said:but that was while the browse option was disabled
Even when the browser is disabled, it cannot be a reason to crash. But without testing it's hard to distinguish whether the problem is (VBA declaration, somewhere deep inside the function implementation or somewhere else).
Mark Shamoun said:I meant using the mdl function mdlHistory_exists(mdlModelRef_getDgnFile(mdlModelRef_getActive())
It think (no testing done) it can be simplified to
mdlHistory_exists(mdlDgnFileObj_getMasterFile())
Mark Shamoun said:mdlHistory_exists(mdlModelRef_getDgnFile(mdlModelRef_getActive())
You probably need to modify the function declarations to be compatible with 64-bit CONNECT. Those go at the top of your VBA module...
Declare PtrSafe Function mdlHistory_exists Lib "stdmdlbltin.dll" ( ByVal pFile As LongPtr ) As Long
Declare PtrSafe Function mdlDgnFileObj_getMasterFile Lib "stdmdlbltin.dll" ( ) As LongPtr
Now you should be able to use Jan's suggestion. Wrap it in a VBA function to avoid polluting your other code...
Public Function HistoryExists () As Boolean HistoryExists = 0 <> mdlHistory_exists(mdlDgnFileObj_getMasterFile()) End Function