Makro mit Referenzen

Discussion in 'Microstation' started by Alexander Heide, Jan 8, 2004.

  1. Bei der erstellung eines Makros (automatisch mit dem
    Makroaufzeichnungsprogramm)
    wurden an eine bestehende DGN einige referenzen angehängt. Versuch das
    makro in
    einer "jungfräulichen DGN" laufen zu lassen brachte zutage, dass das
    makro an sich
    nicht läuft dafür aber nur die bei der Aufzeichnung des Makros
    aufgemachten Fenster
    auftauchen. Diese lassen sich danach weder bewegen noch schliessen.
    Auch MicroStation selbst lässt sich nicht schliessen.

    Mein Ziel ist, dass die Referenzdateien in der DGN angezeigt werden.

    Was mach ich falsch? Zur Info -> hier das Makro:

    ______________________________________________________________________

    ' dgn an dgn referenziert wobei von schritt zu schritt
    ' ein versatz produziert wird

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

    ' Start a command
    MbeSendCommand "MDL KEYIN REF DIALOG REFERENCE"

    MbeSendCommand "REFERENCE ATTACH "

    ' When a command brings up a modal dialog,
    ' a later statement must close the dialog,
    ' or the MbeState.modalDialogByUser property
    ' should be set to 1 so that the user must close
    ' the dialog when the macro is executed.
    ' Also, you may not use the debugger "Step"
    ' commands while a modal dialog is displayed.

    ' Opened modal dialog "Attach Reference"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setFilterCmd *.dgn"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setDirectoryCmd

    C:\Programme\Bentley\Workspace\Users\test aneinanderreihung\"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setFileNameCmd
    Test_11_AG.dgn"

    ' Closed modal dialog "Attach Reference"

    ' Following comment is the command to close a modal dialog
    ' MbeSendCommand "MBE1 CLOSEMODAL OK"

    ' Opened modal dialog "Attach Reference Settings"

    ' Opened modal dialog "Attachment Settings: test_11_ag.dgn"

    ' Closed modal dialog "Attachment Settings: test_11_ag.dgn"
    ' MbeSendCommand "MBE1 CLOSEMODAL OK"

    ' Closed modal dialog "Attach Reference Settings"
    ' MbeSendCommand "MBE1 CLOSEMODAL OK"

    MbeSendCommand "REFERENCE MOVE "

    ' Coordinates are in master units
    startPoint.x = 0.219077#
    startPoint.y = 0.130269#
    startPoint.z = -0.150819#

    ' Send a data point to the current command
    point.x = startPoint.x
    point.y = startPoint.y
    point.z = startPoint.z
    MbeSendDataPoint point, 2%

    ' Send a keyin that can be a command string
    MbeSendKeyin "AccuDraw Rotate Top"

    ' Send a reset to the current command
    MbeSendReset

    point.x = startPoint.x - 0.077595#
    point.y = startPoint.y + 0.090932#
    point.z = startPoint.z + 0.013338#
    MbeSendDataPoint point, 2%

    MbeSendCommand "REFERENCE MOVE "

    point.x = startPoint.x - 0.219077#
    point.y = startPoint.y - 0.043497#
    point.z = startPoint.z + 0.150819#
    MbeSendDataPoint point, 2%

    point.x = startPoint.x - 0.132305#
    point.y = startPoint.y - 0.043497#
    point.z = startPoint.z + 0.150819#
    MbeSendDataPoint point, 2%

    MbeSendReset

    MbeSendCommand "REFERENCE ATTACH "

    ' Opened modal dialog "Attach Reference"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setFilterCmd *.dgn"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setDirectoryCmd

    C:\Programme\Bentley\Workspace\Users\test aneinanderreihung\"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setFileNameCmd
    Test_12_AG.dgn"

    ' Closed modal dialog "Attach Reference"
    ' MbeSendCommand "MBE1 CLOSEMODAL OK"

    ' Opened modal dialog "Attach Reference Settings"

    ' Closed modal dialog "Attach Reference Settings"
    ' MbeSendCommand "MBE1 CLOSEMODAL OK"

    MbeSendCommand "REFERENCE MOVE "

    point.x = startPoint.x - 0.219077#
    point.y = startPoint.y - 0.043497#
    point.z = startPoint.z + 0.150819#
    MbeSendDataPoint point, 2%

    point.x = startPoint.x - 0.045525#
    point.y = startPoint.y - 0.048176#
    point.z = startPoint.z + 0.150819#
    MbeSendDataPoint point, 2%

    MbeSendReset

    MbeSendCommand "UNDO "

    MbeSendCommand "REFERENCE MOVE "

    point.x = startPoint.x - 0.219077#
    point.y = startPoint.y - 0.043497#
    point.z = startPoint.z + 0.150819#
    MbeSendDataPoint point, 2%

    point.x = startPoint.x - 0.045533#
    point.y = startPoint.y - 0.043497#
    point.z = startPoint.z + 0.150819#
    MbeSendDataPoint point, 2%

    MbeSendReset

    MbeSendCommand "REFERENCE ATTACH "

    ' Opened modal dialog "Attach Reference"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setFilterCmd *.dgn"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setDirectoryCmd

    C:\Programme\Bentley\Workspace\Users\test aneinanderreihung\"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setFileNameCmd
    Test_13_AG.dgn"

    ' Closed modal dialog "Attach Reference"
    ' MbeSendCommand "MBE1 CLOSEMODAL OK"

    ' Opened modal dialog "Attach Reference Settings"

    ' Closed modal dialog "Attach Reference Settings"
    ' MbeSendCommand "MBE1 CLOSEMODAL OK"

    MbeSendCommand "REFERENCE MOVE "

    point.x = startPoint.x - 0.219077#
    point.y = startPoint.y - 0.043497#
    point.z = startPoint.z + 0.150819#
    MbeSendDataPoint point, 2%

    point.x = startPoint.x + 0.041239#
    point.y = startPoint.y - 0.043497#
    point.z = startPoint.z + 0.150819#
    MbeSendDataPoint point, 2%

    MbeSendReset

    MbeSendCommand "FIT VIEW EXTENDED 2"

    MbeSendCommand "REFERENCE ATTACH "

    ' Opened modal dialog "Attach Reference"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setFilterCmd *.dgn"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setDirectoryCmd

    C:\Programme\Bentley\Workspace\Users\test aneinanderreihung\"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setFileNameCmd
    Test_14_AG.dgn"

    ' Closed modal dialog "Attach Reference"
    ' MbeSendCommand "MBE1 CLOSEMODAL OK"

    ' Opened modal dialog "Attach Reference Settings"

    ' Closed modal dialog "Attach Reference Settings"
    ' MbeSendCommand "MBE1 CLOSEMODAL OK"

    MbeSendCommand "REFERENCE MOVE "

    point.x = startPoint.x - 0.219077#
    point.y = startPoint.y - 0.043497#
    point.z = startPoint.z + 0.150819#
    MbeSendDataPoint point, 2%

    point.x = startPoint.x + 0.128012#
    point.y = startPoint.y - 0.043497#
    point.z = startPoint.z + 0.150819#
    MbeSendDataPoint point, 2%

    MbeSendReset

    MbeSendCommand "REFERENCE ATTACH "

    ' Opened modal dialog "Attach Reference"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setFilterCmd *.dgn"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setDirectoryCmd

    C:\Programme\Bentley\Workspace\Users\test aneinanderreihung\"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setFileNameCmd
    Test_15_AG.dgn"

    ' Closed modal dialog "Attach Reference"
    ' MbeSendCommand "MBE1 CLOSEMODAL OK"

    ' Opened modal dialog "Attach Reference Settings"

    ' Closed modal dialog "Attach Reference Settings"
    ' MbeSendCommand "MBE1 CLOSEMODAL OK"

    MbeSendCommand "REFERENCE MOVE "

    point.x = startPoint.x - 0.219077#
    point.y = startPoint.y - 0.043497#
    point.z = startPoint.z + 0.150819#
    MbeSendDataPoint point, 2%

    point.x = startPoint.x + 0.214784#
    point.y = startPoint.y - 0.043497#
    point.z = startPoint.z + 0.150819#
    MbeSendDataPoint point, 2%

    MbeSendReset

    MbeSendCommand "REFERENCE ATTACH "

    ' Opened modal dialog "Attach Reference"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setFilterCmd *.dgn"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setDirectoryCmd

    C:\Programme\Bentley\Workspace\Users\test aneinanderreihung\"

    MbeSendCommand "MDL COMMAND MGDSHOOK,fileList_setFileNameCmd
    Test_16_AG.dgn"

    ' Closed modal dialog "Attach Reference"
    ' MbeSendCommand "MBE1 CLOSEMODAL OK"

    ' Opened modal dialog "Attach Reference Settings"

    ' Closed modal dialog "Attach Reference Settings"
    ' MbeSendCommand "MBE1 CLOSEMODAL OK"

    MbeSendCommand "REFERENCE MOVE "

    point.x = startPoint.x - 0.219077#
    point.y = startPoint.y - 0.043497#
    point.z = startPoint.z + 0.150819#
    MbeSendDataPoint point, 2%

    point.x = startPoint.x + 0.301556#
    point.y = startPoint.y - 0.043497#
    point.z = startPoint.z + 0.150819#
    MbeSendDataPoint point, 2%

    MbeSendReset
    End Sub

    ______________________________________________________________________


    Besten Dank!

    Alenander Heide
     
    Alexander Heide, Jan 8, 2004
    #1
  2. Hi,

    Alexander, wie ich aus Deínem Macro ersehe, wird nirgends ein
    Referenzfilename als Argument angegeben. z.B. wenn ich eine Referenz
    anhänge geht das mit "rference attach
    c:\mydgn\guteguete\referencedatei.dgn,ref1,Dies ist eine Reference"
    wobei die durch komma getrennten Argumente sind: Referencedateiname,
    logical name und Veschreibung. Es mach auch sinn, ein Escape
    hinterherzusenden.

    Ich verstehe sowieso nicht, wiel Leute, welche scheinbar absolut keine
    Programmiererfahrung haben, glauben mit VBA-Macros Programmieren zu können.
    Es kommt auch ein wenig auf Zusammenhänge an.
     
    Rainer Wiesel, Jan 12, 2004
    #2
  3. Hallo Alenander,

    Ich zeige Dir wie man das Problem lösen könnte.

    Macro:

    Sub main
    Dim startPoint As MbePoint
    Dim point As MbePoint, point2 As MbePoint
    Dim xur As Long, yur As Long, zur As Long
    Dim vno As Integer
    Dim viewNum As Long

    ' öffnet eine DGN
    MbeSendKeyin "rd=d:\GeoGraphics\Project\fnp_2000\dgn\wohnen00.dgn"

    'hänget eine Referenz-datei an
    MbeSendKeyin "rf=d:\GeoGraphics\Project\fnp_2000\dgn\wohn_area.dgn,1,1"
    MbeSendReset

    'Macht Ebene 63 aktiv und schaltet alle Ebenen der aktiven datei aus
    MbeSendKeyin "Lv=63;on=1-63;selview all;echo;null;Lv=63;of=1-63;selview all"

    'hänget eine 2. Referenz-datei an
    MbeSendKeyin "rf=d:\GeoGraphics\Project\fnp_2000\dgn\wohn_symb.dgn,2,2"
    MbeSendReset

    'Plaziert einen Zaun "Hohlraum-Überlappung
    MbeSendKeyin "lock fence void overlap"
    MbeSendKeyin "place fence block;xy=0,0;xy=2,2 |uor"

    'Kopiert den Zauninhalt (hier den Inhalt der angehängten Referenzen
    MbeSendKeyin "fence copy"
    point.x = xur
    point.y = yur
    point.z = zur
    viewNum = vno
    MbeSendDataPoint point, viewNum
    point.x = xur
    point.y = yur
    point.z = zur
    viewNum = vno
    MbeSendDataPoint point, viewNum

    'Hängt alle Referenzen ab
    MbeSendKeyin "ref det all"
    MbeSendKeyin "Lv=63;on=1-63;selview all"

    'Ordnet alle Ansichten und alle Objekte werden in View 1 eingepaßt
    MbeSendCommand "WINDOW TILE;FIT VIEW EXTENDED 1"

    'Schaltet Ebene 1 aktiv und schaltet alle Ebene ein
    SendKeyin "Lv=1;on=1-63;selview all;echo;null;"

    End Sub

    mfg

    Jens Rückriem
     
    Jens R?ckriem, Feb 3, 2004
    #3
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.