<?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>Microstation VBA Batch Cell Replacement</title><link>https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/103086/microstation-vba-batch-cell-replacement</link><description>I have created a program which will go through all my DGN drawings that are in many sub folders in a Master Folder. ( Example: C:/MasterFolder/Subfolder/1234.DGN) 
 My program goes through each element looking for specific cell name and when it does find</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Microstation VBA Batch Cell Replacement</title><link>https://communities.bentley.com/thread/308348?ContentTypeID=1</link><pubDate>Thu, 11 Dec 2014 08:12:08 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:1b459fa8-2e18-4e12-a840-5621cc4cebd3</guid><dc:creator>Lorys</dc:creator><description>&lt;p&gt;I don&amp;#39;t understand why you don&amp;#39;t just use the batch processor in microstation and use the function replace cell..&lt;/p&gt;
&lt;p&gt;if all your cell libraries are defined in your workspace and the cell names are unique then the replace cell command can be placed into the batch processor script&lt;/p&gt;
&lt;p&gt;first for one defined cell , then the others in turn&amp;nbsp;&amp;nbsp; this came be saved and rerun&amp;nbsp; say on several files at a time or the whole folder you need to end with file design so it saves the changes... much easier with the internal tools than coming up with vba and you can run it overnight and it wont crash...&lt;/p&gt;
&lt;p&gt;Try it with just 2 or 3 test files first and you&amp;#39;ll work it out in no time... I love the batch processor...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Microstation VBA Batch Cell Replacement</title><link>https://communities.bentley.com/thread/307966?ContentTypeID=1</link><pubDate>Mon, 08 Dec 2014 19:25:36 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:c535c0fb-60a9-4ef4-a899-0f529988df7c</guid><dc:creator>Rod Wing</dc:creator><description>If you look at the first line of code I posted it is defined as a constant set to the location of your cell lib&lt;br /&gt;
&lt;br /&gt;
Const CELL_LIB_NAME As String = &amp;quot;J:\Microstation\WSMOD\Medesign\V8_Cells\MECELIB\parts.cel&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It&amp;#39;s a good idea to define things like this at the top of your code module so that if you want to modify this to run against a different cell library you don&amp;#39;t have to go searching through your code.&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Microstation VBA Batch Cell Replacement</title><link>https://communities.bentley.com/thread/307963?ContentTypeID=1</link><pubDate>Mon, 08 Dec 2014 19:14:57 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:cffbb8bd-fec7-4798-a8b0-67a5699a4387</guid><dc:creator>kevindragonduong</dc:creator><description>btw what is  CELL_LIB_NAME?&lt;br /&gt;
&lt;br /&gt;
&amp;quot;.SendCommand &amp;quot;rc=&amp;quot; &amp;amp; CELL_LIB_NAME&amp;quot;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Microstation VBA Batch Cell Replacement</title><link>https://communities.bentley.com/thread/307935?ContentTypeID=1</link><pubDate>Mon, 08 Dec 2014 16:38:18 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:7146acec-4d0d-441a-aa46-44a340a22eb6</guid><dc:creator>Jon Summers</dc:creator><description>&lt;p&gt;[quote user=&amp;quot;kevindragonduong&amp;quot;]Is there a way to have a timer in MicroStation?[/quote]&lt;/p&gt;
&lt;p&gt;Search VBA help for keyword &lt;em&gt;timer&lt;/em&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Microstation VBA Batch Cell Replacement</title><link>https://communities.bentley.com/thread/307934?ContentTypeID=1</link><pubDate>Mon, 08 Dec 2014 16:23:38 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:2c92d7bc-b0de-425a-aeef-355cde419a85</guid><dc:creator>kevindragonduong</dc:creator><description>thank you for the reply, i was wondering. is there a way to have a timer in microstation? i have searched but have had no luck&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Microstation VBA Batch Cell Replacement</title><link>https://communities.bentley.com/thread/307918?ContentTypeID=1</link><pubDate>Mon, 08 Dec 2014 14:57:06 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:67a12f21-c5cf-414c-a758-5edbfbac7028</guid><dc:creator>Rod Wing</dc:creator><description>&lt;p&gt;I didn&amp;#39;t take a close look at everything in your code, but found a few glaring things that should be cleaned up.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The first thing is that some of your variables are miscast. For example your xcoord and ycoord variables are set to Integer when they storing double values. For better efficiency these are should be replaced by a single Point3d data type.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;You can issue key-in commands to replace the reliance on the modal dialog handler, you will see that in the update to your&lt;strong&gt; stuff&lt;/strong&gt; sub below.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Which brings me to my next point, name your functions a subs with more meaningful names.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;I&amp;#39;m not sure why you were doing the double scan of the model to grab the cells and find the cells by name. That can be done in a single scan.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Don&amp;#39;t try to process all 12000+ dgn files at once. Divide the processing into smaller sets of jobs/projects.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I&amp;#39;ve made some updates to your &lt;strong&gt;getting&lt;/strong&gt; and &lt;strong&gt;stuff&lt;/strong&gt; routines and posted them below.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Const CELL_LIB_NAME As String = &amp;quot;J:\Microstation\WSMOD\Medesign\V8_Cells\MECELIB\parts.cel&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;#39;These are double values, and should be stored in a single Point3d data type&lt;br /&gt;&amp;#39;Dim xcoord, ycoord As Integer&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Dim ptOrigin As Point3d&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;br /&gt;&amp;#39;Don&amp;#39;t use Variants unless absolutely necessary&lt;br /&gt;&amp;#39;Names are stored as Strings&lt;br /&gt;&amp;#39;Dim CellName As Variant&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Dim CellName As String&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;#39;This counter/index variable is really an Integer value&lt;br /&gt;&amp;#39;Dim i As Double&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Dim i As Integer&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Sub getting()&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left:30px;"&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; Dim oCriteria As New ElementScanCriteria&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; Dim ee As ElementEnumerator &amp;#39;ElementEnumerator is how it is able to search through the entire model for a specific element&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; Dim tc As CellElement&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left:30px;"&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;With oCriteria&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left:60px;"&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; .ExcludeAllTypes&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; .IncludeType msdElementTypeCellHeader&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; .IncludeType msdElementTypeSharedCell&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; .IncludeOnlyCell CellName&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left:30px;"&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;End With&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left:30px;"&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;#39; &amp;#39;searches for references that fits the criteria ( type header, and shared cell) and sets it as ee&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;#39; Set ee = ActiveModelReference.Scan(oCriteria)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;#39;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;#39; Do While ee.MoveNext&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;#39; If ee.Current.AsCellElement.Name = CStr(CellName) Then &amp;#39;&amp;lt;------name this something different for different changes&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;#39; oCriteria.ExcludeAllTypes&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;#39; oCriteria.IncludeType msdElementTypeCellHeader&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;#39; oCriteria.IncludeType msdElementTypeSharedCell&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;#39; End If&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;#39; Loop&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;#39;&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; Set ee = ActiveModelReference.Scan(oCriteria)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left:30px;"&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;#39;DO NOT CHANGE SCALING FACTORS/NUMBER UNLESS NECESSARY&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; Do While ee.MoveNext&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left:60px;"&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; Set tc = ee.Current&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; &amp;#39;tc.ResetElementEnumeration&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; &amp;#39;xcoord = tc.Origin.X&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; &amp;#39;ycoord = tc.Origin.Y&lt;/span&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; ptOrigin = tc.Origin&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; Call stuff&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left:30px;"&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Loop&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;End Sub&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;Sub stuff()&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left:30px;"&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; With CadInputQueue&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left:60px;"&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; .SendCommand &amp;quot;rc=&amp;quot; &amp;amp; CELL_LIB_NAME&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; .SendCommand &amp;quot;ac=&amp;quot; &amp;amp; CellName&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; .SendCommand &amp;quot;REPLACE CELLS EXTENDED&amp;quot;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; .SendDataPoint ptOrigin&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; .SendDataPoint ptOrigin&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left:30px;"&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;End With&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin-left:30px;"&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;CommandState.StartDefaultCommand&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;End Sub&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>