<?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/"><channel><title>Calculating the range of Rotated Cells</title><link>https://communities.bentley.com/products/microstation/w/microstation__wiki/21861/calculating-the-range-of-rotated-cells</link><description>Bentley View, MicroStation, PowerDraft</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>Calculating the range of Rotated Cells</title><link>https://communities.bentley.com/products/microstation/w/microstation__wiki/21861/calculating-the-range-of-rotated-cells</link><pubDate>Thu, 09 Jul 2015 15:24:48 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:f1feea52-6913-43ad-bebe-e7978e582352</guid><dc:creator>Maggie Fortescue</dc:creator><comments>https://communities.bentley.com/products/microstation/w/microstation__wiki/21861/calculating-the-range-of-rotated-cells#comments</comments><description>Current Revision posted to MicroStation Wiki by Maggie Fortescue on 7/9/2015 3:24:48 PM&lt;br /&gt;
&lt;h1&gt;&lt;b&gt;&lt;img style="border-width:0px;" alt=" " src="/cfs-file.ashx/__key/communityserver-components-sitefiles/TSG-Logo.png" width="189" height="60" /&gt;&lt;/b&gt;&lt;/h1&gt;
&lt;table style="width:500px;background-color:#dce5f0;border:#dce5f0 0px solid;" border="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;span style="font-size:medium;"&gt;&lt;b&gt;Applies To&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Product(s):&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;MicroStation&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Version(s):&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;08.11.09.578&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Environment:&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Windows 7 32 bit,Windows 7 64 bit&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Area:&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Programming&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Subarea:&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;VBA&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Original Author:&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Tristan Anderson, Bentley Technical Support Group&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2&gt;&amp;nbsp;Background Information&lt;/h2&gt;
&lt;p&gt;To calculate the size of a cell (also referred to as range), you can use the VBA property Range.&lt;br /&gt;The datatype Range includes two points, typically the lower left and top right corners of the smallest rectangle enclosing the cell.&lt;br /&gt;This range can also be calculated in 3D analog. Although the following examples can also work in 3D, I have shown everything in 2D for illustrative purposes.&lt;br /&gt;Be aware that the range box of a given element is always orthogonal to the identify view and a rotated view will always show/calculate a rotated range block that will differ from the identity.&lt;/p&gt;
&lt;h2&gt;Steps&lt;/h2&gt;
&lt;p&gt;To demonstrate the problem, this example will show a simple procedure for non-rotated cells. Consider the following example with two cells with the names CellA and CellB:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/9.PNG"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/9.PNG" width="635" height="234" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To determine the size of these cells, you can use the Range property in a cell, as shown in an example below:&lt;/p&gt;
&lt;pre class="brush: vb; fontsize: 100; first-line: 1; "&gt;Sub range_simple()
    Dim rangeBox As Range3d
    Dim Ee As ElementEnumerator
    Set Ee = ActiveModelReference.GraphicalElementCache.Scan
    Do While Ee.MoveNext
        If Ee.Current.Type = msdElementTypeCellHeader Then
            Debug.Print &amp;quot;Name of Cell: &amp;quot; &amp;amp; Ee.Current.AsCellElement.Name
            rangeBox = Ee.Current.AsCellElement.range
            Debug.Print &amp;quot;Width and Height: &amp;quot;, rangeBox.High.X - rangeBox.Low.X, rangeBox.High.Y - rangeBox.Low.Y
        End If
    Loop
End Sub&lt;/pre&gt;
&lt;p&gt;The issue is not shown here, as the two cells currently have identical dimensions:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/10.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/10.png" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If, however, one cell is rotated as shown below:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/11.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/11.png" width="526" height="267" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The results of the calculation will be changed:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/12.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/12.png" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The rotated cell now shows a different size from the Range property. The reason, however, in the range calculation is shown below&lt;/p&gt;
&lt;p&gt;by the Keying &amp;quot;set range;Update1&amp;quot;:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/13.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/13.png" width="556" height="287" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To compensate for this error, you can simply turn the rotated cell back to its original position to calculate the size correctly.&lt;br /&gt;For this, I used the following example:&lt;/p&gt;
&lt;pre class="brush: vb; fontsize: 100; first-line: 1; "&gt;Sub range_untwisted()
    Dim rangeBox As Range3d
    Dim Rotate As Matrix3d
    Dim transForm As Transform3d
    Dim Ee As ElementEnumerator
    Set Ee = ActiveModelReference.GraphicalElementCache.Scan
    Do While Ee.MoveNext
        If Ee.Current.Type = msdElementTypeCellHeader Then
            Debug.Print &amp;quot;Name of Cell: &amp;quot; &amp;amp; Ee.Current.AsCellElement.Name
             
            &amp;#39;Cell untwisted examine:
            Rotate = Ee.Current.AsCellElement.Rotation
            Rooted = Matrix3dInverse(Roooted)
            transForm = Transform3dFromMatrix3dAndFixedPoint3d(Rotat, Ee.Current.AsCellElement.Origin)
            Ee.Current.AsCellElement.transForm transForm
             
            rangeBox = Ee.Current.AsCellElement.range
            Debug.Print &amp;quot;Width and Height: &amp;quot;, rangeBox.High.X - rangeBox.Low.X, rangeBox.High.Y - rangeBox.Low.Y
        End If
Loop
End Sub&lt;/pre&gt;
&lt;p&gt;First, the current rotation of the cell is read (.rotation), and the inverse matrix (Matrix3dInverse) is calculated to reverse the rotation.&lt;br /&gt;From the inverse matrix, we create a transformation (Transform3dFromMatrix3dAndFixedPoint3d) to use on the cell (.transform).&lt;br /&gt;When executing again, we get the same results as the first time:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/10.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/10.png" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Interestingly, this has not changed the drawing itself, because the rotation of the cells was only carried out in memory.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: VBAWindows 7 32 bit, MicroStation, Windows 7 64 bit, Programming, en, 08.11.09.578, SELECTsupport&lt;/div&gt;
</description></item><item><title>Calculating the range of Rotated Cells</title><link>https://communities.bentley.com/products/microstation/w/microstation__wiki/21861/calculating-the-range-of-rotated-cells/revision/4</link><pubDate>Wed, 08 Jul 2015 20:50:32 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:f1feea52-6913-43ad-bebe-e7978e582352</guid><dc:creator>Maggie Fortescue</dc:creator><comments>https://communities.bentley.com/products/microstation/w/microstation__wiki/21861/calculating-the-range-of-rotated-cells#comments</comments><description>Revision 4 posted to MicroStation Wiki by Maggie Fortescue on 7/8/2015 8:50:32 PM&lt;br /&gt;
&lt;h1&gt;&lt;b&gt;&lt;img style="border-width:0px;" alt=" " src="/cfs-file.ashx/__key/communityserver-components-sitefiles/TSG-Logo.png" width="189" height="60" /&gt;&lt;/b&gt;&lt;/h1&gt;
&lt;table style="width:500px;background-color:#dce5f0;border:#dce5f0 0px solid;" border="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;span style="font-size:medium;"&gt;&lt;b&gt;Applies To&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Product(s):&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;MicroStation&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Version(s):&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;08.11.09.578&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Environment:&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Windows 7 32 bit,Windows 7 64 bit&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Area:&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Programming&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Subarea:&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;VBA&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Original Author:&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Tristan Anderson, Bentley Technical Support Group&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2&gt;&amp;nbsp;Background Information&lt;/h2&gt;
&lt;p&gt;To calculate the size of a cell (also referred to as range), you can use the VBA property Range.&lt;br /&gt;The datatype Range includes two points, typically the lower left and top right corners of the smallest rectangle enclosing the cell.&lt;br /&gt;This range can also be calculated in 3D analog. Although the following examples can also work in 3D, I have shown everything in 2D for illustrative purposes.&lt;br /&gt;Be aware that the range box of a given element is always orthogonal to the identify view and a rotated view will always show/calculate a rotated range block that will differ from the identity.&lt;/p&gt;
&lt;h2&gt;Steps&lt;/h2&gt;
&lt;p&gt;To demonstrate the problem, this example will show a simple procedure for non-rotated cells. Consider the following example with two cells with the names CellA and CellB:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/9.PNG"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/9.PNG" width="635" height="234" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To determine the size of these cells, you can use the .Range property in a cell, as shown in an example below:&lt;/p&gt;
&lt;pre class="brush: vb; fontsize: 100; first-line: 1; "&gt;Sub range_simple()
    Dim rangeBox As Range3d
    Dim Ee As ElementEnumerator
    Set Ee = ActiveModelReference.GraphicalElementCache.Scan
    Do While Ee.MoveNext
        If Ee.Current.Type = msdElementTypeCellHeader Then
            Debug.Print &amp;quot;Name of Cell: &amp;quot; &amp;amp; Ee.Current.AsCellElement.Name
            rangeBox = Ee.Current.AsCellElement.range
            Debug.Print &amp;quot;Width and Height: &amp;quot;, rangeBox.High.X - rangeBox.Low.X, rangeBox.High.Y - rangeBox.Low.Y
        End If
    Loop
End Sub&lt;/pre&gt;
&lt;p&gt;The issue is not shown here, as the two cells currently have identical dimensions:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/10.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/10.png" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If, however, one cell is rotated as shown below:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/11.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/11.png" width="526" height="267" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The results of the calculation will be changed:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/12.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/12.png" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The rotated cell now shows a different size from the Range property. The reason, however, in the range calculation is shown below&lt;/p&gt;
&lt;p&gt;by the Keying &amp;quot;set range;Update1&amp;quot;:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/13.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/13.png" width="556" height="287" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To compensate for this error, you can simply turn the rotated cell back to its original position to calculate the size correctly.&lt;br /&gt;For this, I used the following example:&lt;/p&gt;
&lt;pre class="brush: vb; fontsize: 100; first-line: 1; "&gt;Sub range_untwisted()
    Dim rangeBox As Range3d
    Dim Rotate As Matrix3d
    Dim transForm As Transform3d
    Dim Ee As ElementEnumerator
    Set Ee = ActiveModelReference.GraphicalElementCache.Scan
    Do While Ee.MoveNext
        If Ee.Current.Type = msdElementTypeCellHeader Then
            Debug.Print &amp;quot;Name of Cell: &amp;quot; &amp;amp; Ee.Current.AsCellElement.Name
             
            &amp;#39;Cell untwisted examine:
            Rotate = Ee.Current.AsCellElement.Rotation
            Rooted = Matrix3dInverse(Roooted)
            transForm = Transform3dFromMatrix3dAndFixedPoint3d(Rotat, Ee.Current.AsCellElement.Origin)
            Ee.Current.AsCellElement.transForm transForm
             
            rangeBox = Ee.Current.AsCellElement.range
            Debug.Print &amp;quot;Width and Height: &amp;quot;, rangeBox.High.X - rangeBox.Low.X, rangeBox.High.Y - rangeBox.Low.Y
        End If
Loop
End Sub&lt;/pre&gt;
&lt;p&gt;First, the current rotation of the cell is read (.rotation), and the inverse matrix (Matrix3dInverse) is calculated to reverse the rotation.&lt;br /&gt;From the inverse matrix, we create a transformation (Transform3dFromMatrix3dAndFixedPoint3d) to use on the cell (.transform).&lt;br /&gt;When executing again, we get the same results as the first time:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/10.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/10.png" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Interestingly, this has not changed the drawing itself, because the rotation of the cells was only carried out in memory.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: VBAWindows 7 32 bit, MicroStation, Windows 7 64 bit, Programming, en, 08.11.09.578, SELECTsupport&lt;/div&gt;
</description></item><item><title>Calculating the range of Rotated Cells</title><link>https://communities.bentley.com/products/microstation/w/microstation__wiki/21861/calculating-the-range-of-rotated-cells/revision/3</link><pubDate>Tue, 09 Jun 2015 16:49:03 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:f1feea52-6913-43ad-bebe-e7978e582352</guid><dc:creator>Tristan Anderson</dc:creator><comments>https://communities.bentley.com/products/microstation/w/microstation__wiki/21861/calculating-the-range-of-rotated-cells#comments</comments><description>Revision 3 posted to MicroStation Wiki by Tristan Anderson on 6/9/2015 4:49:03 PM&lt;br /&gt;
&lt;h1&gt;&lt;b&gt;&lt;img style="border-width:0px;" alt=" " src="/cfs-file.ashx/__key/communityserver-components-sitefiles/TSG-Logo.png" width="189" height="60" /&gt;&lt;/b&gt;&lt;/h1&gt;
&lt;table style="width:500px;background-color:#dce5f0;border:#dce5f0 0px solid;" border="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;span style="font-size:medium;"&gt;&lt;b&gt;Applies To&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Product(s):&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;MicroStation&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Version(s):&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;08.11.09.578&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Environment:&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Windows 7 32 bit,Windows 7 64 bit&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Area:&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Programming&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Subarea:&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;VBA&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Original Author:&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Tristan Anderson, Bentley Technical Support Group&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2&gt;&amp;nbsp;Background Information&lt;/h2&gt;
&lt;p&gt;To calculate the size of a cell (also reffered to as range), you can use the VBA property .Range.&lt;br /&gt;The datatype Range includes two points, typically the lower left and top right corners of the smallest rectangle enclosing the cell.&lt;br /&gt;This range can also be calculated in 3D analog. Although the following examples can also work in 3D, I have shown everything in 2D for illustrative purposes.&lt;br /&gt;Be aware that the range box of a given element is always orthogonal to the identify view and a rotated view will always show/calculate a rotated range block that will differ from the identity.&lt;/p&gt;
&lt;h2&gt;Steps&lt;/h2&gt;
&lt;p&gt;To demonstrate the problem, this example will show a simple profedure for non-rotated cells. Consider the following example with two cells with the names CellA and CellB:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/9.PNG"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/9.PNG" width="635" height="234" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To determine the size of these cells, you can use the .Range property in a cell, as shown in an example below:&lt;/p&gt;
&lt;pre class="brush: vb; fontsize: 100; first-line: 1; "&gt;Sub range_simple()
    Dim rangeBox As Range3d
    Dim Ee As ElementEnumerator
    Set Ee = ActiveModelReference.GraphicalElementCache.Scan
    Do While Ee.MoveNext
        If Ee.Current.Type = msdElementTypeCellHeader Then
            Debug.Print &amp;quot;Name of Cell: &amp;quot; &amp;amp; Ee.Current.AsCellElement.Name
            rangeBox = Ee.Current.AsCellElement.range
            Debug.Print &amp;quot;Width and Height: &amp;quot;, rangeBox.High.X - rangeBox.Low.X, rangeBox.High.Y - rangeBox.Low.Y
        End If
    Loop
End Sub&lt;/pre&gt;
&lt;p&gt;The issue is not shown here, as the two cells currentlyhave identical dimensions:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/10.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/10.png" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If, however, one cell is rotated as shown below:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/11.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/11.png" width="526" height="267" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The results of the calculation will be changed:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/12.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/12.png" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The rotated cell now shows a different size from the .Range property. The reason, however, in the range calculation is shown below&lt;/p&gt;
&lt;p&gt;by the Keying &amp;quot;set range;Update1&amp;quot;:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/13.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/13.png" width="556" height="287" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To compensate for this error, you can simply turn the rotated cell back to its original position to calculate the size correctly.&lt;br /&gt;For this, I used the following example:&lt;/p&gt;
&lt;pre class="brush: vb; fontsize: 100; first-line: 1; "&gt;Sub range_untwisted()
    Dim rangeBox As Range3d
    Dim Rotate As Matrix3d
    Dim transForm As Transform3d
    Dim Ee As ElementEnumerator
    Set Ee = ActiveModelReference.GraphicalElementCache.Scan
    Do While Ee.MoveNext
        If Ee.Current.Type = msdElementTypeCellHeader Then
            Debug.Print &amp;quot;Name of Cell: &amp;quot; &amp;amp; Ee.Current.AsCellElement.Name
             
            &amp;#39;Cell untwisted examine:
            Rotate = Ee.Current.AsCellElement.Rotation
            Rooted = Matrix3dInverse(Roooted)
            transForm = Transform3dFromMatrix3dAndFixedPoint3d(Rotat, Ee.Current.AsCellElement.Origin)
            Ee.Current.AsCellElement.transForm transForm
             
            rangeBox = Ee.Current.AsCellElement.range
            Debug.Print &amp;quot;Width and Height: &amp;quot;, rangeBox.High.X - rangeBox.Low.X, rangeBox.High.Y - rangeBox.Low.Y
        End If
Loop
End Sub&lt;/pre&gt;
&lt;p&gt;First, the current rotation of the cell is read (.rotation), and the inverse matrix (Matrix3dInverse) is calculated to reverse the rotation.&lt;br /&gt;From the inverse matrix, we create a transformation (Transform3dFromMatrix3dAndFixedPoint3d) to use on the cell (.transform).&lt;br /&gt;When executing again, we get the same results as the first time:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/10.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/10.png" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Interestingly, this has not changed the drawing itself, because the rotation of the cells was only carried out in memory.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: VBAWindows 7 32 bit, MicroStation, Windows 7 64 bit, Programming, en, 08.11.09.578, SELECTsupport&lt;/div&gt;
</description></item><item><title>Calculating the range of Rotated Cells</title><link>https://communities.bentley.com/products/microstation/w/microstation__wiki/21861/calculating-the-range-of-rotated-cells/revision/2</link><pubDate>Tue, 09 Jun 2015 16:46:51 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:f1feea52-6913-43ad-bebe-e7978e582352</guid><dc:creator>Tristan Anderson</dc:creator><comments>https://communities.bentley.com/products/microstation/w/microstation__wiki/21861/calculating-the-range-of-rotated-cells#comments</comments><description>Revision 2 posted to MicroStation Wiki by Tristan Anderson on 6/9/2015 4:46:51 PM&lt;br /&gt;
&lt;h1&gt;&lt;b&gt;&lt;img style="border-width:0px;" alt=" " src="/cfs-file.ashx/__key/communityserver-components-sitefiles/TSG-Logo.png" width="189" height="60" /&gt;&lt;/b&gt;&lt;/h1&gt;
&lt;table style="width:500px;background-color:#dce5f0;border:#dce5f0 0px solid;" border="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;span style="font-size:medium;"&gt;&lt;b&gt;Applies To&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Product(s):&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;MicroStation&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Version(s):&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;08.11.09.578&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Environment:&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Windows 7 32 bit,Windows 7 64 bit&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Area:&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Programming&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Subarea:&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;VBA&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Original Author:&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Tristan Anderson, Bentley Technical Support Group&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&amp;nbsp;Background Information&lt;br /&gt;To calculate the size of a cell (also reffered to as range), you can use the VBA property .Range.&lt;br /&gt;The datatype Range includes two points, typically the lower left and top right corners of the smallest rectangle enclosing the&lt;/p&gt;
&lt;p&gt;cell.&lt;br /&gt;This range can also be calculated in 3D analog. Although the following examples can also work in 3D, I have shown everything in 2D&lt;/p&gt;
&lt;p&gt;for illustrative purposes.&lt;br /&gt;Be aware that the range box of a given element is always orthogonal to the identify view and a rotated view will always&lt;/p&gt;
&lt;p&gt;show/calculate a rotated range block that will differ from the identity.&lt;/p&gt;
&lt;p&gt;Steps&lt;br /&gt;To demonstrate the problem, this example will show a simple profedure for non-rotated cells. Consider the following example with&lt;/p&gt;
&lt;p&gt;two cells with the names CellA and CellB:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/9.PNG"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/9.PNG" width="635" height="234" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To determine the size of these cells, you can use the .Range property in a cell, as shown in an example below:&lt;/p&gt;
&lt;pre class="brush: vb; fontsize: 100; first-line: 1; "&gt;Sub range_simple()
    Dim rangeBox As Range3d
    Dim Ee As ElementEnumerator
    Set Ee = ActiveModelReference.GraphicalElementCache.Scan
    Do While Ee.MoveNext
        If Ee.Current.Type = msdElementTypeCellHeader Then
            Debug.Print &amp;quot;Name of Cell: &amp;quot; &amp;amp; Ee.Current.AsCellElement.Name
            rangeBox = Ee.Current.AsCellElement.range
            Debug.Print &amp;quot;Width and Height: &amp;quot;, rangeBox.High.X - rangeBox.Low.X, rangeBox.High.Y - rangeBox.Low.Y
        End If
    Loop
End Sub&lt;/pre&gt;
&lt;p&gt;The issue is not shown here, as the two cells currentlyhave identical dimensions:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/10.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/10.png" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If, however, one cell is rotated as shown below:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/11.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/11.png" width="526" height="267" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The results of the calculation will be changed:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/12.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/12.png" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The rotated cell now shows a different size from the .Range property. The reason, however, in the range calculation is shown below&lt;/p&gt;
&lt;p&gt;by the Keying &amp;quot;set range;Update1&amp;quot;:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/13.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/13.png" width="556" height="287" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To compensate for this error, you can simply turn the rotated cell back to its original position to calculate the size correctly.&lt;br /&gt;For this, I used the following example:&lt;/p&gt;
&lt;pre class="brush: vb; fontsize: 100; first-line: 1; "&gt;Sub range_untwisted()
    Dim rangeBox As Range3d
    Dim Rotate As Matrix3d
    Dim transForm As Transform3d
    Dim Ee As ElementEnumerator
    Set Ee = ActiveModelReference.GraphicalElementCache.Scan
    Do While Ee.MoveNext
        If Ee.Current.Type = msdElementTypeCellHeader Then
            Debug.Print &amp;quot;Name of Cell: &amp;quot; &amp;amp; Ee.Current.AsCellElement.Name
             
            &amp;#39;Cell untwisted examine:
            Rotate = Ee.Current.AsCellElement.Rotation
            Rooted = Matrix3dInverse(Roooted)
            transForm = Transform3dFromMatrix3dAndFixedPoint3d(Rotat, Ee.Current.AsCellElement.Origin)
            Ee.Current.AsCellElement.transForm transForm
             
            rangeBox = Ee.Current.AsCellElement.range
            Debug.Print &amp;quot;Width and Height: &amp;quot;, rangeBox.High.X - rangeBox.Low.X, rangeBox.High.Y - rangeBox.Low.Y
        End If
Loop
End Sub&lt;/pre&gt;
&lt;p&gt;First, the current rotation of the cell is read (.rotation), and the inverse matrix (Matrix3dInverse) is calculated to reverse the rotation.&lt;br /&gt;From the inverse matrix, we create a transformation (Transform3dFromMatrix3dAndFixedPoint3d) to use on the cell (.transform).&lt;br /&gt;When executing again, we get the same results as the first time:&lt;/p&gt;
&lt;p&gt;&lt;a href="/cfs-file/__key/communityserver-wikis-components-files/00-00-00-00-35/10.png"&gt;&lt;img src="/resized-image/__size/940x0/__key/communityserver-wikis-components-files/00-00-00-00-35/10.png" alt=" " /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Interestingly, this has not changed the drawing itself, because the rotation of the cells was only carried out in memory.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: VBAWindows 7 32 bit, MicroStation, Windows 7 64 bit, Programming, en, 08.11.09.578, SELECTsupport&lt;/div&gt;
</description></item><item><title>Calculating the range of Rotated Cells</title><link>https://communities.bentley.com/products/microstation/w/microstation__wiki/21861/calculating-the-range-of-rotated-cells/revision/1</link><pubDate>Tue, 09 Jun 2015 16:13:20 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:f1feea52-6913-43ad-bebe-e7978e582352</guid><dc:creator>Tristan Anderson</dc:creator><comments>https://communities.bentley.com/products/microstation/w/microstation__wiki/21861/calculating-the-range-of-rotated-cells#comments</comments><description>Revision 1 posted to MicroStation Wiki by Tristan Anderson on 6/9/2015 4:13:20 PM&lt;br /&gt;
&lt;h1&gt;&lt;b&gt;&lt;img style="border-left-width:0px;border-right-width:0px;border-bottom-width:0px;border-top-width:0px;" alt=" " src="http://communities.bentley.com/cfs-file.ashx/__key/communityserver-components-sitefiles/TSG-Logo.png" width="189" height="60" /&gt;&lt;/b&gt;&lt;/h1&gt;
&lt;table style="border-top:#dce5f0 0px solid;border-right:#dce5f0 0px solid;width:500px;border-bottom:#dce5f0 0px solid;border-left:#dce5f0 0px solid;background-color:#dce5f0;" border="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;span style="font-size:medium;"&gt;&lt;b&gt;Applies To&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Product(s):&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;MicroStation&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Version(s):&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;08.11.09.578 &lt;/td&gt;
&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Environment:&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Windows 7 32 bit,Windows 7 64 bit&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Area:&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Programming&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Subarea:&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;VBA&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;Original Author:&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Tristan Anderson, Bentley Technical Support Group&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align:right;"&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;&amp;nbsp;Background Information&lt;br /&gt;To calculate the size of a cell (also reffered to as range), you can use the VBA property .Range.&lt;br /&gt;The datatype Range includes two points, typically the lower left and top right corners of the smallest rectangle enclosing the &lt;/p&gt;
&lt;p&gt;cell.&lt;br /&gt;This range can also be calculated in 3D analog. Although the following examples can also work in 3D, I have shown everything in 2D &lt;/p&gt;
&lt;p&gt;for illustrative purposes.&lt;br /&gt;Be aware that the range box of a given element is always orthogonal to the identify view and a rotated view will always &lt;/p&gt;
&lt;p&gt;show/calculate a rotated range block that will differ from the identity.&lt;/p&gt;
&lt;p&gt;Steps&lt;br /&gt;To demonstrate the problem, this example will show a simple profedure for non-rotated cells. Consider the following example with &lt;/p&gt;
&lt;p&gt;two cells with the names CellA and CellB:&lt;/p&gt;
&lt;p&gt;CELL PICTURE&lt;/p&gt;
&lt;p&gt;To determine the size of these cells, you can use the .Range property in a cell, as shown in an example below:&lt;/p&gt;
&lt;p&gt;Sub range_simple()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim rangeBox As Range3d&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim Ee As ElementEnumerator&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set Ee = ActiveModelReference.GraphicalElementCache.Scan&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do While Ee.MoveNext&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If Ee.Current.Type = msdElementTypeCellHeader Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print &amp;quot;Name of Cell: &amp;quot; &amp;amp; Ee.Current.AsCellElement.Name&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rangeBox = Ee.Current.AsCellElement.range&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print &amp;quot;Width and Height: &amp;quot;, rangeBox.High.X - rangeBox.Low.X, rangeBox.High.Y - rangeBox.Low.Y&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop&lt;br /&gt;End Sub&lt;/p&gt;
&lt;p&gt;The issue is not shown here, as the two cells currentlyhave identical dimensions:&lt;/p&gt;
&lt;p&gt;IMMEDIATE WINDOW&lt;/p&gt;
&lt;p&gt;If, however, one cell is rotated as shown below:&lt;/p&gt;
&lt;p&gt;ROTATED CELL&lt;/p&gt;
&lt;p&gt;The results of the calculation will be changed:&lt;/p&gt;
&lt;p&gt;IMMEDIATE 2&lt;/p&gt;
&lt;p&gt;The rotated cell now shows a different size from the .Range property. The reason, however, in the range calculation is shown below &lt;/p&gt;
&lt;p&gt;by the Keying &amp;quot;set range;Update1&amp;quot;:&lt;/p&gt;
&lt;p&gt;CELL 3&lt;/p&gt;
&lt;p&gt;To compensate for this error, you can simply turn the rotated cell back to its original position to calculate the size correctly.&lt;br /&gt;For this, I used the following example:&lt;/p&gt;
&lt;p&gt;Sub range_untwisted()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim rangeBox As Range3d&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim Rotate As Matrix3d&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim transForm As Transform3d&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim Ee As ElementEnumerator&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set Ee = ActiveModelReference.GraphicalElementCache.Scan&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do While Ee.MoveNext&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If Ee.Current.Type = msdElementTypeCellHeader Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print &amp;quot;Name of Cell: &amp;quot; &amp;amp; Ee.Current.AsCellElement.Name&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39;Cell untwisted examine:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rotate = Ee.Current.AsCellElement.Rotation&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rooted = Matrix3dInverse(Roooted)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; transForm = Transform3dFromMatrix3dAndFixedPoint3d(Rotat, Ee.Current.AsCellElement.Origin)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Ee.Current.AsCellElement.transForm transForm&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rangeBox = Ee.Current.AsCellElement.range&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.Print &amp;quot;Width and Height: &amp;quot;, rangeBox.High.X - rangeBox.Low.X, rangeBox.High.Y - rangeBox.Low.Y&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;Loop&lt;br /&gt;End Sub&lt;/p&gt;
&lt;p&gt;First, the current rotation of the cell is read (.rotation), and the inverse matrix (Matrix3dInverse) is calculated to reverse the rotation.&lt;br /&gt;From the inverse matrix, we create a transformation (Transform3dFromMatrix3dAndFixedPoint3d) to use on the cell (.transform).&lt;br /&gt;When executing again, we get the same results as the first time:&lt;/p&gt;
&lt;p&gt;FIRST PICTURE&lt;/p&gt;
&lt;p&gt;Interestingly, this has not changed the drawing itself, because the rotation of the cells was only carried out in memory.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;

&lt;div style="font-size: 90%;"&gt;Tags: VBAWindows 7 32 bit, MicroStation, Windows 7 64 bit, Programming, en, 08.11.09.578, SELECTsupport&lt;/div&gt;
</description></item></channel></rss>