<?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 Re: How to get current view [Top, Front, Left,Right...] orientation using C# in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-get-current-view-top-front-left-right-orientation-using-c/m-p/12233509#M25890</link>
    <description>&lt;P&gt;Could you explain more about&amp;nbsp; sqrt033? How is about value for edge views or other angles view? Thanks for your helps&lt;/P&gt;</description>
    <pubDate>Tue, 12 Sep 2023 02:35:32 GMT</pubDate>
    <dc:creator>ditran7577</dc:creator>
    <dc:date>2023-09-12T02:35:32Z</dc:date>
    <item>
      <title>How to get current view [Top, Front, Left,Right...] orientation using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-get-current-view-top-front-left-right-orientation-using-c/m-p/8013158#M25885</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can help any one how to get the orientation [Top, Front, Left, Right...] from Model space only ?.&lt;/P&gt;&lt;P&gt;Please, note that the model space&amp;nbsp;divided/split grater than two view [snap attached].&lt;/P&gt;&lt;P&gt;Need to get current view orientation as respective of cursor position...&lt;/P&gt;&lt;P&gt;Thanks in advance..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 19 May 2018 11:32:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-get-current-view-top-front-left-right-orientation-using-c/m-p/8013158#M25885</guid>
      <dc:creator>kite15</dc:creator>
      <dc:date>2018-05-19T11:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to get current view [Top, Front, Left,Right...] orientation using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-get-current-view-top-front-left-right-orientation-using-c/m-p/8013263#M25886</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can check the ViewDirection property of the active model space viewport view (ViewTableRecord).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        [CommandMethod("CMD", CommandFlags.NoPaperSpace)]
        public void Cmd()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;
            using (var view = ed.GetCurrentView())
            {
                ed.WriteMessage($"\nCurrent View: {GetViewName(view.ViewDirection)}");
            }
        }

        private string GetViewName(Vector3d viewDirection)
        {
            double sqrt033 = Math.Sqrt(1.0 / 3.0);
            switch (viewDirection.GetNormal())
            {
                case Vector3d v when v.IsEqualTo( Vector3d.ZAxis): return "Top";
                case Vector3d v when v.IsEqualTo(Vector3d.ZAxis.Negate()): return "Bottom";
                case Vector3d v when v.IsEqualTo(Vector3d.XAxis): return "Right";
                case Vector3d v when v.IsEqualTo(Vector3d.XAxis.Negate()): return "Left";
                case Vector3d v when v.IsEqualTo(Vector3d.YAxis): return "Back";
                case Vector3d v when v.IsEqualTo(Vector3d.YAxis.Negate()): return "Front";
                case Vector3d v when v.IsEqualTo(new Vector3d(sqrt033, sqrt033, sqrt033)): return "NE Isometric";
                case Vector3d v when v.IsEqualTo(new Vector3d(-sqrt033, sqrt033, sqrt033)): return "NW Isometric";
                case Vector3d v when v.IsEqualTo(new Vector3d(-sqrt033, -sqrt033, sqrt033)): return "SW Isometric";
                case Vector3d v when v.IsEqualTo(new Vector3d(sqrt033, -sqrt033, sqrt033)): return "SE Isometric";
                default: return $"Custom View";
            }
        }&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 May 2018 14:10:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-get-current-view-top-front-left-right-orientation-using-c/m-p/8013263#M25886</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-05-19T14:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to get current view [Top, Front, Left,Right...] orientation using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-get-current-view-top-front-left-right-orientation-using-c/m-p/8019862#M25887</link>
      <description>&lt;P&gt;Hi _gile,&lt;/P&gt;&lt;P&gt;The code shown some error (attached snap).&lt;/P&gt;&lt;P&gt;Whereas, I have modified the code from switch, case to if, else.. and get the asking result.&lt;/P&gt;&lt;P&gt;Although, the switch, case way is great apart from performance. Please, comment on this&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;PRE&gt;        [CommandMethod("CMD", CommandFlags.NoPaperSpace)]
        public void GetCurrentViewName()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;
            using (var view = ed.GetCurrentView())
            {               
                Vector3d viewDirection = ed.GetCurrentView().ViewDirection;
                if (viewDirection.IsEqualTo(Vector3d.ZAxis))
                {
                    ed.WriteMessage("\nTop");
                }
                else if (viewDirection.IsEqualTo(Vector3d.XAxis))
                {
                    ed.WriteMessage("\nRight");
                }
                else if (viewDirection.IsEqualTo(Vector3d.XAxis.Negate()))
                {
                    ed.WriteMessage("\nLeft");
                }
                else if (viewDirection.IsEqualTo(Vector3d.YAxis.Negate()))
                {
                    ed.WriteMessage("\nFront");
                }
                else
                {
                    ed.WriteMessage("\nCustom View");
                }
            }
        }&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 May 2018 04:29:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-get-current-view-top-front-left-right-orientation-using-c/m-p/8019862#M25887</guid>
      <dc:creator>kite15</dc:creator>
      <dc:date>2018-05-23T04:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to get current view [Top, Front, Left,Right...] orientation using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-get-current-view-top-front-left-right-orientation-using-c/m-p/8019968#M25888</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code I posted uses &lt;A href="https://docs.microsoft.com/en-us/dotnet/csharp/pattern-matching" target="_blank"&gt;pattern matching&lt;/A&gt;, one of the C# 7 (Visual Studio 2017) new features.&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 05:50:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-get-current-view-top-front-left-right-orientation-using-c/m-p/8019968#M25888</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-05-23T05:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to get current view [Top, Front, Left,Right...] orientation using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-get-current-view-top-front-left-right-orientation-using-c/m-p/8019984#M25889</link>
      <description>&lt;P&gt;Actually, I am using&amp;nbsp;&lt;SPAN&gt;Visual Studio 2013. So, this is the reason.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you...&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 06:01:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-get-current-view-top-front-left-right-orientation-using-c/m-p/8019984#M25889</guid>
      <dc:creator>kite15</dc:creator>
      <dc:date>2018-05-23T06:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to get current view [Top, Front, Left,Right...] orientation using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-get-current-view-top-front-left-right-orientation-using-c/m-p/12233509#M25890</link>
      <description>&lt;P&gt;Could you explain more about&amp;nbsp; sqrt033? How is about value for edge views or other angles view? Thanks for your helps&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 02:35:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-get-current-view-top-front-left-right-orientation-using-c/m-p/12233509#M25890</guid>
      <dc:creator>ditran7577</dc:creator>
      <dc:date>2023-09-12T02:35:32Z</dc:date>
    </item>
  </channel>
</rss>

