We used to be able to use mdlLevel_getElementCount(lCount, ActiveModelReference.MdlModelRefP, oLevel.ID) to get an element count of a level in V8i, it seems to have stopped working in connect? it errors on MdlModelRefP with a type mismatch
Ben Davies said:mdlLevel_getElementCount
If you're calling mdlLevel_getElementCount from VBA, then you have a function declaration in your VBA module. Because MicroStation CONNECT is 64-bit, that declaration will need adjusting for CONNECT. Please post it here so we can respond.
mdlLevel_getElementCount
The MicroStation V8 MDL Function Reference Manual includes the VBA declaration for each function. You can copy that declaration (for the 32-bit API) into your VBA code. Unfortunately, the documentation team did not provide that same courtesy for MicroStation CONNECT, which has a 64-bit API. We have to guess what the VBA declaration might be.
I recommend that you keep hold of the MDL Function Reference Manual for V8. It provides a starting point to develop a 64-bit equivalent for each VBA declaration.
Regards, Jon Summers LA Solutions
Hi Jon, thanks for coming backDeclare thisDeclare PtrSafe Function mdlLevel_getElementCount Lib "stdmdlbltin.dll" Alias "mdlLevel_getELementCOunt" (ByRef pUsageCountOut As Long, ByVal modelRefIn As Long, ByVal levelIdIn As Long) As Long
Ben Davies said:Declare PtrSafe Function mdlLevel_getElementCount Lib "stdmdlbltin.dll" Alias "mdlLevel_getELementCOunt" (ByRef pUsageCountOut As Long, ByVal modelRefIn As Long, ByVal levelIdIn As Long) As Long
That's a hybrid of your V8 original declaration and a CONNECT declaration.
You have to recognise variables that are pointers in MDL. Microsoft introduced the LongPtr data type to service pointer declarations. See this Microsoft article. They also introduced a macro to enable you to detect whether the platform is 32-bit or 64-bit, allowing this sort of declaration to work with both MicroStation CONNECT and MicroStation V8...
LongPtr
#If VBA7 Then Declare PtrSafe Function mdlLevel_getElementCount Lib "stdmdlbltin.dll" _ Alias "mdlLevel_getElementCount" ( _ ByRef pUsageCountOut As LongPtr, _ ByVal modelRefIn As LongPtr, _ ByVal levelIdIn As Long) As Long #Else Declare Function mdlLevel_getElementCount Lib "stdmdlbltin.dll" _ Alias "mdlLevel_getElementCount" ( _ ByRef pUsageCountOut As Long, _ ByVal modelRefIn As Long, _ ByVal levelIdIn As Long) As Long #EndIf
Public Function GetElementCountOnLevel ( _ ByVal levelId As Long, _ ByVal oModel As ModelReference) As Long Dim usage As LongPtr Const SUCCESS As Boolean = 0 If SUCCESS = mdlLevel_getElementCount(usage, _ oModel.MdlModelRefP, _ levelId) Then GetElementCountOnLevel = CLng(usage) End Function
The above code is untested, so you may have to footle with it.
many thanks for the pointers Jon, always a source of valuable info.i will have a loot in a bit.
B