delete all sheet models

how can I delete all sheet models that have different names in a batch process

I cant go through 200 dwg files that were translated into ms  and  add them into a txt file

model delete layout
model delete layout1
model delete layout2

  • Only way I know to do it is with VBA. You could try and brute force it with a batch processor command file that was just 20 (or however many you needed) "model delete layout" then "model delete layout1" etc... But then each command prompts if you're sure you want to delete the model, even if the model doesn't exist, so that's 20 clicks every file.

    Anyway, I took the vba from here: Deleting all models - MicroStation Programming - Wiki - MicroStation Programming - Bentley Communities

    and modified it to delete all the sheet models in a file. Note there is a bug in the original that if your loop starts at 2 and counts up you'll get an error because as models are deleted the indexes of the models left behind all change. Going through the models backwards fixes that.

    Sub delete_all_sheet_models()
    
        Dim allModels As ModelReferences
        Dim thisModel As ModelReference
        Dim i As Long
        
        Set allModels = ActiveDesignFile.Models
        allModels(1).Activate
        For i = allModels.Count To 2 Step -1
            Set thisModel = allModels(i)
            If thisModel.Type = msdModelTypeSheet Then
                allModels.Delete thisModel
            End If
        Next
    
    End Sub
    

    If you only want to delete sheet models with a name beginning with "layout" and leave others behind you'll have to add that yourself.

    Create an mvba file, add that into a the module in the file, save it.

    make a batch process command file that is:

    • vba load "path\to\your.mvba"
    • vba run delete_all_sheet_models

    Oh, this assumes the first model is the default model that you want to keep. Generally that's true when you create a dgn file from a dgn seed file, not sure it's true for converted files so you'll have to check.