<?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: View Frame Rotation (C3D .NET API) in Civil 3D Customization Forum</title>
    <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/view-frame-rotation-c3d-net-api/m-p/5428770#M16363</link>
    <description>&lt;P&gt;Thank you, this will work for my current problem.&lt;/P&gt;</description>
    <pubDate>Mon, 01 Dec 2014 13:32:35 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-12-01T13:32:35Z</dc:date>
    <item>
      <title>View Frame Rotation (C3D .NET API)</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/view-frame-rotation-c3d-net-api/m-p/5424572#M16359</link>
      <description>&lt;P&gt;I am trying to get the rotation of each view frame in a group. &amp;nbsp;I can't find any "rotation" or "transform" properties that are exposed in the ViewFrame class. &amp;nbsp;Is there any way that I can do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I am using to get information about the viewframes. &amp;nbsp;I also included the test files I am using.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[CommandMethod("ListViewFrames")]
        public void listVFrames()
        {
            CivilDocument cdoc = CivilApplication.ActiveDocument;
            
            // Get editor for command line output
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            // Document Database
            Database acDB = doc.Database;


            ObjectIdCollection FGGIDs = cdoc.GetViewFrameGroupIds();

            ed.WriteMessage("Object Class: " + FGGIDs[0].ObjectClass.DxfName + " ::: ");

            using (Transaction trans = acDB.TransactionManager.StartTransaction())
            {
                ViewFrameGroup vfg = trans.GetObject(FGGIDs[0], OpenMode.ForRead) as ViewFrameGroup;
                ObjectIdCollection vFrameIDs = vfg.GetViewFrameIds();

                ed.WriteMessage("\nFrame Count: " + vFrameIDs.Count);

                foreach (ObjectId vfID in vFrameIDs)
                {
                    ViewFrame vf = trans.GetObject(vfID, OpenMode.ForWrite) as ViewFrame;
                    
                    ed.WriteMessage("\nName: " + vf.Name + " Display Name: " + vf.DisplayName);
                }
            }
            
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Nov 2014 22:32:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/view-frame-rotation-c3d-net-api/m-p/5424572#M16359</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-25T22:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: View Frame Rotation (C3D .NET API)</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/view-frame-rotation-c3d-net-api/m-p/5426136#M16360</link>
      <description>&lt;P&gt;I'd explode the view frames and then examine the long line in the collected exploded items to figure out the rotation. I'd do this outside of transaction that was committed to not affect the one in the drawing.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Nov 2014 04:22:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/view-frame-rotation-c3d-net-api/m-p/5426136#M16360</guid>
      <dc:creator>Civil3DReminders_com</dc:creator>
      <dc:date>2014-11-27T04:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: View Frame Rotation (C3D .NET API)</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/view-frame-rotation-c3d-net-api/m-p/5426815#M16361</link>
      <description>&lt;P&gt;As Chris mentioned, something like this should work. It is very simplistic and is only guaranteed to work for the sample drawing provided. You will want to make it more robust (creating a new style for the viewframes so you know exactly what objects will be created, checking the type of each of the object you are exploding, exiting out of the loops once you find the correct line, etc). Since you weren't commiting the transaction anyway, I didn't bother starting a second transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[CommandMethod( "ListViewFrames" )]
public void listVFrames()
{
  var cdoc = CivilApplication.ActiveDocument;
  var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
  var ed = doc.Editor;
  var acDB = doc.Database;

  var FGGIDs = cdoc.GetViewFrameGroupIds();

  ed.WriteMessage( "Object Class: {0} ::: ", FGGIDs[0].ObjectClass.DxfName );

  using ( var trans = acDB.TransactionManager.StartTransaction() )
  {
    var vfg = trans.GetObject( FGGIDs[0], OpenMode.ForRead ) as ViewFrameGroup;
    var vFrameIDs = vfg.GetViewFrameIds();

    ed.WriteMessage( "{0}Frame Count: {1}", System.Environment.NewLine, vFrameIDs.Count );

    foreach ( ObjectId vfID in vFrameIDs )
    {
      var vf = (ViewFrame)trans.GetObject( vfID, OpenMode.ForWrite );
      var expSet = new DBObjectCollection();
      vf.Explode( expSet ); // explode to block
      var rot = double.NaN;
      foreach ( Entity ent in expSet )
      {
        var expSet1 = new DBObjectCollection();
        ent.Explode( expSet1 ); // explode to polyline
        foreach ( Entity ent1 in expSet1 )
        {
          var expSet2 = new DBObjectCollection();
          ent1.Explode( expSet2 ); // explode to lines
          foreach ( Entity ent2 in expSet2 )
          {
            if ( typeof( Line ) == ent2.GetType() )
            {
              var l = (Line)ent2; // the first line is the top line of frame drawn left to right
              rot = l.Angle;
              break; // break after the first line
            }
          }
        }
      }
      ed.WriteMessage( "{0}Name: {1} Display Name: {2} Rotation: {3}", System.Environment.NewLine, vf.Name, vf.DisplayName, rot.ToString( "F6" ) );
    }
  }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Nov 2014 18:27:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/view-frame-rotation-c3d-net-api/m-p/5426815#M16361</guid>
      <dc:creator>tyronebk</dc:creator>
      <dc:date>2014-11-27T18:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: View Frame Rotation (C3D .NET API)</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/view-frame-rotation-c3d-net-api/m-p/5427700#M16362</link>
      <description>&lt;P&gt;good snippet code.&lt;/P&gt;&lt;P&gt;I´m doing my own command for Civil 3D 2015:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;A target="_blank" href="http://www.mediafire.com/download/aq9gbtwwfenzixg/PaginasEje_C3D+2015.dll"&gt;http://www.mediafire.com/download/aq9gbtwwfenzixg/PaginasEje_C3D+2015.dll&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;command: paginasEje.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 16px; line-height: 12.8000001907349px;"&gt;But it has different criteria. However, I understood criteria of Civil 3D to create viewframes and perhaps I will include it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Nov 2014 22:47:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/view-frame-rotation-c3d-net-api/m-p/5427700#M16362</guid>
      <dc:creator>joantopo</dc:creator>
      <dc:date>2014-11-28T22:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: View Frame Rotation (C3D .NET API)</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/view-frame-rotation-c3d-net-api/m-p/5428770#M16363</link>
      <description>&lt;P&gt;Thank you, this will work for my current problem.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Dec 2014 13:32:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/view-frame-rotation-c3d-net-api/m-p/5428770#M16363</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-12-01T13:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: View Frame Rotation (C3D .NET API)</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/view-frame-rotation-c3d-net-api/m-p/10055711#M16364</link>
      <description>&lt;P&gt;I tried this using Civil 3D 2020. &amp;nbsp;When I explode the view frame object, it results in a line that follows the z axis and is nowhere near the original view frame. &amp;nbsp;However, when using the explode command, I get expected results. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is your code working as expected in more recent versions of Civil 3D?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 00:46:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/view-frame-rotation-c3d-net-api/m-p/10055711#M16364</guid>
      <dc:creator>keith_sowinski</dc:creator>
      <dc:date>2021-02-04T00:46:20Z</dc:date>
    </item>
  </channel>
</rss>

