Microstation Basic Macro

I created a Microstation Basic Macro to attach a reference file (e.g. border sheet) to multiple files in a folder. The macro runs perfect except that the Reference Attachment Settings dialog pops up and I have to click the "OK" tab for every file on the list. Is there a way to automate this or add line into the Macro so I don't have to hit the 'OK' tab? If there is, what should be the Microstation basic command I should add into the macro.?

 macro?

  • Hi Cezar,

    at first, please read and follow this forum best practices: They contain recommendations e.g. how subject should be formated and what information should be always shared (e.g. product and its exact version) to ensure the communication will be efficent and quick.

    Also, please never share the macro code in a form of picture, because it's not veru useful (not easy to ready, cannot be copied and tried). Use Insert > Insert code tool to share the code. On the other hand, I appreciate you tried to share the code, many people try to discuss macros and applications and do not show anything ;-)

    I created a Microstation Basic Macro

    Why do you use MicroStation BASIC? You did not specify what product and version do you use, but it's recommended for many years (I guess from V8 2004 Edition) to don't use BASIC in favor of MicroStation VBA. From the picture it seems you use some version of MicroStation V8i, so I recommend to stay away from BASIC and use better VBA (where you will probably receive more answers).

    If there is, what should be the Microstation basic command I should add into the macro.?

    It's because your code is not "real macro", but a script simulating user's activity. I do not know whether it's possible in BASIC (I have not used it for about 10 years), but in VBA the solution is to don't send key-ins, but to attach the file directly using VBA API (using Attachment.Attach() method). There are example in MicroStation VBA help how to work with Attachment object.

    With regards,

      Jan

  • Hi ,

    As Jon recommends, MicroStation VBA macros would be a better way to future proof this and future customizations you may need to create.

    Since you are asking to automatically close the dialog while attaching a reference, from one perspective this may imply that you do not need the file selection dialog box at all - if you know the exact full path and file name you wish to attach.  If this is the case, consider simply sending an appropriate key-in to attach a reference file or raster image; shown (and compatible) with ProjectWise managed locations; simply replace with your own local full paths and file names needed if you wish to test or use this approach.

    Here are two samples keyins to attach a MicroStation design file and a raster reference to the active model:

     MicroStation Key-in to Attach a ProjectWise managed Design File as a MicroStation Reference
     rf=pw:\\mypwsrv.mycompany.com:mydatasource\Documents\RHook\LotsOfLevelsTest.dgn,Default,MyLogicalName,MyDescription,Top;SELV ALL

     MicroStation Key-in to Attach a ProjectWise managed Raster File as a MicroStation Raster Reference
     RASTER ATTACH [fixed|interactive] pw:\\mypwsrv.mycompany.com:mydatasource\Documents\images\test.tif

    HTH,
    Bob

    Reference: Attach a reference file programmetrickly (pardon my language :-)) using Object GUID or similar



  • I totally agree with all the aboves. Using key-in command is most easy way. MVBA is much better than MicroStation Basic.

    I have a new suggestion, considering you are working in PW, there might be some codes running in PW, such as titleblock mapping. Such codes will run automatically open a new drawing in PW and it takes time. I might consider to export all the files to local, add references locally, import files into PW, scan references. It might save some time.

  • Hi ,

    Just to clarify, the Original Poster (OP) did not mention using ProjectWise.  I simply re-used an existing suggestion in a (proven) form that shows ProjectWise compatible key-ins and stated to replace with (Local) Full Path and File Names (filespec) and everything should work equally as well.  Sorry if that may not have been clear when reading my post.

    Thank you for your additional ProjectWise considerations added.

    Bob



  • you may find it easier if you attaching the same ref file to just use the batch processor with the ref attach keyin instead

    the following keyins work without having to accept and will work in your batch processor

    (world coincedent )
    RF=filenameofRef,,,,#

    (coincedent)
    RF=filenameofRef,,,,*

      (but goof practice would be to add the fit view  extended and file design commands )

    FYI

    (top)
    RF=filenameofRef,,,,top
    but top requires a data point

    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 

    Answer Verified By: Cezar Pangilinan