/// <summary>
        /// Get 1 truss or 2 columns from selection
        /// </summary>
        /// <returns>return false if selection incorrect</returns>
        private bool GetSelectTrussOrColumns()
        {
            if (m_activeDocument.Selection.GetElementIds().Count > 2 ||
                0 == m_activeDocument.Selection.GetElementIds().Count)
            {
                return(false);
            }

            ElementSet es = new ElementSet();

            foreach (ElementId elementId in m_activeDocument.Selection.GetElementIds())
            {
                es.Insert(m_activeDocument.Document.GetElement(elementId));
            }
            IEnumerator iter = es.GetEnumerator();

            iter.Reset();
            while (iter.MoveNext())
            {
                if (iter.Current is Autodesk.Revit.DB.Structure.Truss)
                {
                    if (null == m_truss)
                    {
                        m_truss = iter.Current as Autodesk.Revit.DB.Structure.Truss;
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (iter.Current is Autodesk.Revit.DB.FamilyInstance)
                {
                    FamilyInstance familyInstance = iter.Current as FamilyInstance;
                    if (StructuralType.Column == familyInstance.StructuralType)
                    {
                        if (null == column1)
                        {
                            column1 = familyInstance;
                        }
                        else
                        {
                            column2 = familyInstance;
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            if (null == m_truss && (null == column1 || null == column2))
            {
                return(false);
            }
            return(true);
        }
Exemple #2
0
        Autodesk.Revit.DB.XYZ startLocation = null; //store the start point of truss location

        #endregion Fields

        #region Constructors

        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="truss">new created truss object in Revit</param>
        public TrussGeometry(Autodesk.Revit.DB.Structure.Truss truss, ExternalCommandData commandData)
        {
            m_commandData = commandData;
            m_topChord = new LineTool();
            m_bottomChord = new LineTool();
            m_truss = truss;
            m_graphicsPaths = new ArrayList();
            GetTrussGeometryInfo();
        }
        Autodesk.Revit.DB.XYZ endLocation = null;   //store the end point of truss location

        #endregion

        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="truss">new created truss object in Revit</param>
        public TrussGeometry(Autodesk.Revit.DB.Structure.Truss truss, ExternalCommandData commandData)
        {
            m_commandData   = commandData;
            m_topChord      = new LineTool();
            m_bottomChord   = new LineTool();
            m_truss         = truss;
            m_graphicsPaths = new ArrayList();
            GetTrussGeometryInfo();
        }
Exemple #4
0
        /// <summary>
        /// Get 1 truss or 2 columns from selection
        /// </summary>
        /// <returns>return false if selection incorrect</returns>
        private bool GetSelectTrussOrColumns()
        {
            if (m_activeDocument.Selection.Elements.Size > 2 ||
                0 == m_activeDocument.Selection.Elements.Size)
            {
                return(false);
            }

            IEnumerator iter = m_activeDocument.Selection.Elements.GetEnumerator();

            iter.Reset();
            while (iter.MoveNext())
            {
                if (iter.Current is Autodesk.Revit.DB.Structure.Truss)
                {
                    if (null == m_truss)
                    {
                        m_truss = iter.Current as Autodesk.Revit.DB.Structure.Truss;
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (iter.Current is Autodesk.Revit.DB.FamilyInstance)
                {
                    FamilyInstance familyInstance = iter.Current as FamilyInstance;
                    if (StructuralType.Column == familyInstance.StructuralType)
                    {
                        if (null == column1)
                        {
                            column1 = familyInstance;
                        }
                        else
                        {
                            column2 = familyInstance;
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            if (null == m_truss && (null == column1 || null == column2))
            {
                return(false);
            }
            return(true);
        }
Exemple #5
0
        /// <summary>
        /// create new truss
        /// </summary>
        /// <param name="sender">object who sent this event</param>
        /// <param name="e">event args</param>
        private void CreateButton_Click(object sender, EventArgs e)
        {
            try
            {
                Transaction transaction = new Transaction(m_commandData.Application.ActiveUIDocument.Document, "CreateTruss");
                transaction.Start();
                // create the truss
                m_truss = CreateTruss();
                m_truss.Location.Move(new Autodesk.Revit.DB.XYZ(0, 0, m_selectedView.GenLevel.Elevation));
                transaction.Commit();
                trussGeometry = new TrussGeometry(m_truss, m_commandData);
                this.TrussGraphicsTabControl.SelectedIndex = 1;
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message); }

            this.TrussTypeComboBox.Enabled = false;
            this.CreateButton.Enabled      = false;
            this.ViewComboBox.Enabled      = false;
        }
Exemple #6
0
        /// <summary>
        /// Get 1 truss or 2 columns from selection
        /// </summary>
        /// <returns>return false if selection incorrect</returns>
        private bool GetSelectTrussOrColumns()
        {
            if (m_activeDocument.Selection.Elements.Size > 2 ||
                0 == m_activeDocument.Selection.Elements.Size)
            { return false; }

            IEnumerator iter = m_activeDocument.Selection.Elements.GetEnumerator();
            iter.Reset();
            while (iter.MoveNext())
            {
                if (iter.Current is Autodesk.Revit.DB.Structure.Truss)
                {
                    if (null == m_truss)
                    { m_truss = iter.Current as Autodesk.Revit.DB.Structure.Truss; }
                    else { return false; }
                }
                else if (iter.Current is Autodesk.Revit.DB.FamilyInstance)
                {
                    FamilyInstance familyInstance = iter.Current as FamilyInstance;
                    if (StructuralType.Column == familyInstance.StructuralType)
                    {
                        if (null == column1) { column1 = familyInstance; }
                        else { column2 = familyInstance; }
                    }
                    else
                    { return false; }
                }
                else { return false; }
            }
            if (null == m_truss && (null == column1 || null == column2))
            { return false; }
            return true;
        }
Exemple #7
0
        /// <summary>
        /// create new truss
        /// </summary>
        /// <param name="sender">object who sent this event</param>
        /// <param name="e">event args</param>
        private void CreateButton_Click(object sender, EventArgs e)
        {
            try
            {
               Transaction transaction = new Transaction(m_commandData.Application.ActiveUIDocument.Document, "CreateTruss");
               transaction.Start();
                // create the truss
                m_truss = CreateTruss();
                m_truss.Location.Move(new Autodesk.Revit.DB.XYZ (0, 0, m_selectedView.GenLevel.Elevation));
                transaction.Commit();
                trussGeometry = new TrussGeometry(m_truss, m_commandData);
                this.TrussGraphicsTabControl.SelectedIndex = 1;
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message); }

            this.TrussTypeComboBox.Enabled = false;
            this.CreateButton.Enabled = false;
            this.ViewComboBox.Enabled = false;
        }