/// <summary>
        /// Create the arc(ModelArc)
        /// </summary>
        /// <param name="sketchId">the id of the sketch plane</param>
        /// <param name="startPoint">the start point of the arc</param>
        /// <param name="endPoint">the end point of the arc</param>
        /// <param name="thirdPoint">the third point which is on the arc</param>
        public void CreateArc(ElementId sketchId, Autodesk.Revit.DB.XYZ startPoint, Autodesk.Revit.DB.XYZ endPoint, Autodesk.Revit.DB.XYZ thirdPoint)
        {
            try
            {
                // First get the sketch plane by the giving element id.
                SketchPlane workPlane = GetSketchPlaneById(sketchId);

                // Additional check: the start, end and third point should not be the same
                if (startPoint.Equals(endPoint) || startPoint.Equals(thirdPoint) ||
                    endPoint.Equals(thirdPoint))
                {
                    throw new ArgumentException("Three points should not be the same.");
                }

                // create the geometry arc
                Arc geometryArc = Arc.Create(startPoint, endPoint, thirdPoint);
                if (null == geometryArc)        // assert the creation is successful
                {
                    throw new Exception("Create the geometry arc failed.");
                }
                // create the ModelArc
                ModelArc arc = m_createDoc.NewModelCurve(geometryArc, workPlane) as ModelArc;
                if (null == arc)                // assert the creation is successful
                {
                    throw new Exception("Create the ModelArc failed.");
                }
                // Add the created ModelArc into the arc array
                m_arcArray.Append(arc);

                // Finally refresh information map.
                RefreshInformationMap();
            }
            catch (Exception ex)
            {
                throw new Exception("Can not create the ModelArc, message: " + ex.Message);
            }
        }
Example #2
0
        /// <summary>
        /// Read the journal data from the journal.
        /// All journal data is stored in commandData.Data.
        /// </summary>
        private void ReadJournalData()
        {
            // Get the journal data map from API
            Document doc = m_commandData.Application.ActiveUIDocument.Document;
            IDictionary <string, string> dataMap = m_commandData.JournalData;

            String dataValue = null;    // store the journal data value temporarily

            // Get the wall type from the journal
            dataValue = GetSpecialData(dataMap, "Wall Type Name"); // get wall type name
            foreach (WallType type in m_wallTypeList)              // get the wall type by the name
            {
                if (dataValue == type.Name)
                {
                    m_createType = type;
                    break;
                }
            }
            if (null == m_createType)   // assert the wall type is exist
            {
                throw new InvalidDataException("Can't find the wall type from the journal.");
            }

            // Get the level information from the journal
            dataValue = GetSpecialData(dataMap, "Level Id");                                              // get the level id
            Autodesk.Revit.DB.ElementId id = new Autodesk.Revit.DB.ElementId(Convert.ToInt32(dataValue)); // get the level by its id

            m_createlevel = doc.GetElement(id) as Level;
            if (null == m_createlevel)  // assert the level is exist
            {
                throw new InvalidDataException("Can't find the level from the journal.");
            }

            // Get the start point information from the journal
            dataValue    = GetSpecialData(dataMap, "Start Point");
            m_startPoint = StirngToXYZ(dataValue);

            // Get the end point information from the journal
            dataValue  = GetSpecialData(dataMap, "End Point");
            m_endPoint = StirngToXYZ(dataValue);

            // Create wall don't allow the start point equals end point
            if (m_startPoint.Equals(m_endPoint))
            {
                throw new InvalidDataException("Start point is equal to end point.");
            }
        }
Example #3
0
        /// <summary>
        /// The okButton click event method,
        /// this method collect the data, and pass them to the journaling class
        /// </summary>
        private void okButton_Click(object sender, EventArgs e)
        {
            // Get the support data from the UI controls
            Autodesk.Revit.DB.XYZ startPoint = startPointUserControl.GetPointData(); // start point
            Autodesk.Revit.DB.XYZ endPoint   = endPointUserControl.GetPointData();   // end point
            if (startPoint.Equals(endPoint))                                         // Don't allow start point equals end point
            {
                TaskDialog.Show("Revit", "Start point should not equal end point.");
                return;
            }

            double diff = Math.Abs(startPoint.Z - endPoint.Z);

            if (diff > Precision)
            {
                TaskDialog.Show("Revit", "Z coordinate of start and end points should be equal.");
                return;
            }

            Level level = levelComboBox.SelectedItem as Level; // level information

            if (null == level)                                 // assert it isn't null
            {
                TaskDialog.Show("Revit", "The selected level is null or incorrect.");
                return;
            }

            WallType type = typeComboBox.SelectedItem as WallType; // wall type

            if (null == type)                                      // assert it isn't null
            {
                TaskDialog.Show("Revit", "The selected wall type is null or incorrect.");
                return;
            }

            // Invoke SetNecessaryData method to set the collected support data
            m_dataBuffer.SetNecessaryData(startPoint, endPoint, level, type);

            // Set result information and close the form
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Example #4
0
        private void ReadJournalData()
        {
            RevitDB.Document             doc     = m_commandData.Application.ActiveUIDocument.Document;
            IDictionary <string, string> dataMap = m_commandData.JournalData;
            string dataValue = null;

            dataValue = GetSpecialData(dataMap, "Wall Type Name");
            foreach (RevitDB.WallType type in m_wallTypeList)
            {
                if (dataValue == type.Name)
                {
                    m_createType = type;
                    break;
                }
            }
            if (null == m_createType)
            {
                throw new InvalidDataException("Can't find the wall type from the journal.");
            }

            dataValue = GetSpecialData(dataMap, "Level Id");
            RevitDB.ElementId id = new RevitDB.ElementId(Convert.ToInt32(dataValue));

            m_createlevel = doc.GetElement(id) as RevitDB.Level;
            if (null == m_createlevel)
            {
                throw new InvalidDataException("Can't find the level from the journal.");
            }

            dataValue    = GetSpecialData(dataMap, "Start Point");
            m_startPoint = StringToXYZ(dataValue);

            if (m_startPoint.Equals(m_endPoint))
            {
                throw new InvalidDataException("Start point is equal to end point.");
            }
        }
        /// <summary>
        /// Create the line(ModelLine)
        /// </summary>
        /// <param name="sketchId">the id of the sketch plane</param>
        /// <param name="startPoint">the start point of the line</param>
        /// <param name="endPoint">the end point of the line</param>
        public void CreateLine(ElementId sketchId, Autodesk.Revit.DB.XYZ startPoint, Autodesk.Revit.DB.XYZ endPoint)
        {
            try
            {
                // First get the sketch plane by the giving element id.
                SketchPlane workPlane = GetSketchPlaneById(sketchId);

                // Additional check: start point should not equal end point
                if (startPoint.Equals(endPoint))
                {
                    throw new ArgumentException("Two points should not be the same.");
                }

                // create geometry line
                Line geometryLine = Line.CreateBound(startPoint, endPoint);
                if (null == geometryLine)   // assert the creation is successful
                {
                    throw new Exception("Create the geometry line failed.");
                }
                // create the ModelLine
                ModelLine line = m_createDoc.NewModelCurve(geometryLine, workPlane) as ModelLine;
                if (null == line)           // assert the creation is successful
                {
                    throw new Exception("Create the ModelLine failed.");
                }
                // Add the created ModelLine into the line array
                m_lineArray.Append(line);

                // Finally refresh information map.
                RefreshInformationMap();
            }
            catch (Exception ex)
            {
                throw new Exception("Can not create the ModelLine, message: " + ex.Message);
            }
        }