This is main data class for creating family Instance by face
Beispiel #1
0
        /// <summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application
        /// which contains data related to the command,
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application
        /// which will be displayed if a failure or cancellation is returned by
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command.
        /// A result of Succeeded means that the API external method functioned as expected.
        /// Cancelled can be used to signify that the user cancelled the external operation
        /// at some point. Failure should be returned if the application is unable to proceed with
        /// the operation.</returns>
        public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData,
                                                ref string message,
                                                ElementSet elements)
        {
            // Quit if active document is null
            if (null == commandData.Application.ActiveUIDocument.Document)
            {
                message = "Active document is null.";
                return(Autodesk.Revit.UI.Result.Failed);
            }

            try
            {
                FamilyInstanceCreator creator = new FamilyInstanceCreator(commandData.Application);

                // an option dialog for user choosing based type of creating
                BasedTypeForm baseTypeform = new BasedTypeForm();
                if (DialogResult.OK == baseTypeform.ShowDialog())
                {
                    PlaceFamilyInstanceForm placeForm = new PlaceFamilyInstanceForm(creator
                                                                                    , baseTypeform.BaseType);
                    placeForm.ShowDialog();
                }

                // if everything goes well, return succeeded.
                return(Autodesk.Revit.UI.Result.Succeeded);
            }
            catch (Exception ex)
            {
                // If any error, give error information and return failed
                message = ex.Message;
                return(Autodesk.Revit.UI.Result.Failed);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application 
        /// which contains data related to the command, 
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application 
        /// which will be displayed if a failure or cancellation is returned by 
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application 
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command. 
        /// A result of Succeeded means that the API external method functioned as expected. 
        /// Cancelled can be used to signify that the user cancelled the external operation 
        /// at some point. Failure should be returned if the application is unable to proceed with 
        /// the operation.</returns>
        public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData,
                                               ref string message,
                                               ElementSet elements)
        {
            // Quit if active document is null
            if (null == commandData.Application.ActiveUIDocument.Document)
            {
                message = "Active document is null.";
                return Autodesk.Revit.UI.Result.Failed;
            }

            try
            {
                FamilyInstanceCreator creator = new FamilyInstanceCreator(commandData.Application);

                // an option dialog for user choosing based type of creating
                BasedTypeForm baseTypeform = new BasedTypeForm();
                if (DialogResult.OK == baseTypeform.ShowDialog())
                {
                    PlaceFamilyInstanceForm placeForm = new PlaceFamilyInstanceForm(creator
                        , baseTypeform.BaseType);
                    placeForm.ShowDialog();
                }

                // if everything goes well, return succeeded.
                return Autodesk.Revit.UI.Result.Succeeded;
            }
            catch (Exception ex)
            {
                // If any error, give error information and return failed
                message = ex.Message;
                return Autodesk.Revit.UI.Result.Failed;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="creator">the family instance creator</param>
        /// <param name="type">based-type</param>
        public PlaceFamilyInstanceForm(FamilyInstanceCreator creator, BasedType type)
        {
            m_creator = creator;
            m_creator.CheckFamilySymbol(type);
            m_baseType = type;
            InitializeComponent();

            // set the face name list and the default value
            foreach (String name in creator.FaceNameList)
            {
                comboBoxFace.Items.Add(name);
            }
            if (comboBoxFace.Items.Count > 0)
            {
                SetFaceIndex(0);
            }

            // set the family name list and the default value
            foreach (String symbolName in m_creator.FamilySymbolNameList)
            {
                comboBoxFamily.Items.Add(symbolName);
            }
            if (m_creator.DefaultFamilySymbolIndex < 0)
            {
                comboBoxFamily.SelectedItem = m_creator.FamilySymbolNameList[0];
            }
            else
            {
                comboBoxFamily.SelectedItem =
                    m_creator.FamilySymbolNameList[m_creator.DefaultFamilySymbolIndex];
            }

            // set UI display according to baseType
            switch (m_baseType)
            {
            case BasedType.Point:
                this.Text        = "Place Point-Based Family Instance";
                labelFirst.Text  = "Location :";
                labelSecond.Text = "Direction :";
                break;

            case BasedType.Line:
                comboBoxFamily.SelectedItem = "Line-based";
                this.Text = "Place Line-Based Family Instance";

                labelFirst.Text  = "Start Point :";
                labelSecond.Text = "End Point :";
                break;

            default:
                break;
            }
            AdjustComboBoxDropDownListWidth(comboBoxFace);
            AdjustComboBoxDropDownListWidth(comboBoxFamily);
        }
Beispiel #4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="creator">the family instance creator</param>
        /// <param name="type">based-type</param>
        public PlaceFamilyInstanceForm(FamilyInstanceCreator creator, BasedType type)
        {
            m_creator = creator;
            m_creator.CheckFamilySymbol(type);
            m_baseType = type;
            InitializeComponent();

            // set the face name list and the default value
            foreach (String name in creator.FaceNameList)
            {
                comboBoxFace.Items.Add(name);
            }
            if (comboBoxFace.Items.Count > 0)
            {
                SetFaceIndex(0);
            }

            // set the family name list and the default value
            foreach (String symbolName in m_creator.FamilySymbolNameList)
            {
                comboBoxFamily.Items.Add(symbolName);
            }
            if (m_creator.DefaultFamilySymbolIndex < 0)
            {
                comboBoxFamily.SelectedItem = m_creator.FamilySymbolNameList[0];
            }
            else
            {
                comboBoxFamily.SelectedItem =
                    m_creator.FamilySymbolNameList[m_creator.DefaultFamilySymbolIndex];
            }

            // set UI display according to baseType
            switch (m_baseType)
            {
                case BasedType.Point:
                    this.Text = "Place Point-Based Family Instance";
                    labelFirst.Text = "Location :";
                    labelSecond.Text = "Direction :";
                    break;
                case BasedType.Line:
                    comboBoxFamily.SelectedItem = "Line-based";
                    this.Text = "Place Line-Based Family Instance";

                    labelFirst.Text = "Start Point :";
                    labelSecond.Text = "End Point :";
                    break;
                default:
                    break;
            }
            AdjustComboBoxDropDownListWidth(comboBoxFace);
            AdjustComboBoxDropDownListWidth(comboBoxFamily);
        }