V8 macro...

Discussion in 'Microstation' started by redbyrd, Sep 9, 2003.

  1. redbyrd

    redbyrd Guest

    I am trying to convert my MSJ ucm into a macro and would like some
    help. Below is what I derived. It seems when running it as a macro
    the first line doesn't properly envoke, leaving View 1 hanging over
    into my second monitor. When I type these lines through the keyin,
    one at a time, everything runs fine. What would cause the macro not
    run when run the first line? Also, how can I get this macro, once
    perfect, to run automatically when I open a new design file. Would I
    put some line of code in my UPF?

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

    ' Start a command

    MbeSendCommand "DIALOG TOOLBOX MAIN OFF "

    MbeSendCommand "DIALOG SNAPS OFF"

    MbeSendCommand "VIEW OFF ALL "

    MbeSendCommand "VIEW ON 1 "

    MbeSendCommand "MGDSHOOK,
    msDialogState.viewSettingsP->flags.line_wghts", 0&'"

    MbeSendCommand "VIEW ON 5 "

    MbeSendCommand "WINDOW TILE "

    MbeSendCommand "DIALOG TOOLBOX MAIN ON "

    MbeSendCommand "DIALOG SNAPS "

    End Sub

    thanks
    redbyrd
     
    redbyrd, Sep 9, 2003
    #1
  2. The main issue with the code you listed appeared to be the trailing
    spaces.
    In some cases, they prevent the command from working in code, but work
    just fine when you key them in manually.
    The code to toggle the toolboxes is not really needed and does not
    always work as expected in v8.
    Below is code that will achieve what you want.

    Sub Main
    MbeSendCommand "VIEW OFF ALL"
    MbeSendCommand "VIEW ON 1"
    MbeViews(1).lineWeight = 0
    MbeSendCommand "VIEW ON 5"
    MbeSendCommand "WINDOW TILE"
    End Sub

    As far as automatically running when you open a file, well that is a
    little more complicated. There are a few ways you can do that.
    You may want to investigate the RunMacro.ma, or implementing scripts.
    If you are a Select member, you can find info on Bentley.com
    In the past, we took the easy road and just used a function key.

    However, if you are running V8 you may want to consider using VBA
    instead of old MBE and UCMs.
    In VBA, you could write a small class and some startup code in your
    Default.mvba which would give you what you want.

    If you want code to do this, let me know.
    It is more complicated than MBE, but still simple.

    Gerald
     
    Gerald Hernandez, Sep 9, 2003
    #2
  3. Hello Redbyrd,

    To run a macro automatic you need to add the next lines
    to your userconfiguration file (ucf)

    MS_DGNAPPS > RUNMACRO
    MS_DGNMACROS = redbyrd

    RUNMACRO is a mdl routine which is loading the macro redbyrd automatic.

    I did also look at your macro, I did change the

    MbeSendCommand "MGDSHOOK, msDialogState.viewSettingsP->flags.line_wghts",
    0&'"
    to
    version v7
    status = MbeCExpressionLong ("tcb->view[0].flags.line_wghts= 0")
    version v8
    the tcb-variable doesn't exist anymore in v8 so I am making use of
    the mdl function mdlView_setDisplayControl.

    The problems that you are seeing with 2 monitors I can't reproduce.

    '>> begin source
    'redbyrd.bas
    Sub main
    Dim status as long

    ' Start a command

    MbeSendCommand "DIALOG TOOLBOX MAIN OFF "
    MbeSendCommand "DIALOG SNAPS OFF"
    MbeSendCommand "VIEW OFF ALL "
    MbeSendCommand "VIEW ON 1 "
    MbeSendCommand "VIEW ON 5 "
    'set the line weights in view 1 and 5 off
    'version v7
    ' status = MbeCExpressionLong ("tcb->view[0].flags.line_wghts= 0")
    ' status = MbeCExpressionLong ("tcb->view[4].flags.line_wghts= 0")

    'version v8
    call setdisplaycontrol(3,0,0)
    call setdisplaycontrol(3,4,0)

    'as example
    'set the line weights in view 1 and 5 on
    'version v7
    ' status = MbeCExpressionLong ("tcb->view[0].flags.line_wghts= 1")
    ' status = MbeCExpressionLong ("tcb->view[4].flags.line_wghts= 1")

    'version v8
    ' call setdisplaycontrol(3,0,1)
    ' call setdisplaycontrol(3,4,1)

    MbeSendCommand "WINDOW TILE "
    MbeSendCommand "DIALOG TOOLBOX MAIN ON "
    MbeSendCommand "DIALOG SNAPS "

    End Sub

    Sub setdisplaycontrol (flag as integer, view as integer, newvar as integer)
    dim status as long

    'see for the values of flag mdl.h
    'Defines for mdlView_getDisplayControls() &
    ' mdlView_setDisplayControls()

    'newvar
    '0 = false
    '1 = true

    status = MbeCExpressionLong ("mdlView_setDisplayControl (" + _
    cstr(flag) + "," + _
    cstr(view) + "," + _
    cstr(newvar) + _
    ")")
    End sub
    '>> end source

    I hope this will help.
    For more mbe examples see my website.

    With Regards,

    Harry Stegeman
    www.h-stegeman.demon.nl
     
    Harry Stegeman, Sep 10, 2003
    #3
  4. redbyrd,

    Yes, using the RUNMACRO.ma as Harry said will do what you want.
    I'm a little perplexed on Harry's suggested method of turning off line
    weights.
    With all due respect to Harry who is obviousely talented, his method
    seems unnecessarily complicated.
    I did forget the line to turn off view 5 in the code I listed.
    It is:
    MbeViews(5).lineWeight = 0

    The MBE macro I listed works equally well with SE, J, and v8 without
    change as far as I know.

    If you are running V8 and would like to use VBA for this, you can
    download an MVBA file from our website that will do exactly what you
    want.
    Open it in your VBA project manager and then check the "Auto-Load"
    area.
    Then every time you run Microstation, it automatically loads.
    Every time you open a file, it will perform your view setup.

    The path to the MVBA is:
    www.GPSBroadband.com/ViewSetup.zip

    Regards,
    Gerald Hernandez
     
    Gerald Hernandez, Sep 10, 2003
    #4
  5. Harry,
    Touche', indeed you are also correct.

    Gerald
     
    Gerald Hernandez, Sep 11, 2003
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.