I am trying to write a vba macro to create two elements copied parallel from a centreline at given distances between on each side. I am using MicroStation CE update 14 and trying to use the mdlElmdscr_copyParallel and mdlElmdscr_extractNormal, but I am find the example I have found is throwing an error "Type Mismatcfh" on the iElem.MdlElementDescrP, has something changed with this in connect edition or should I be looking for something else.
If DrawMode = msdDrawingModeTemporary Then If 0 = mdlElmdscr_extractNormal(Normal, PntOnElm, iElem.MdlElementDescrP, View.Rotation.RowZ) Then If 0 = mdlElmdscr_copyParallel(oElemDscrP, iElem.MdlElementDescrP, point, dOffset, Normal) Then Set oElem = MdlCreateElementFromElementDescrP(oElemDscrP) End If End If End If
John D said:has something changed with this in connect edition
Yes! MicroStation CONNECT is a 64-bit application; MicroStation V8 is a 32-bit application. MicroStation CONNECT provides 64-bit VBA version 7.1; MicroStation V8 provides 32-bit VBA version 6.5. There's plenty of information about the differences. For example...
Whenever you call MDL from VBA, you inevitably run up against pointers. VBA doesn't do pointers, and we have to cheat by pretending that a long integer is a pointer. Microsoft introduced the LongPtr data type to help in that situation.
Your MDL function declarations need to be updated. Here they are, defined for both VBA 7.1 and VBA 6.5...
#If VBA7 Then Private Declare PtrSafe Function mdlElmdscr_copyParallel Lib "stdmdlbltin.dll" ( _ ByRef outDscrPP As LongPtr, _ ByVal inDscr As LongPtr, _ ByRef point As Point3d, _ ByVal distance As Double, _ ByRef normal As Point3d) As Long Private Declare PtrSafe Function mdlElmdscr_extractNormal Lib "stdmdlbltin.dll" ( _ ByRef normal As Point3d, _ ByRef point As Point3d, _ ByVal edP As LongPtr, _ ByRef inputDefaultNormal As Point3d) As Long #Else Private Declare Function mdlElmdscr_copyParallel Lib "stdmdlbltin.dll" (ByRef outDscrPP As Long, ByVal inDscr As Long, ByRef point As Point3d, ByVal distance As Double, ByRef m_ptNormal As Point3d) As Long Private Declare Function mdlElmdscr_extractNormal Lib "stdmdlbltin.dll" (ByRef m_ptNormal As Point3d, ByRef point As Point3d, ByVal edP As Long, ByRef inputDefaultNormal As Point3d) As Long #End If
Here's an updated CopyParallel macro...
CopyParallel.zip
Regards, Jon Summers LA Solutions
Hi Jon/Jan,
Thanks for responding. I should have included a space between the post and the example file, I realise now how easy it was for you to miss it.
The example was downloaded from one of Dan Pauls posts and I can't seem to find it again, I presume he supplied it. The example was already including the obvious VB7 changes but when run, it threw a type mismatch error so not sure what has changed since the example was provided, presuming that Dan supplied a working example.
Example file included again.
3482.VBACopyParallel.mvba
Best Regards,
John Davidson
John D said:Thanks for responding. I realise now how easy it was for you to miss it.
I didn't miss it. I responded with
Try it!
Thanks for the clarification Jon, I was mainly responding to Jan's comments and I obviously didn't pick up the changes you made,
It seems to be working now, and when I have it completed it will be available on our website at https://bugva.org/hints-tips-links/ in our BUGVA_Collection
John Davidson said: it will be available on our website at https://bugva.org/hints-tips-links/ in our BUGVA_Collection
Excellent!
That site mentions the lack of a cell counter in MicroStation CONNECT. We've made available a freeware Cell Counter that you're welcome to add to your BUG.
Thanks Jon, very generous of you, we are trying to promote users to add to the list of things like this, if anyone has anything like Jon has provided and would like to share, please let us know at https://bugva.org/contact/