Exemple #1
0
        /// <summary>
        /// Join geometry between overlapping solids.
        /// </summary>
        /// <param name="document">The active document</param>
        /// <returns>The number of geometry combination be joined in this document.</returns>
        public int Join(Document document)
        {
            int combinated = 0;

            // CombinableElement is of an element type that exists in the API, but not in Revit's native object model.
            // We use a combination of GenericForm and GeomCombination elements instead to find all CombinableElement.
            LogicalOrFilter filter = new LogicalOrFilter(
                new ElementClassFilter(typeof(GenericForm)),
                new ElementClassFilter(typeof(GeomCombination)));

            FilteredElementIterator itor = (new FilteredElementCollector(document)).WherePasses(filter).GetElementIterator();

            itor.Reset();
            while (itor.MoveNext())
            {
                GenericForm gf = itor.Current as GenericForm;
                if (null != gf && !gf.IsSolid)
                {
                    continue;
                }

                CombinableElement ce = itor.Current as CombinableElement;
                if (null == ce)
                {
                    continue;
                }
                else
                {
                    m_elements.Add(ce);
                }
            }
            // Added all solid forms in this document.

            while (1 < m_elements.Count)
            {
                GeomCombination geomCombination = JoinOverlapping(m_elements, document);
                if (null == geomCombination)
                {
                    return(combinated);//No overlapping.
                }

                combinated++;
            }

            return(combinated);
        }
        private void Stream( ArrayList data, GeomCombination geomComb )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( GeomCombination ) ) );

              data.Add( new Snoop.Data.Enumerable( "All members", geomComb.AllMembers ) );
        }