Exemple #1
0
        private void makeBayView(File3dm file, StructuralBay bay)
        {
            //File3dm file = setupFile();
            RhinoViewport viewport = new RhinoViewport();

            //shift to mid point of module
            Point3d origin = new Point3d(bay.minPlane.Origin);
            Plane   plnA   = new Plane(origin + bay.minPlane.YAxis * bay.parameters.yCell / 2, bay.minPlane.XAxis, Vector3d.ZAxis);
            //shift to end of module
            Plane plnB = new Plane(origin + bay.minPlane.YAxis * bay.parameters.yCell, bay.minPlane.XAxis, Vector3d.ZAxis);

            plnA.Flip();


            viewport.SetProjection(DefinedViewportProjection.Perspective, "bay_" + bay.baynum.ToString() + "section", false);

            viewport.ChangeToParallelProjection(true);

            //set camera and target
            Vector3d shiftTarget = bay.maxPlane.Origin - bay.minPlane.Origin;

            viewport.SetCameraTarget(bay.minPlane.Origin + shiftTarget / 2, false);
            viewport.SetCameraLocation(viewport.CameraTarget + bay.minPlane.YAxis * -50000, false);
            viewport.SetCameraDirection(viewport.CameraTarget - viewport.CameraTarget, false);
            viewport.CameraUp = Vector3d.ZAxis;
            //viewport.ZoomExtents();
            viewport.PushViewProjection();
            file.AllViews.Add(new ViewInfo(viewport));

            //Clip plane A
            file.Objects.AddClippingPlane(plnA, bay.parameters.width, bay.parameters.height, viewport.Id);
            //Clip plane B
            file.Objects.AddClippingPlane(plnB, bay.parameters.width, bay.parameters.height, viewport.Id);
        }
Exemple #2
0
        public string ViewToNative(View3D view)
        {
            Rhino.RhinoApp.InvokeOnUiThread((Action) delegate {
                RhinoView _view        = Doc.Views.ActiveView;
                RhinoViewport viewport = _view.ActiveViewport;
                viewport.SetProjection(DefinedViewportProjection.Perspective, null, false);
                var origin  = PointToNative(view.origin).Location;
                var forward = new Vector3d(view.forwardDirection.x, view.forwardDirection.y, view.forwardDirection.z);

                if (view.target != null)
                {
                    viewport.SetCameraLocations(PointToNative(view.target).Location, origin); // this changes viewport.CameraUp. works for axon from revit if after, for perspective from revit if before
                }
                else
                {
                    viewport.SetCameraLocation(origin, true);
                    viewport.SetCameraDirection(forward, true);
                }
                viewport.CameraUp = new Vector3d(view.upDirection.x, view.upDirection.y, view.upDirection.z);

                viewport.Name = view.name;

                /* TODO: debug this and see if it helps better match views from revit
                 * // set bounding box
                 * var box = BoxToNative(view.boundingBox);
                 * BoundingBox boundingBox = new BoundingBox(box.X.Min, box.Y.Min, box.Z.Min, box.X.Max, box.Y.Max, box.Z.Max);
                 * viewport.SetClippingPlanes(boundingBox);
                 */

                // set rhino view props if available
                SetViewParams(viewport, view);

                if (view.isOrthogonal)
                {
                    viewport.ChangeToParallelProjection(true);
                }

                var commitInfo = GetCommitInfo();
                var viewName   = $"{commitInfo } - {view.name}";

                Doc.NamedViews.Add(viewName, viewport.Id);
            });

            //ConversionErrors.Add(sdfasdfaf);

            return("baked");
        }