[VBA] Need help with MDL Wrapper Function for mdlSheetDef_setBorderAttachmentId

The documentation when followed generates the following error message:

Bad DLL calling convention (Error 49)

While this error has a help page, it does not explain any specific corrective action that can be done.

The Wrapper statement, from the MDL help is:

Declare Function mdlSheetDef_getBorderAttachmentId Lib "stdmdlbltin.dll" ( ByVal sheetDefIn As Long , ByRef borderAttachmentIdOut As DLong ) As Long

There is also a property in the VBA SheetDefinition object named MdlSheetDef that, according to its help "Retrieves the associated SheetDef pointer that a program can use as an argument to MDL mdlSheetDef functions."

With no example, we cannot determine how to use this or even if this is the way to use the subject wrapper function.

We seem to have hit a brick wall on this and need help from a Bentley Programmer.

Parents
  • Jon,

    You "Da Man!"

    Worked a treat!

    You really earned your BeMVP star today!

    Here is the code: (Note - At this time, it is essential to modify a number of fixed values and strings for this to function. I also had to change the slot number of my reference files, which can be done in the reference file dialog box. But it was also necessary to close and reopen the file for this to work. Next on the agenda is for the code to try and determine which slot contains the sheet border and work its magic based upon what it finds so no fixed values are required. As for the slot number issue, In my anticipated work flow, InRoads creates the model with the attached border and I believe, it is always in slot 1. And in that workflow, all sizes and annotation scales will be identical.)  

    Sub changeModelType2Sheet()

       Dim thisModel As ModelReference, refBorder As ModelReference

       Dim thisSheet As SheetDefinition

       Dim refBorderElID As DLong

       Dim sheetDefRef As Long

       Set thisModel = ActiveModelReference

       Set refBorder = ActiveModelReference.Attachments(1)

       If thisModel.Type <> msdModelTypeSheet Then thisModel.Type = msdModelTypeSheet

       refBorderElID = refBorder.AsAttachment.ElementID

       Set thisSheet = thisModel.GetSheetDefinition

       With thisSheet

            sheetDefRef = VarPtr(.MdlSheetDef)

            'this next line actually does not work

           .FormName = "Arch D"

           'these next two lines result in a correct FormName if there is a FormName defined with a matching size

           .Width = thisModel.WorkingUnitsToDouble("36'") * thisModel.UORsPerMasterUnit

           .Height = thisModel.WorkingUnitsToDouble("24'") * thisModel.UORsPerMasterUnit

           .AnnotationScaleFactor = 30

       End With

       expr = "mdlSheetDef_setBorderAttachmentId((void*)" & thisSheet.MdlSheetDef & ", " & _

              DLongToString(refBorderElID) & ")"

       GetCExpressionValue expr

       thisModel.SetSheetDefinition thisSheet

       thisModel.PropagateAnnotationScale

    End Sub


    Charles (Chuck) Rheault
    CADD Manager

    MDOT State Highway Administration

    • MicroStation user since IGDS, InRoads user since TDP.
    • AutoCAD, Land Desktop and Civil 3D, off and on since 1996
Reply
  • Jon,

    You "Da Man!"

    Worked a treat!

    You really earned your BeMVP star today!

    Here is the code: (Note - At this time, it is essential to modify a number of fixed values and strings for this to function. I also had to change the slot number of my reference files, which can be done in the reference file dialog box. But it was also necessary to close and reopen the file for this to work. Next on the agenda is for the code to try and determine which slot contains the sheet border and work its magic based upon what it finds so no fixed values are required. As for the slot number issue, In my anticipated work flow, InRoads creates the model with the attached border and I believe, it is always in slot 1. And in that workflow, all sizes and annotation scales will be identical.)  

    Sub changeModelType2Sheet()

       Dim thisModel As ModelReference, refBorder As ModelReference

       Dim thisSheet As SheetDefinition

       Dim refBorderElID As DLong

       Dim sheetDefRef As Long

       Set thisModel = ActiveModelReference

       Set refBorder = ActiveModelReference.Attachments(1)

       If thisModel.Type <> msdModelTypeSheet Then thisModel.Type = msdModelTypeSheet

       refBorderElID = refBorder.AsAttachment.ElementID

       Set thisSheet = thisModel.GetSheetDefinition

       With thisSheet

            sheetDefRef = VarPtr(.MdlSheetDef)

            'this next line actually does not work

           .FormName = "Arch D"

           'these next two lines result in a correct FormName if there is a FormName defined with a matching size

           .Width = thisModel.WorkingUnitsToDouble("36'") * thisModel.UORsPerMasterUnit

           .Height = thisModel.WorkingUnitsToDouble("24'") * thisModel.UORsPerMasterUnit

           .AnnotationScaleFactor = 30

       End With

       expr = "mdlSheetDef_setBorderAttachmentId((void*)" & thisSheet.MdlSheetDef & ", " & _

              DLongToString(refBorderElID) & ")"

       GetCExpressionValue expr

       thisModel.SetSheetDefinition thisSheet

       thisModel.PropagateAnnotationScale

    End Sub


    Charles (Chuck) Rheault
    CADD Manager

    MDOT State Highway Administration

    • MicroStation user since IGDS, InRoads user since TDP.
    • AutoCAD, Land Desktop and Civil 3D, off and on since 1996
Children
No Data