Basic Macro file to be run in a batch process in v8i

I have to change one border content in text format DMS to EDMS in 4500 sheets, i have created a Basic Macro(langues are pasted below) it  is working in sheet by sheet only , Anybody can help how to  process in Batch mode. Reply highly appreciated... 

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

' Start a command
MbeSendCommand "EDIT TEXT "

' Coordinates are in master units
startPoint.x = 0.451857#
startPoint.y = 0.005378#
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%

' Send a message string to an application
' Content is defined by the application
MbeSendAppMessage "WORDPROC", "1 selection 13 18"

MbeSendAppMessage "WORDPROC", "1 moveCaretToPosition 13"

MbeSendAppMessage "WORDPROC", "1 selection 13 18"

MbeSendAppMessage "WORDPROC", "1 moveCaretToPosition 18"

MbeSendAppMessage "WORDPROC", "1 selection 13 18"

MbeSendAppMessage "WORDPROC", "1 moveCaretToPosition 18"

MbeSendAppMessage "WORDPROC", "1 selection 13 18"

MbeSendAppMessage "WORDPROC", "1 moveCaretToPosition 18"

MbeSendAppMessage "WORDPROC", "1 selection 13 18"

MbeSendAppMessage "WORDPROC", "1 moveCaretToPosition 18"

MbeSendAppMessage "WORDPROC", "1 selection 13 18"

MbeSendAppMessage "WORDPROC", "1 moveCaretToPosition 13"

MbeSendAppMessage "WORDPROC", "1 selection 13 18"

MbeSendAppMessage "WORDPROC", "1 keypress 69 0 0 0 0 0 0 0 0 0 0 0 1"

MbeSendAppMessage "WORDPROC", "1 keypress 68 0 0 0 0 0 0 0 0 0 0 0 1"

MbeSendAppMessage "WORDPROC", "1 keypress 77 0 0 0 0 0 0 0 0 0 0 0 1"

MbeSendAppMessage "WORDPROC", "1 keypress 83 0 0 0 0 0 0 0 0 0 0 0 1"

point.x = startPoint.x - 0.014170#
point.y = startPoint.y - 0.004074#
point.z = startPoint.z
MbeSendDataPoint point, 1%

MbeSendCommand "MODIFY TEXT "

point.x = startPoint.x + 0.001466#
point.y = startPoint.y - 0.001141#
point.z = startPoint.z
MbeSendDataPoint point, 1%

point.x = startPoint.x + 0.001955#
point.y = startPoint.y - 0.001304#
point.z = startPoint.z
MbeSendDataPoint point, 1%

MbeSendCommand "CHOOSE ELEMENT "
End Sub

  • how to  process in Batch mode

    very easy in v8i,

    Now before I get flamed Basic is not recommended as it has been deprecated in v8i and abandoned altogether in Connect edition and Bentley recommends we stop ung it and start using VBA instead... but since your using v8i an already made the macro in basic and you tested I works then lets proceed .

    From what I see in your screen shot your basic macro is being found right away so msnt  knows where to find its pathing this is a good thing

    So go load  the batch processor from Utilities> batch processor

    Now we need to create a command file, fortunaltey msnt uses a template  for this so just above the apply selection  to the right there is a square icon, create new command line, click it new dialog give it a name in the filename box and press save

    this now opens in note pad

    good practice is to enter some details   ie your name , date, what the process does etc

    so you can edit say 4th line  after # put  REPLACES DMS TEXT WITH EDMS , YOUR NAME, DATE

    then the first command should be to load and run your macro

    so first empty line below #--------------------- We will call up the macro by name and it will autorun , then next line we will put a fitview just because its nice PRACTICE BUT NOT COMPULSORY   then 3RD LINE  will save settings and save the file then move on  to the next drawing in the listing and runs again......

    MACRO EDMS-2

    FIT VIEW EXTENDED

    FILEDESIGN

    now that's it save and close the text file

    it should now be visible in the command file box

    next step add the drawings you want to process via 4th icon from top left add files ( it has a little plus sign)

    now once you have a list of them its good practice to just test it on one file first so click on the first file in the list and it highlights and then click on box process selection only it should now have a tick, now to run it only on one  file click the icon that looks like ancient ibm pc , which is the process batch and new dialog pops to confirm click the tab Process and sit  back and watch the magic happen

    Now if it worked as intended  great close the done, then untick process selection only and  run again by click the pc icon and confirm process tab, note if you have more than one model it will process all the models if you want only specific models  cancel and return to main and click on each file and select only the models you want..

    Now if it didn't work you will have to edit your command file ,click  on the pencil icon and figure out what is wrong or  put # in front of your command lines  and only run one line at a time ie no # in front of the command...

    some of the great things about his are

    1. If your macros are able to be run from the keyin window  via  "  macro macroname "     then you don't have to path your macro  in your batch processor command file.

    2 .You can reuse  parts of other command files  ie the fit view extended and the File design etc.

    3. These command files are retrievable and can be reused over and over and shared with other users.

    4. They are text can have comments and intructions and can be edited from default text editor.

    5. If the command are  just microstation keyin commands  so you can always fin them from he help or the keyin window extened,

    To learn more keyins look in help under action strings and  search askinga  set item tool settings to find more complex commands that cant picked up by the macro recorder..

    Enjoy the ride and let us know how you went.

    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: Anwer Nechikkad 

  • Thank you for your reply, your support highly appreciated., 

    i tried to work as per your instruction but i stuck on my way, i am just a beginner in Batch process. please apologize., as your advise i create one command file which is copy pasted below, could you please support to help out to fill the comment file properly.

    #----------------------------------------------------------------------
    #
    # Command file for batchprocess utility
    # REPLACES DMS TEXT WITH EDMS
    # This command file was originally copied from $(MS_DATA)cmdfiletemplate.txt.
    # Command file information:
    # - Lines that start with the '#' character are treated as comments and ignored.
    #
    #----------------------------------------------------------------------

    Thanks again for your support.

  • MACRO EDMS-2

    FIT VIEW EXTENDED

    FILEDESIGN

    Just to note, Anwar - these three lines are the commands that actually need to be included in your Command text file. What you currently show is a command file that is only comments. you will need actual commands (as suggested by Lorys) to make anything happen.

    MaryB

    Power GeoPak 08.11.09.918
    Power InRoads 08.11.09.918
    OpenRoads Designer 2021 R2

        

  • Basic is not recommended as it has been deprecated in v8i and abandoned altogether in Connect edition and Bentley recommends we stop using it and start using VBA

    Well said, Lorys!

     
    Regards, Jon Summers
    LA Solutions