Beispiel #1
0
        /// <summary>
        /// Matches View3D's orientation and cropbox to an orthagonal view.  Also sets the View3D to isometric.
        /// </summary>
        /// <param name="View3D">The 3D view to change orientation and crop</param>
        /// <param name="SourceView">The source orthogonal view to acquire orientation and cropbox</param>
        /// <param name="Offset">Offset of the camera from the view direction of the source view</param>
        /// <returns name="View3D"></returns>
        public static DynaView3D View3dOrientToggleIsometric(DynaView3D View3D, DynaView SourceView, double Offset)
        {
            string transactionName = "View3dOrientToggleIsometric";

            RevitView3D rView       = (RevitView3D)View3D.InternalElement;
            RevitView   rSourceView = (RevitView)SourceView.InternalElement;

            RevitDoc document = rView.Document;

            // Cropbox
            RevitBB  cropbox = rSourceView.CropBox;
            RevitXYZ origin  = cropbox.Transform.Origin;

            // View Orientation
            RevitXYZ rEyePosition      = origin.Add(rSourceView.ViewDirection.Normalize().Multiply(Offset));
            RevitXYZ rUpDirection      = rSourceView.UpDirection;
            RevitXYZ rForwardDirection = rSourceView.ViewDirection.Negate();

            RevitViewOrientation viewOrient = new RevitViewOrientation(rEyePosition, rUpDirection, rForwardDirection);

            Action <RevitView3D, RevitViewOrientation, RevitBB> orientView = (view, orient, cropbb) =>
            {
                view.ToggleToIsometric();
                view.SetOrientation(orient);
                view.CropBox = cropbb;
            };

            if (document.IsModifiable)
            {
                TransactionManager.Instance.EnsureInTransaction(document);
                orientView(rView, viewOrient, cropbox);
                TransactionManager.Instance.TransactionTaskDone();
            }
            else
            {
                using (Autodesk.Revit.DB.Transaction trans = new Autodesk.Revit.DB.Transaction(document))
                {
                    trans.Start(transactionName);
                    orientView(rView, viewOrient, cropbox);
                    trans.Commit();
                }
            }
            return(View3D);
        }
Beispiel #2
0
        /// <summary>
        /// Add edge to the loft form
        /// </summary>
        /// <param name="form">The loft form to be added edge</param>
        /// <returns>Reference of the added edge</returns>
        private Reference AddEdge(Form form)
        {
            // Get two specific edges from the form
            Autodesk.Revit.DB.XYZ startOfTop = new Autodesk.Revit.DB.XYZ(-1 * m_topLength / 2, -1 * m_topWidth / 2, m_topHeight);
            Autodesk.Revit.DB.XYZ endOfTop   = new Autodesk.Revit.DB.XYZ(m_topLength / 2, -1 * m_topWidth / 2, m_topHeight);
            Edge topEdge = GetEdgeByEndPoints(form, startOfTop, endOfTop);

            Autodesk.Revit.DB.XYZ startOfBottom = new Autodesk.Revit.DB.XYZ(-1 * (m_bottomLength / 2 + m_vertexOffsetOnBottomProfile), -1 * (m_bottomWidth / 2 + m_vertexOffsetOnBottomProfile), m_bottomHeight);
            Autodesk.Revit.DB.XYZ endOfBottom   = new Autodesk.Revit.DB.XYZ((m_bottomLength / 2 + m_vertexOffsetOnBottomProfile), -1 * (m_bottomWidth / 2 + m_vertexOffsetOnBottomProfile), m_bottomHeight);
            Edge bottomEdge = GetEdgeByEndPoints(form, startOfBottom, endOfBottom);

            // Add an edge between the two edges with specific parameters
            double topParam    = 0.5;
            double bottomParam = 0.5;

            form.AddEdge(topEdge.Reference, topParam, bottomEdge.Reference, bottomParam);
            m_revitDoc.Regenerate();

            // Get the added edge and return its reference
            Autodesk.Revit.DB.XYZ startOfAddedEdge = startOfTop.Add(endOfTop.Subtract(startOfTop).Multiply(topParam));
            Autodesk.Revit.DB.XYZ endOfAddedEdge   = startOfBottom.Add(endOfBottom.Subtract(startOfBottom).Multiply(bottomParam));
            return(GetEdgeByEndPoints(form, startOfAddedEdge, endOfAddedEdge).Reference);
        }
Beispiel #3
0
        /// <summary>
        /// Add edge to the loft form
        /// </summary>
        /// <param name="form">The loft form to be added edge</param>
        /// <returns>Reference of the added edge</returns>
        private Reference AddEdge(Form form)
        {
            // Get two specific edges from the form
             Autodesk.Revit.DB.XYZ startOfTop = new Autodesk.Revit.DB.XYZ (-1 * m_topLength / 2, -1 * m_topWidth / 2, m_topHeight);
             Autodesk.Revit.DB.XYZ endOfTop = new Autodesk.Revit.DB.XYZ (m_topLength / 2, -1 * m_topWidth / 2, m_topHeight);
             Edge topEdge = GetEdgeByEndPoints(form, startOfTop, endOfTop);
             Autodesk.Revit.DB.XYZ startOfBottom = new Autodesk.Revit.DB.XYZ (-1 * (m_bottomLength / 2 + m_vertexOffsetOnBottomProfile), -1 * (m_bottomWidth / 2 + m_vertexOffsetOnBottomProfile), m_bottomHeight);
             Autodesk.Revit.DB.XYZ endOfBottom = new Autodesk.Revit.DB.XYZ ((m_bottomLength / 2 + m_vertexOffsetOnBottomProfile), -1 * (m_bottomWidth / 2 + m_vertexOffsetOnBottomProfile), m_bottomHeight);
             Edge bottomEdge = GetEdgeByEndPoints(form, startOfBottom, endOfBottom);

             // Add an edge between the two edges with specific parameters
             double topParam = 0.5;
             double bottomParam = 0.5;
             form.AddEdge(topEdge.Reference, topParam, bottomEdge.Reference, bottomParam);
             m_revitDoc.Regenerate();

             // Get the added edge and return its reference
             Autodesk.Revit.DB.XYZ startOfAddedEdge = startOfTop.Add(endOfTop.Subtract(startOfTop).Multiply(topParam));
             Autodesk.Revit.DB.XYZ endOfAddedEdge = startOfBottom.Add(endOfBottom.Subtract(startOfBottom).Multiply(bottomParam));
             return GetEdgeByEndPoints(form, startOfAddedEdge, endOfAddedEdge).Reference;
        }