<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://communities.bentley.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>delete all sheet models</title><link>https://communities.bentley.com/products/microstation/f/microstation-forum/237793/delete-all-sheet-models</link><description>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</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: delete all sheet models</title><link>https://communities.bentley.com/thread/739738?ContentTypeID=1</link><pubDate>Tue, 01 Nov 2022 23:52:36 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:0a7a528d-3d1a-4a91-bdce-8268f5534c6e</guid><dc:creator>Kevin van Haaren</dc:creator><description>&lt;p&gt;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) &amp;quot;model delete layout&amp;quot; then &amp;quot;model delete layout1&amp;quot; etc... But then each command prompts if you&amp;#39;re sure you want to delete the model, even if the model doesn&amp;#39;t exist, so that&amp;#39;s 20 clicks every file.&lt;/p&gt;
&lt;p&gt;Anyway, I took the vba from here:&amp;nbsp;&lt;a href="/products/programming/microstation_programming/w/wiki/12628/deleting-all-models"&gt;Deleting all models - MicroStation Programming - Wiki - MicroStation Programming - Bentley Communities&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;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&amp;#39;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.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;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
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If you only want to delete sheet models with a name beginning with &amp;quot;layout&amp;quot; and leave others behind you&amp;#39;ll have to add that yourself.&lt;/p&gt;
&lt;p&gt;Create an mvba file, add that into a the module in the file, save it.&lt;/p&gt;
&lt;p&gt;make a batch process command file that is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;vba load &amp;quot;path\to\your.mvba&amp;quot;&lt;/li&gt;
&lt;li&gt;vba run delete_all_sheet_models&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Oh, this assumes&amp;nbsp;the first model is the default model that you want to keep. Generally that&amp;#39;s true when you create a dgn file from a dgn seed file, not sure it&amp;#39;s true for converted files so you&amp;#39;ll have to check.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>