Set view paralell to plane in viewports in layout

unhandled
#1

Hi all,
I created a Layout with 4 viewports and now I want to focus each viewport to another object.I tried it with detail.Viewport.SetCameraTarget(planes[i].Origin, true); but without success.


My code is as follows:

private void RunScript(bool run, List<Point3d> w2, List<Point3d> h2, List<Plane> planes, ref object A, ref object B)
  {
    if (run)
    {
      //set units
      doc.PageUnitSystem = Rhino.UnitSystem.Millimeters;
      //existing layouts
      var page_views = doc.Views.GetPageViews();
      //how many layouts do already exist?
      int page_number = (page_views == null) ? 1 : page_views.Length + 1;
      //create new layout
      var pageview = doc.Views.AddPageView(string.Format("A0_{0}", page_number), 1189, 841);
      for (int i = 0; i < planes.Count ; i++)
      {
        //add detail to layout
        if( pageview != null )
        {
          var detail = pageview.AddDetailView("ModelView", new Point2d(w2[i].X, w2[i].Y), new Point2d(h2[i].X, h2[i].Y), Rhino.Display.DefinedViewportProjection.Perspective);

          if (detail != null)
          {
            pageview.SetActiveDetail(detail.Id);
            detail.Viewport.SetCameraTarget(planes[i].Origin, true);
            detail.DetailGeometry.IsProjectionLocked = true;
            detail.DetailGeometry.SetScale(1, doc.ModelUnitSystem, 10, doc.PageUnitSystem);
            // Commit changes tells the document to replace the document's detail object
            // with the modified one that we just adjusted
            detail.CommitChanges();
          }
        }        
      }

      pageview.SetPageAsActive();
      doc.Views.ActiveView = pageview;
      doc.Views.Redraw();
    }
  }

The file:20190309_MakeLayout.gh (9.0 KB)

Thanks for every hint!

Baris

0 Likes

#2

Hi,
I am sorry for bumping this, but I am struggling already a while.
I am still trying, got a bit closer but still the view isnt paralell to the plane.
Does anybody know how to fix this?

The file:
20190311_MakeLayout.gh (10.9 KB)

0 Likes