Exemple #1
0
        /// <summary>
        /// Create a family instance according the selected options by user
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            bool retBool = false;

            try
            {
                Transaction transaction = new Transaction(m_creator.RevitDoc.Document, "CreateFamilyInstance");
                transaction.Start();
                switch (m_baseType)
                {
                case BasedType.Point:
                    retBool = m_creator.CreatePointFamilyInstance(PointControlFirst.GetPointData()
                                                                  , PointControlSecond.GetPointData()
                                                                  , comboBoxFace.SelectedIndex
                                                                  , comboBoxFamily.SelectedIndex);
                    break;

                case BasedType.Line:
                    retBool = m_creator.CreateLineFamilyInstance(PointControlFirst.GetPointData()
                                                                 , PointControlSecond.GetPointData()
                                                                 , comboBoxFace.SelectedIndex
                                                                 , comboBoxFamily.SelectedIndex);
                    break;

                default:
                    break;
                }
                transaction.Commit();
            }
            catch (ApplicationException)
            {
                Autodesk.Revit.UI.TaskDialog.Show("Revit", "Failed in creating family instance, maybe because the family symbol is wrong type, please check and choose again.");
                return;
            }
            catch (Exception ee)
            {
                Autodesk.Revit.UI.TaskDialog.Show("Revit", ee.Message);
                return;
            }

            if (retBool)
            {
                this.Close();
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                Autodesk.Revit.UI.TaskDialog.Show("Revit", "The line is perpendicular to this face, please input the position again.");
            }
        }
Exemple #2
0
        /// <summary>
        /// Get face information when the selected face is changed
        /// </summary>
        /// <param name="index">the index of the new selected face</param>
        private void SetFaceIndex(int index)
        {
            comboBoxFace.SelectedItem = m_creator.FaceNameList[index];

            BoundingBoxXYZ boundingBox = m_creator.GetFaceBoundingBox(index);

            Autodesk.Revit.DB.XYZ totle = boundingBox.Min + boundingBox.Max;
            switch (m_baseType)
            {
            case BasedType.Point:
                PointControlFirst.SetPointData(totle / 2.0f);
                PointControlSecond.SetPointData(new Autodesk.Revit.DB.XYZ(1.0f, 0f, 0f));
                break;

            case BasedType.Line:
                PointControlFirst.SetPointData(boundingBox.Min);
                PointControlSecond.SetPointData(boundingBox.Max);
                break;

            default:
                break;
            }
        }