MICROSTATION SS10 BATCH PROCESSS

Good morning,

I am trying to create a Batch Process which will replace one reference in the plan sheets DGNs with another reference. 

Is there a command script for that?

Also, can someone please send me a spreadsheet or word document with all the Batch command scripts so I can expand my knowledge in the batch processing. 

Thank you so much! 

Parents
  • Nearly all of the command keyins can be found in the Help, often under the command itself.

    Keyins can be strung together with the use of semicolons:
    active angle 0;active scale 1
    and a command file can have multiple rows of keyin commands.

    If you can run your keyin commands through the keyin broswer, you should be able to run them as a command file for a batch process.

    As far as "replacing" a reference, there is no simple command to do that. You would have to detach the original reference and attach the new one. You may be able to do that through keyins, but it could get complicated if you have to do any scaling, rotating, moving or clipping. For all of that, you might need to develop a VBA routine, which could be run through a key-in in a command file.

    Reference keyins can be found in the Help file under "References, Raster Images and Point Clouds". Expand that topic, and there is a section specifically named "References Keyins"

    MaryB

    Power GeoPak 08.11.09.918
    Power InRoads 08.11.09.918
    OpenRoads Designer 2021 R2

        

  • If you detatch and attach new you loose all settings that you may have done (levels off, overrides, etc.) to the first reference. So the rename reference approach here is good to keep the seetings.

    For example you get a new revision of a "background" file that you only need to see particular levels of in your context (floorplans, terrain etc,)

    I do it manually in the reference dialog > filename and exchange the previous version with the new one. That keeps all the settings intact - like the above tool probably will.

  • remember that any person or an AI as well may not always give a correct answer... "*** cautela sumere ("*** grano salis)". Literally translated, this means "To take with caution (with a grain of salt)". This expression was coined by the Roman author Pliny the Elder and means something like "Be cautious, but also be skeptical".

    Just out of curiosity I asked ChatGPT and got this after a little more questioning in the ChatGPT dialog: (what do you think?)

    How make it work in a batch, I asked as well (answer see beneath the code section)

    ....CODE

    Sure, here's an updated version of the VBA macro that reads the list of reference files to be replaced from a text file. The text file should contain one line for each reference file, with the old reference filename and the new reference filename separated by a comma. The filenames should include the full path to the files.

    ```
    Sub ReplaceReferences()
    Dim ref As Element
    Dim newRefName As String
    Dim oldRefName As String
    Dim fileName As String
    Dim fileNum As Integer

    fileName = "C:\path\to\file\references.txt" ' specify the path and filename of the text file containing the list of reference files

    fileNum = FreeFile()
    Open fileName For Input As #fileNum

    ' loop through each line of the text file
    Do Until EOF(fileNum)
    Line Input #fileNum, lineText
    lineParts = Split(lineText, ",")
    oldRefName = Trim(lineParts(0))
    newRefName = Trim(lineParts(1))

    ' loop through all references in the active model
    For Each ref In ActiveModelReference.Attachments
    If ref.Name = oldRefName Then
    ' replace the reference
    ref.Replace newRefName
    End If
    Next ref
    Loop

    Close #fileNum
    End Sub
    ```

    In this version of the macro, the list of reference files to be replaced is read from a text file specified by the `fileName` variable. The macro loops through each line of the text file, splitting it into the old reference filename and the new reference filename. For each reference in the active model, the macro checks if its name matches the old reference filename. If a match is found, the reference is replaced with the new reference filename.

    Note that the text file should have one line per reference file and the old and new reference filenames should be separated by a comma with no spaces. Also, make sure to update the `fileName` variable with the correct path and filename of the text file before running the macro.

    ...BATCH

    To run the VBA macro from a MicroStation batch routine, you can use the following steps:

    1. Open the Macro dialog box in MicroStation by selecting `Utilities > Macro > Macros...` from the main menu.

    2. Click on the `New` button to create a new macro.

    3. Paste the VBA code for the macro into the code editor.

    4. Save the macro with a meaningful name, such as "ReplaceReferences".

    5. Close the Macro dialog box.

    6. Create a batch file using a text editor, such as Notepad.

    7. In the batch file, add the following command to run the macro:

    ```
    C:\path\to\microstation\ustation.exe -batch C:\path\to\macro\ReplaceReferences.mac
    ```

    Replace `C:\path\to\microstation\ustation.exe` with the path to the MicroStation executable file on your system, and `C:\path\to\macro\ReplaceReferences.mac` with the full path to the macro file you saved in step 4.

    8. Save the batch file with a meaningful name, such as "ReplaceReferencesBatch".

    9. Double-click on the batch file to run it.

    The MicroStation application will start and run the macro, replacing the references in the active model as specified in the macro code. Once the macro completes, the application will close automatically.

    Note that you may need to adjust the paths in the batch file to match the locations of the MicroStation executable file and the macro file on your system. Also, make sure that the active model is set to the correct one before running the macro, as the macro will replace the references in the active model.

Reply
  • remember that any person or an AI as well may not always give a correct answer... "*** cautela sumere ("*** grano salis)". Literally translated, this means "To take with caution (with a grain of salt)". This expression was coined by the Roman author Pliny the Elder and means something like "Be cautious, but also be skeptical".

    Just out of curiosity I asked ChatGPT and got this after a little more questioning in the ChatGPT dialog: (what do you think?)

    How make it work in a batch, I asked as well (answer see beneath the code section)

    ....CODE

    Sure, here's an updated version of the VBA macro that reads the list of reference files to be replaced from a text file. The text file should contain one line for each reference file, with the old reference filename and the new reference filename separated by a comma. The filenames should include the full path to the files.

    ```
    Sub ReplaceReferences()
    Dim ref As Element
    Dim newRefName As String
    Dim oldRefName As String
    Dim fileName As String
    Dim fileNum As Integer

    fileName = "C:\path\to\file\references.txt" ' specify the path and filename of the text file containing the list of reference files

    fileNum = FreeFile()
    Open fileName For Input As #fileNum

    ' loop through each line of the text file
    Do Until EOF(fileNum)
    Line Input #fileNum, lineText
    lineParts = Split(lineText, ",")
    oldRefName = Trim(lineParts(0))
    newRefName = Trim(lineParts(1))

    ' loop through all references in the active model
    For Each ref In ActiveModelReference.Attachments
    If ref.Name = oldRefName Then
    ' replace the reference
    ref.Replace newRefName
    End If
    Next ref
    Loop

    Close #fileNum
    End Sub
    ```

    In this version of the macro, the list of reference files to be replaced is read from a text file specified by the `fileName` variable. The macro loops through each line of the text file, splitting it into the old reference filename and the new reference filename. For each reference in the active model, the macro checks if its name matches the old reference filename. If a match is found, the reference is replaced with the new reference filename.

    Note that the text file should have one line per reference file and the old and new reference filenames should be separated by a comma with no spaces. Also, make sure to update the `fileName` variable with the correct path and filename of the text file before running the macro.

    ...BATCH

    To run the VBA macro from a MicroStation batch routine, you can use the following steps:

    1. Open the Macro dialog box in MicroStation by selecting `Utilities > Macro > Macros...` from the main menu.

    2. Click on the `New` button to create a new macro.

    3. Paste the VBA code for the macro into the code editor.

    4. Save the macro with a meaningful name, such as "ReplaceReferences".

    5. Close the Macro dialog box.

    6. Create a batch file using a text editor, such as Notepad.

    7. In the batch file, add the following command to run the macro:

    ```
    C:\path\to\microstation\ustation.exe -batch C:\path\to\macro\ReplaceReferences.mac
    ```

    Replace `C:\path\to\microstation\ustation.exe` with the path to the MicroStation executable file on your system, and `C:\path\to\macro\ReplaceReferences.mac` with the full path to the macro file you saved in step 4.

    8. Save the batch file with a meaningful name, such as "ReplaceReferencesBatch".

    9. Double-click on the batch file to run it.

    The MicroStation application will start and run the macro, replacing the references in the active model as specified in the macro code. Once the macro completes, the application will close automatically.

    Note that you may need to adjust the paths in the batch file to match the locations of the MicroStation executable file and the macro file on your system. Also, make sure that the active model is set to the correct one before running the macro, as the macro will replace the references in the active model.

Children