Pen Table Macro Hook help?!?

We are trying to write our first Macro for use with our Pentable. What we want to do is have the pen table "Drop element" based on criteria established, the print the element then undo the "drop element" to return it to it original status. So we started with having our steps recorded, but are unable to figure out the "Pen Table Print Element Hook". The following is our macro called "Drop_element". Any help would be greatly appreciated as we trying to learn how to do this and this seemed to be easy, but apparently it is not.

' Drop elements and undo drop

Sub main

Dim startPoint As MbePoint

Dim point As MbePoint, point2 As MbePoint

' Start a command

MbeSendCommand "DROP ELEMENT "

' Set a variable associated with a dialog box

MbeSetAppVariable "DROP", "dropOptions.complex", -1&

MbeSetAppVariable "DROP", "dropOptions.strings", -1&

MbeSetAppVariable "DROP", "dropOptions.sharedCells", -1&

MbeSetAppVariable "DROP", "dropOptions.mlines", -1&

MbeSendCommand "CHOOSE ALL "

MbeSendCommand "DROP ELEMENT "

' Coordinates are in master units

startPoint.x = 120.583542#

startPoint.y = 130.883882#

startPoint.z = 0.000000#

' Send a data point to the current command

point.x = startPoint.x

point.y = startPoint.y

point.z = startPoint.z

MbeSendDataPoint point, 1%

MbeSendCommand "CHOOSE ALL "

MbeSendCommand "DROP ELEMENT "

point.x = startPoint.x + 0.234617#

point.y = startPoint.y - 1.156249#

point.z = startPoint.z

MbeSendDataPoint point, 1%

MbeSendCommand "UNDO "

MbeSendCommand "UNDO "

End Sub

  • I could not figure out how to hook a VBA directly in my thread, Emulate Plot Hook Functions & AutoRun. Although it is possible with a BASIC macro.

    Add a section to a PenTable to call the BASIC Macro:

    BEGIN Splash_Draw_Order
        BASICFUNC     = SPLASH_PenTableHook.bas,PenTableHook
    END

    Create a BASIC macro to call your primary macro (my "SPLASH_PenTableHook.bas" macro):

    Function PenTableHook (inElem as MbeElement) As Long

        Dim PenTableHookPoint      As String

        PenTableHook = MBE_ElemNormal

    End Function

    Sub main
        Dim startPoint As MbePoint
        Dim point As MbePoint, point2 As MbePoint

    '   Send a keyin that can be a command string
        MbeSendKeyin "macro Splash_Draw_Order"
    End Sub

    Note that the "SPLASH_PenTableHook.bas" calls the "Splash_Draw_Order.ba" macro, this could also call a VBA macro.
     

  • I found an easier method to hook a BASIC macro to the pen table, similar to the former response: In your pen table, add something like this:

    BEGIN DropElementFunction
    BASICFUNC = DropElementFromPenTable.bas, DropElements
    PRIORITY = 30
    END

    Where, DropElementFunction is only a name, there is nothing else associated with it.
    DropElementFromPenTable.bas is a basic macro that contains the DropElements function that you want performed at plotting. Note that your basic macro must contain a sub main(). Commands in the sub main() will be run prior to the function being called so you can have some pre-processing done, including calling other functions.

    The Hook Function is in the BASIC macro Editor. While editing your BASIC macro, from the Edit pull down menu select "Program Entry Point", click new and choose the type of Hook you need and insert your function name in the dialog box.

    It is my understanding that you cannot use VBA as your macro from the pen table, it must be in BASIC.
  • This thread really belongs to programing forum..

    but in any case I'm curious why do you need to drop anything for printing .. cant your pentable correct things that dont print the way yuo want  normally?

    Lorys

    Started msnt work 1990 - Retired  Nov 2022 ( oh boy am I old )

    But was long time user V8iss10 (8.11.09.919) dabbler CE  update 16 (10.16.00.80) 

    MicroStation user since 1990 Melbourne Australia.
    click link to PM me