Example #1
0
        /// <summary>
        /// Move existing point by offset
        /// </summary>
        public void MovePoint(Pt point, double offset)
        {
            if (this.InternalRoof.SlabShapeEditor == null)
            {
                throw new Exception(Properties.Resources.InvalidShapeEditor);
            }

            SlabShapeVertex vertex = null;

            foreach (SlabShapeVertex v in this.InternalRoof.SlabShapeEditor.SlabShapeVertices)
            {
                if (point.IsAlmostEqualTo(v.Position.ToPoint()))
                {
                    vertex = v;
                }
            }

            if (vertex != null && offset != 0)
            {
                TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument);
                this.InternalRoof.SlabShapeEditor.Enable();
                this.InternalRoof.SlabShapeEditor.ModifySubElement(vertex, offset);
                TransactionManager.Instance.TransactionTaskDone();
            }
        }
Example #2
0
        Stream(ArrayList data, SlabShapeVertex slabVertex)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(SlabShapeVertex)));

            data.Add(new Snoop.Data.Xyz("Position", slabVertex.Position));
            data.Add(new Snoop.Data.String("Vertex type", slabVertex.VertexType.ToString()));
        }
Example #3
0
        /// <summary>
        /// Add Crease on specific location
        /// </summary>
        /// <param name="point1">first point of location where Crease add on</param>
        /// <param name="point2">second point of location where Crease add on</param>
        /// <returns>new created Crease</returns>
        public SlabShapeCrease AddCrease(PointF point1, PointF point2)
        {
            //create first vertex
            Transaction transaction = new Transaction(
                m_commandData.Application.ActiveUIDocument.Document, "AddCrease");

            transaction.Start();
            Vector4 v1 = new Vector4(new Autodesk.Revit.DB.XYZ(point1.X, point1.Y, 0));

            v1 = m_restoreMatrix.Transform(v1);
            SlabShapeVertex vertex1 = m_slabShapeEditor.DrawPoint(new Autodesk.Revit.DB.XYZ(v1.X, v1.Y, v1.Z));
            //create second vertex
            Vector4 v2 = new Vector4(new Autodesk.Revit.DB.XYZ(point2.X, point2.Y, 0));

            v2 = m_restoreMatrix.Transform(v2);
            SlabShapeVertex vertex2 = m_slabShapeEditor.DrawPoint(new Autodesk.Revit.DB.XYZ(v2.X, v2.Y, v2.Z));
            //create crease
            SlabShapeCreaseArray creases = m_slabShapeEditor.DrawSplitLine(vertex1, vertex2);

            SlabShapeCrease crease = creases.get_Item(0);

            transaction.Commit();
            //re-calculate geometry info
            GetSlabProfileInfo();
            return(crease);
        }
Example #4
0
        public static string AddSplitLineWithElevation(global::Revit.Elements.Element roof, Curve curve, double elevation)
        {
            Autodesk.Revit.DB.Document doc          = DocumentManager.Instance.CurrentDBDocument;
            Autodesk.Revit.DB.RoofBase internalRoof = (Autodesk.Revit.DB.RoofBase)roof.InternalElement;

            Point startPoint = Point.ByCoordinates(curve.StartPoint.X, curve.StartPoint.Y, elevation);
            Point endPoint   = Point.ByCoordinates(curve.EndPoint.X, curve.EndPoint.Y, elevation);

            string result;

            try
            {
                TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument);
                internalRoof.SlabShapeEditor.Enable();
                SlabShapeVertex vertex1 = internalRoof.SlabShapeEditor.DrawPoint(startPoint.ToXyz());
                SlabShapeVertex vertex2 = internalRoof.SlabShapeEditor.DrawPoint(endPoint.ToXyz());
                internalRoof.SlabShapeEditor.DrawSplitLine(vertex1, vertex2);
                TransactionManager.Instance.TransactionTaskDone();
                result = "Success.";
            }
            catch (Exception)
            {
                result = "not so success.";
            }

            return(result);
        }
Example #5
0
 /// <summary>
 /// add vertex and crease, select new created vertex and crease
 /// </summary>
 /// <param name="sender">object who sent this event</param>
 /// <param name="e">event args</param>
 private void SlabShapePictureBox_MouseClick(object sender, MouseEventArgs e)
 {
     if (EditorState.AddCrease == editorState)
     {
         if (!m_slabProfile.CanCreateVertex(new PointF(e.X, e.Y)))
         {
             return;
         }
         m_lineTool.Points.Add(new PointF(e.X, e.Y));
         int lineSize = m_lineTool.Points.Count;
         if (0 == m_lineTool.Points.Count % 2)
         {
             m_createCreases.Add(
                 m_slabProfile.AddCrease((PointF)m_lineTool.Points[lineSize - 2],
                                         (PointF)m_lineTool.Points[lineSize - 1]));
         }
         CreateGraphicsPath(); //create graphic path for all the vertex and crease
     }
     else if (EditorState.AddVertex == editorState)
     {
         SlabShapeVertex vertex = m_slabProfile.AddVertex(new PointF(e.X, e.Y));
         if (null == vertex)
         {
             return;
         }
         m_pointTool.Points.Add(new PointF(e.X, e.Y));
         //draw point as a short line, so add two points here
         m_pointTool.Points.Add(new PointF((float)(e.X + 2), (float)(e.Y + 2)));
         m_createdVertices.Add(vertex);
         CreateGraphicsPath(); //create graphic path for all the vertex and crease
     }
     else if (EditorState.Select == editorState)
     {
         if (m_selectIndex >= 0)
         {
             m_clickedIndex = m_selectIndex;
             if (m_selectIndex <= m_createCreases.Count - 1)
             {
                 m_selectedCrease = (SlabShapeCrease)(m_createCreases[m_selectIndex]);
                 m_selectedVertex = null;
             }
             else
             {
                 //put all path (crease and vertex) in one arrayList, so reduce creases.count
                 int index = m_selectIndex - m_createCreases.Count;
                 m_selectedVertex = (SlabShapeVertex)(m_createdVertices[index]);
                 m_selectedCrease = null;
             }
         }
         else
         {
             m_selectedVertex = null; m_selectedCrease = null; m_clickedIndex = -1;
         }
     }
     this.SlabShapePictureBox.Refresh();
 }
Example #6
0
        /// <summary>
        /// Add vertex on specific location
        /// </summary>
        /// <param name="point">location where vertex add on</param>
        /// <returns>new created vertex</returns>
        public SlabShapeVertex AddVertex(PointF point)
        {
            Transaction transaction = new Transaction(
                m_commandData.Application.ActiveUIDocument.Document, "AddVertex");

            transaction.Start();
            Vector4 v1 = new Vector4(new Autodesk.Revit.DB.XYZ(point.X, point.Y, 0));

            v1 = m_restoreMatrix.Transform(v1);
            SlabShapeVertex vertex = m_slabShapeEditor.DrawPoint(new Autodesk.Revit.DB.XYZ(v1.X, v1.Y, v1.Z));

            transaction.Commit();
            //re-calculate geometry info
            GetSlabProfileInfo();

            return(vertex);
        }
Example #7
0
        /// <summary>
        /// judge whether point can use to create vertex on slab
        /// </summary>
        /// <param name="point1">location where vertex add on</param>
        /// <returns>whether point can use to create vertex on slab</returns>
        public bool CanCreateVertex(PointF pointF)
        {
            bool        createSuccess = false;
            Transaction transaction   = new Transaction(
                m_commandData.Application.ActiveUIDocument.Document, "CanCreateVertex");

            transaction.Start();
            Vector4 v1 = new Vector4(new Autodesk.Revit.DB.XYZ(pointF.X, pointF.Y, 0));

            v1 = m_restoreMatrix.Transform(v1);
            SlabShapeVertex vertex = m_slabShapeEditor.DrawPoint(new Autodesk.Revit.DB.XYZ(v1.X, v1.Y, v1.Z));

            if (null != vertex)
            {
                createSuccess = true;
            }
            transaction.RollBack();
            //re-calculate geometry info
            GetSlabProfileInfo();
            return(createSuccess);
        }
Example #8
0
        public static string AddPoint(global::Revit.Elements.Element roof, Point point)
        {
            Autodesk.Revit.DB.Document doc          = DocumentManager.Instance.CurrentDBDocument;
            Autodesk.Revit.DB.RoofBase internalRoof = (Autodesk.Revit.DB.RoofBase)roof.InternalElement;

            string result;

            try
            {
                TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument);
                internalRoof.SlabShapeEditor.Enable();
                SlabShapeVertex vertex1 = internalRoof.SlabShapeEditor.DrawPoint(point.ToXyz());
                TransactionManager.Instance.TransactionTaskDone();
                result = "Success.";
            }
            catch (Exception)
            {
                result = "not so success.";
            }

            return(result);
        }
Example #9
0
        CollectEvent(object sender, CollectorEventArgs e)
        {
            // cast the sender object to the SnoopCollector we are expecting
            Collector snoopCollector = sender as Collector;

            if (snoopCollector == null)
            {
                Debug.Assert(false);    // why did someone else send us the message?
                return;
            }

            // see if it is a type we are responsible for
            SlabShapeCrease slabCrease = e.ObjToSnoop as SlabShapeCrease;

            if (slabCrease != null)
            {
                Stream(snoopCollector.Data(), slabCrease);
                return;
            }

            SlabShapeEditor slabEditor = e.ObjToSnoop as SlabShapeEditor;

            if (slabEditor != null)
            {
                Stream(snoopCollector.Data(), slabEditor);
                return;
            }

            SlabShapeVertex slabVertex = e.ObjToSnoop as SlabShapeVertex;

            if (slabVertex != null)
            {
                Stream(snoopCollector.Data(), slabVertex);
                return;
            }
        }
Example #10
0
 /// <summary>
 /// add vertex and crease, select new created vertex and crease
 /// </summary>
 /// <param name="sender">object who sent this event</param>
 /// <param name="e">event args</param>
 private void SlabShapePictureBox_MouseClick(object sender, MouseEventArgs e)
 {
     if (EditorState.AddCrease == editorState)
     {
         if (!m_slabProfile.CanCreateVertex(new PointF(e.X, e.Y))) { return; }
         m_lineTool.Points.Add(new PointF(e.X, e.Y));
         int lineSize = m_lineTool.Points.Count;
         if (0 == m_lineTool.Points.Count % 2)
         {
             m_createCreases.Add(
                 m_slabProfile.AddCrease((PointF)m_lineTool.Points[lineSize - 2],
                 (PointF)m_lineTool.Points[lineSize - 1]));
         }
         CreateGraphicsPath(); //create graphic path for all the vertex and crease
     }
     else if (EditorState.AddVertex == editorState)
     {
         SlabShapeVertex vertex = m_slabProfile.AddVertex(new PointF(e.X, e.Y));
         if (null == vertex) { return; }
         m_pointTool.Points.Add(new PointF(e.X, e.Y));
         //draw point as a short line, so add two points here
         m_pointTool.Points.Add(new PointF((float)(e.X + 2), (float)(e.Y + 2)));
         m_createdVertices.Add(vertex);
         CreateGraphicsPath(); //create graphic path for all the vertex and crease
     }
     else if (EditorState.Select == editorState)
     {
         if (m_selectIndex >= 0)
         {
             m_clickedIndex = m_selectIndex;
             if (m_selectIndex <= m_createCreases.Count - 1)
             {
                 m_selectedCrease = (SlabShapeCrease)(m_createCreases[m_selectIndex]);
                 m_selectedVertex = null;
             }
             else
             {
                 //put all path (crease and vertex) in one arrayList, so reduce creases.count
                 int index = m_selectIndex - m_createCreases.Count;
                 m_selectedVertex = (SlabShapeVertex)(m_createdVertices[index]);
                 m_selectedCrease = null;
             }
         }
         else { m_selectedVertex = null; m_selectedCrease = null; m_clickedIndex = -1; }
     }
     this.SlabShapePictureBox.Refresh();
 }
        private void Stream(ArrayList data, SlabShapeVertex slabVertex)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(SlabShapeVertex)));

            data.Add(new Snoop.Data.Xyz("Position", slabVertex.Position));
            data.Add(new Snoop.Data.String("Vertex type", slabVertex.VertexType.ToString()));
        }