Author Topic: Creating a orthogonal named views around an object  (Read 1343 times)

0 Members and 1 Guest are viewing this topic.

Keith Brown

  • Swamp Rat
  • Posts: 601
Creating a orthogonal named views around an object
« on: May 02, 2015, 09:14:08 AM »
I am tasked with automatically creating named orthogonal named views around an object.  So far I have successfully created a "3-dimensional box" around the object which is really just 6 rectangular 3d polylines.  I am then creating the named views by supplying the view 2 of the points of the polyline.  A lower left point and a upper right point.  (both points defined in current ucs) So far the only  view that is working correctly is the top view which makes sense because i have not done any ucs transformations.  The question that I have is that before i create any of the other views do i need to change my ucs to that view direction and then transform my points that define that view into the current ucs?  I am a little bit confused about how to create a view programmatically that is perpendicular to the current space.


I am following the article found at this location [size=78%]http://adndevblog.typepad.com/autocad/2013/03/settingcreating-a-named-view-with-associated-ucs.html[/size] but i find that they do not do a good job of explaining what they are doing or why they are doing something.  They just throw the code at you. 
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: Creating a orthogonal named views around an object
« Reply #1 on: May 02, 2015, 10:40:25 AM »
I should have asked the duck.  All i needed to do was transform the points that I was passing to the CreateView method to the normal ucs of the view direction.  Something like this.

Code - C#: [Select]
  1. var rightPolyline = CreateRectangle3D(frontRightBottom, backRightBottom, backRightTop, frontRightTop, transaction, database);
  2. var rightView = CreateView(rightPolyline.GetPointAtParameter(0).TransformBy(Matrix3d.WorldToPlane(rightDirection)), rightPolyline.GetPointAtParameter(2).TransformBy(Matrix3d.WorldToPlane(rightDirection)));
  3. rightView.ViewDirection = rightDirection;
  4. rightView.Name = string.Format("{0}-Right", entity.Handle);
  5. rightView.SetUcsToWorld();
  6. rightView.SetViewDirection(OrthographicView.RightView);
  7. viewTable.Add(rightView);
  8. transaction.AddNewlyCreatedDBObject(rightView, true);
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013