<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic cumlitive TwistAngle problem in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5595803#M40472</link>
    <description>&lt;P&gt;I have some code that gets the twistangle from the currentviewport. It's a basic rectangle viewport. All 2d stuff in model space nothing fancy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;There is a North arrow in the drawing in paper space. The code I've written checks the North arrow rotation to the viewport rotation to ensure they match.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It all works great except for when a user rotates the viewport multiple times. Then the twistangle goes out of wack. It's like it's accumulating the angles and not resetting. I have seen twistangle values past 900 degrees!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VPROTATEASSOC = 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea why this is happening?&lt;/P&gt;</description>
    <pubDate>Thu, 16 Apr 2015 19:45:24 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2015-04-16T19:45:24Z</dc:date>
    <item>
      <title>cumlitive TwistAngle problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5595803#M40472</link>
      <description>&lt;P&gt;I have some code that gets the twistangle from the currentviewport. It's a basic rectangle viewport. All 2d stuff in model space nothing fancy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;There is a North arrow in the drawing in paper space. The code I've written checks the North arrow rotation to the viewport rotation to ensure they match.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It all works great except for when a user rotates the viewport multiple times. Then the twistangle goes out of wack. It's like it's accumulating the angles and not resetting. I have seen twistangle values past 900 degrees!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VPROTATEASSOC = 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea why this is happening?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Apr 2015 19:45:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5595803#M40472</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-04-16T19:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: cumlitive TwistAngle problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5599545#M40473</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have seen this behavior before and I do not think the Viewport TwistAngle requires&amp;nbsp;that its angle is between 0 and 360.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It should be possible&amp;nbsp;to bring it to that range if you desire.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if (vp.TwistAngle &amp;gt; 2 * Math.PI)
{
     vp.TwistAngle = Math.Atan2(Math.Sin(vp.TwistAngle), Math.Cos(vp.TwistAngle));
}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Balaji&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2015 11:19:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5599545#M40473</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2015-04-20T11:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: cumlitive TwistAngle problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5599799#M40474</link>
      <description>&lt;P&gt;Thanks Balayi for the suggestion.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm still not getting the correct value returned from TwistAngle. &amp;nbsp;Here is a little more detail on what I am doing.&lt;/P&gt;&lt;P&gt;The goal of my routine is to verify that the North arrow in my drawing in paper space is rotated to the same angle as my viewport.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The North Arrow block points North when it has a 0 degree rotation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I grab both the North Arrow and my viewport and rotate them together. The first time I get perfect results,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;North Block Rotation : 324.184244255124&lt;BR /&gt;ViewportTwist: 324.184244255124&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I rotate agan and get the following;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;North Block Rotation : 293.240839748065&lt;BR /&gt;ViewportTwist: 66.7591602519352&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the above example the if statement you suggest does not get initiated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there something wrong with my logic that I can't use the ViewportTwist in this way? I don't understand where it is coming up with the &lt;SPAN&gt;66.7591602519352&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Coralie&lt;/P&gt;</description>
      <pubDate>Mon, 20 Apr 2015 14:07:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5599799#M40474</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-04-20T14:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: cumlitive TwistAngle problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5600746#M40475</link>
      <description>&lt;P&gt;Sorry, I will need a sample project and the drawing to reproduce the behavior at my end.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please do not share any information that you consider confidential.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Balaji&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2015 05:44:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5600746#M40475</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2015-04-21T05:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: cumlitive TwistAngle problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5620223#M40476</link>
      <description>&lt;P&gt;Sorry it has taken me a long time to reply. Here is the code I'm running, and a sample drawing with the block and viewport.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;' check north arrow&lt;BR /&gt;Dim myDWG As Document = DocumentManager.MdiActiveDocument&lt;BR /&gt;Dim database As Database = HostApplicationServices.WorkingDatabase&lt;BR /&gt;Dim ed As Editor = myDWG.Editor&lt;BR /&gt;Dim BlockRotAng As Double = 0.0 ' rotation angle of North Arrow Block&lt;BR /&gt;Dim UCSAngleDeg As Double = 0.0 ' UCS angle&lt;BR /&gt;Dim NORTHCALC As Double = 0.0&lt;BR /&gt;Dim vptwistInDegrees As Double = 0.0 ' viewport twist in degrees (WCS)&lt;/P&gt;&lt;P&gt;Using myTrans As Transaction = myDWG.TransactionManager.StartTransaction&lt;/P&gt;&lt;P&gt;Dim NORTHID As ObjectId = FindBlock("ntharrow")&lt;BR /&gt;Dim PRJNorth As Boolean = FindTxt("PROJECT NORTH")&lt;BR /&gt;If NORTHID.IsNull = False Then&lt;BR /&gt;If PRJNorth = False Then&lt;BR /&gt;Dim NorthBlkRef As BlockReference = NORTHID.GetObject(OpenMode.ForRead)&lt;BR /&gt;BlockRotAng = NorthBlkRef.Rotation&lt;BR /&gt;' converting Radian to degree&lt;BR /&gt;BlockRotAng = BlockRotAng * (180 / Math.PI)&lt;/P&gt;&lt;P&gt;Dim symTable As SymbolTable = CType(myTrans.GetObject(database.ViewportTableId, OpenMode.ForRead), SymbolTable)&lt;BR /&gt;Dim vpcount As Integer = 0&lt;/P&gt;&lt;P&gt;For Each id As ObjectId In symTable&lt;/P&gt;&lt;P&gt;Dim symbol As ViewportTableRecord = CType(myTrans.GetObject(id, OpenMode.ForRead), ViewportTableRecord)&lt;/P&gt;&lt;P&gt;Dim acadDoc As AcadDocument = Autodesk.AutoCAD.ApplicationServices.DocumentExtension.GetAcadDocument(myDWG)&lt;BR /&gt;acadDoc.MSpace = True&lt;/P&gt;&lt;P&gt;Dim CVport As Viewport = DirectCast(myTrans.GetObject(myDWG.Editor.CurrentViewportObjectId, OpenMode.ForRead), Viewport)&lt;/P&gt;&lt;P&gt;If (CVport.TwistAngle &amp;gt; 2 * Math.PI) Then&lt;BR /&gt;CVport.UpgradeOpen()&lt;BR /&gt;CVport.TwistAngle = Math.Atan2(Math.Sin(CVport.TwistAngle), Math.Cos(CVport.TwistAngle))&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;Dim vptwistInRadians As Double = CVport.TwistAngle&lt;BR /&gt;vptwistInDegrees = Math.Abs((vptwistInRadians * (180 / Math.PI)))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NORTHCALC = BlockRotAng&lt;/P&gt;&lt;P&gt;ed.WriteMessage([String].Format(vbLf &amp;amp; "North Block Rotation : {0}", NORTHCALC.ToString))&lt;BR /&gt;ed.WriteMessage([String].Format(vbLf &amp;amp; "ViewportTwist: {0}", vptwistInDegrees.ToString))&lt;/P&gt;&lt;P&gt;myTrans.Commit()&lt;/P&gt;&lt;P&gt;acadDoc.MSpace = False&lt;BR /&gt;vpcount = vpcount + 1&lt;BR /&gt;Next&lt;/P&gt;&lt;P&gt;If NORTHCALC = 360 Then&lt;BR /&gt;NORTHCALC = 0&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;If vptwistInDegrees = 360 Then&lt;BR /&gt;vptwistInDegrees = 0&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;If vpcount = 1 And UCSAngleDeg &amp;gt; 0 Then&lt;BR /&gt;If (NORTHCALC - UCSAngleDeg) &amp;gt; 1 Or (UCSAngleDeg - NORTHCALC) &amp;gt; 1 Then&lt;BR /&gt;MsgBox("Check the angle of the North Arrow", , "NORTH ARROW ROTATION")&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;If vpcount = 1 And UCSAngleDeg = 0 Then&lt;BR /&gt;If (NORTHCALC - vptwistInDegrees) &amp;gt; 1 Or (vptwistInDegrees - NORTHCALC) &amp;gt; 1 Then&lt;BR /&gt;MsgBox("Check the angle of the North Arrow", , "NORTH ARROW ROTATION")&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;BR /&gt;End Using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2015 17:43:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5620223#M40476</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-04T17:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: cumlitive TwistAngle problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5622394#M40477</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry, I could not reproduce the problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a recording of what i am trying using AutoCAD 2015.&lt;/P&gt;
&lt;P&gt;In the recording you can also find two other methods - one to set the viewport twist and the other to print the viewport twist value&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://autode.sk/1zLGM6w" target="_blank"&gt;http://autode.sk/1zLGM6w&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if there is any additional&amp;nbsp;step to reproduce the behavior.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Balaji&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2015 06:51:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5622394#M40477</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2015-05-06T06:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: cumlitive TwistAngle problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5624260#M40478</link>
      <description>&lt;P&gt;Thanks so much Balaji!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That was great, and definately the more "normal" way to rotate the view. My user's however, sometimes use the &amp;nbsp;basic "rotate" command from paperspace and rotate the viewport object with the North Arrow block at the same time to get the view they want. Then use the grips of the viewport to change it's shape back to a rectangle to fit the page. This option came out with 2010 if I recall, and my user's take advantage of it in some situations. That's when the code fails after a couple of rotates. Hope that makes sense. We only deal in 2D so this option works for them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rotate the first time say ~45 degrees, then another ~45, then another ~-30, etc. the viewtwist angle will be correct for the first couple, then goes off.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope you can reproduce the error that way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks again for your help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cj&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2015 12:44:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5624260#M40478</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-07T12:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: cumlitive TwistAngle problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5625840#M40479</link>
      <description>&lt;P&gt;Hi CJ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please record the steps ? &amp;nbsp;&lt;SPAN style="line-height: 15px;"&gt;I still cannot reproduce the behavior.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only time i find a mismatch is when i skip or forget&amp;nbsp;to select the North block while rotating.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a recording :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://autode.sk/1Kn82sa" target="_blank"&gt;http://autode.sk/1Kn82sa&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Balaji&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2015 21:02:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5625840#M40479</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2015-05-07T21:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: cumlitive TwistAngle problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5626739#M40480</link>
      <description>&lt;P&gt;I tried using Screencast for the first time...pretty cool.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the recording, I rotate the viewport the first time, everything ok, after the second rotation, the values are different.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;A target="_blank" href="http://autode.sk/1KpXYhU"&gt;http://autode.sk/1KpXYhU&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much&amp;nbsp;for your continued effort!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cj&lt;/P&gt;</description>
      <pubDate>Fri, 08 May 2015 13:15:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5626739#M40480</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-08T13:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: cumlitive TwistAngle problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5630762#M40481</link>
      <description>&lt;P&gt;Thanks for recording a video.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did reproduce the behavior at my end.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems the ViewTwist is including multiples of 360 when rotated in clockwise and counter clockwise directions.&lt;/P&gt;
&lt;P&gt;Although it does not affect the actual viewport twist as any angle when rotated 360 degrees in either direction should not affect its numerical value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But in your code it does affect as you require comparison with the block reference's rotation value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A way to workaround it would be to handle it as in this code :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    &amp;lt;CommandMethod("Test1")&amp;gt; _
    Public Sub Test1Method()
        ' check north arrow
        Dim myDWG As Document = Application.DocumentManager.MdiActiveDocument
        Dim database As Database = HostApplicationServices.WorkingDatabase
        Dim ed As Editor = myDWG.Editor
        Dim BlockRotAng As Double = 0.0 ' rotation angle of North Arrow Block
        Dim UCSAngleDeg As Double = 0.0 ' UCS angle
        Dim NORTHCALC As Double = 0.0
        Dim vptwistInDegrees As Double = 0.0 ' viewport twist in degrees (WCS)
        Using myTrans As Transaction = myDWG.TransactionManager.StartTransaction
            Dim bt As BlockTable = CType(myTrans.GetObject(database.BlockTableId, OpenMode.ForRead), BlockTable)
            Dim btr As BlockTableRecord = CType(myTrans.GetObject(bt("ntharrow"), OpenMode.ForRead), BlockTableRecord)
            Dim objIdColl As ObjectIdCollection = btr.GetBlockReferenceIds(True, True)
            Dim NORTHID As ObjectId = objIdColl(0)
            If NORTHID.IsNull = False Then
                Dim NorthBlkRef As BlockReference = NORTHID.GetObject(OpenMode.ForRead)
                BlockRotAng = NorthBlkRef.Rotation
                ' converting Radian to degree
                BlockRotAng = BlockRotAng * (180 / Math.PI)
                Dim symTable As SymbolTable = CType(myTrans.GetObject(database.ViewportTableId, OpenMode.ForRead), SymbolTable)
                Dim vpcount As Integer = 0
                For Each id As ObjectId In symTable
                    Dim symbol As ViewportTableRecord = CType(myTrans.GetObject(id, OpenMode.ForRead), ViewportTableRecord)
                    Dim acadDoc As AcadDocument = Autodesk.AutoCAD.ApplicationServices.DocumentExtension.GetAcadDocument(myDWG)
                    acadDoc.MSpace = True
                    Dim CVport As Autodesk.AutoCAD.DatabaseServices.Viewport = DirectCast(myTrans.GetObject(myDWG.Editor.CurrentViewportObjectId, OpenMode.ForRead), Autodesk.AutoCAD.DatabaseServices.Viewport)
                    'If (CVport.TwistAngle &amp;gt; 2 * Math.PI) Then
                    '    CVport.UpgradeOpen()
                    '    CVport.TwistAngle = Math.Atan2(Math.Sin(CVport.TwistAngle), Math.Cos(CVport.TwistAngle))
                    'End If
                    Dim vptwistInRadians As Double = CVport.TwistAngle
                    vptwistInDegrees = Math.Abs((vptwistInRadians * (180 / Math.PI)))

                    NORTHCALC = BlockRotAng
                    ed.WriteMessage([String].Format(vbLf &amp;amp; "North Block Rotation : {0}", NORTHCALC.ToString))
                    ed.WriteMessage([String].Format(vbLf &amp;amp; "ViewportTwist: {0}", vptwistInDegrees.ToString))
                    myTrans.Commit()
                    acadDoc.MSpace = False
                    vpcount = vpcount + 1
                Next
                'If NORTHCALC = 360 Then
                '    NORTHCALC = 0
                'End If
                'If vptwistInDegrees = 360 Then
                '    vptwistInDegrees = 0
                'End If

                If vptwistInDegrees &amp;gt;= 360 Then
                    Dim fullCircles As System.Int32
                    fullCircles = CType(Math.Floor(vptwistInDegrees / 360), Integer)
                    vptwistInDegrees = vptwistInDegrees - 360 * fullCircles
                End If

                If vpcount = 1 And UCSAngleDeg &amp;gt; 0 Then
                    If (NORTHCALC - UCSAngleDeg) &amp;gt; 1 Or (UCSAngleDeg - NORTHCALC) &amp;gt; 1 Then
                        MsgBox("Check the angle of the North Arrow", , "NORTH ARROW ROTATION")
                    End If
                End If
                If vpcount = 1 And UCSAngleDeg = 0 Then
                    If (NORTHCALC - vptwistInDegrees) &amp;gt; 1 Or (vptwistInDegrees - NORTHCALC) &amp;gt; 1 Then
                        MsgBox("Check the angle of the North Arrow", , "NORTH ARROW ROTATION")
                    End If
                End If
            End If
        End Using
    End Sub&lt;/PRE&gt;
&lt;P&gt;Hope this helps&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Balaji&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2015 08:46:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5630762#M40481</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2015-05-12T08:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: cumlitive TwistAngle problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5632797#M40482</link>
      <description>&lt;P&gt;Thanks so much Balaji.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I quickly tried your code, but it is failing on&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Dim NORTHID As ObjectId = objIdColl(0)&lt;/PRE&gt;&lt;P&gt;I gen an unhandled exception.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will need to take some time to look into that. I'm a part time programmer and have gotten tied up with some other work. Hopefully next week I will get a chance to determine why the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks again&lt;/P&gt;&lt;P&gt;cj&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2015 12:28:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5632797#M40482</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-13T12:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: cumlitive TwistAngle problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5633452#M40483</link>
      <description>&lt;P&gt;Hi CJ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not a problem, please feel free to update when you get a chance to work on it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The line that is giving an error is a replacement for "FindBlock" that you had in your original code.&lt;/P&gt;
&lt;P&gt;Since during my tests north arrow was the only blockreference in the drawing, i simply got hold of it without the "FindBlock".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please feel free to use your original code to find the NORTHID instead of that line.&lt;/P&gt;
&lt;P&gt;i.e., Dim NORTHID As ObjectId = FindBlock("ntharrow")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Balaji&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2015 17:19:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5633452#M40483</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2015-05-13T17:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: cumlitive TwistAngle problem</title>
      <link>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5637125#M40484</link>
      <description>&lt;P&gt;Got it to work! Thanks Balaji!&lt;/P&gt;&lt;P&gt;To cover both scenerio's if the user rotates both the viewport and the north arrow together, the code worked great, BUT if they did it the "traditional" way of rotating within the viewport, the routine did not show the correct North Arrow rotation due to the counterclockwise measurement, so I added the following if the original value of the north arrow does not match, then adjust it and try the match again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;' check for match, if not adjust North angle based on counterclockwise measurement&lt;BR /&gt;Dim angledif As Single = NORTHCALC - vptwistInDegrees&lt;/P&gt;&lt;P&gt;If angledif &amp;gt; 1 Then&lt;BR /&gt;If NORTHCALC &amp;gt; 180 Then&lt;BR /&gt;NORTHCALC = 360 - NORTHCALC&lt;BR /&gt;Else&lt;BR /&gt;NORTHCALC = NORTHCALC + 180&lt;BR /&gt;End If&lt;BR /&gt;End If&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 16:51:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/cumlitive-twistangle-problem/m-p/5637125#M40484</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-15T16:51:00Z</dc:date>
    </item>
  </channel>
</rss>

