예제 #1
0
        /// <summary>
        /// Helper function to export elements
        /// </summary>
        /// <param name="emitter"></param>
        /// <param name="collector"></param>
        /// <param name="opt"></param>
        void ExportElements(IFaceEmitter emitter, FilteredElementCollector collector, Options opt)
        {
            int nElements = 0;
            int nSolids   = 0;

            foreach (Element e in collector)
            {
                ++nElements;
                nSolids += ExportElement(emitter, e, opt);
            }

            int nFaces     = emitter.GetFaceCount();
            int nTriangles = emitter.GetTriangleCount();
            int nVertices  = emitter.GetVertexCount();
        }
예제 #2
0
        /// <summary>
        /// Recursive method that checks for groups and gets solid geometry from elements
        /// </summary>
        /// <param name="emitter"></param>
        /// <param name="e"></param>
        /// <param name="opt"></param>
        /// <returns>int</returns>
        int ExportElement(IFaceEmitter emitter, Element e, Options opt)
        {
            Group group = e as Group;

            // if element successfully casts to a group then iterate through the group
            if (null != group)
            {
                int n = 0;

                foreach (ElementId id in group.GetMemberIds())
                {
                    Element e2 = e.Document.GetElement(id);
                    n += ExportElement(emitter, e2, opt);
                }
                return(n);
            }

            // return if element has no category
            if (null == e.Category)
            {
                return(0);
            }

            // access the geometry object
            Solid solid = GetSolid(e, opt);

            // return if no solid
            if (null == solid)
            {
                return(0);
            }

            Material material;
            Color    color;

            foreach (Face face in solid.Faces)
            {
                material = e.Document.GetElement(face.MaterialElementId) as Material;
                // if no material, no color
                color = (null == material) ? null : material.Color;

                emitter.EmitFace(face, color);
            }
            return(1);
        }
예제 #3
0
        /// <summary>
        /// Helper function to export elements
        /// </summary>
        /// <param name="emitter"></param>
        /// <param name="collector"></param>
        /// <param name="opt"></param>
        void ExportElements(IFaceEmitter emitter, FilteredElementCollector collector, Options opt)
        {
            int nElements = 0;
            int nSolids = 0;

            foreach (Element e in collector)
            {
                ++nElements;
                nSolids += ExportElement(emitter, e, opt);
            }

            int nFaces = emitter.GetFaceCount();
            int nTriangles = emitter.GetTriangleCount();
            int nVertices = emitter.GetVertexCount();
        }
예제 #4
0
        /// <summary>
        /// Recursive method that checks for groups and gets solid geometry from elements
        /// </summary>
        /// <param name="emitter"></param>
        /// <param name="e"></param>
        /// <param name="opt"></param>
        /// <returns>int</returns>
        int ExportElement(IFaceEmitter emitter, Element e, Options opt)
        {
            Group group = e as Group;

            // if element successfully casts to a group then iterate through the group
            if (null != group)
            {
                int n = 0;

                foreach (ElementId id in group.GetMemberIds())
                {
                    Element e2 = e.Document.GetElement(id);
                    n += ExportElement(emitter, e2, opt);
                }
                return n;
            }

            // return if element has no category
            if (null == e.Category)
            {
                return 0;
            }

            // access the geometry object
            Solid solid = GetSolid(e, opt);
            // return if no solid
            if (null == solid)
            {
                return 0;
            }

            Material material;
            Color color;

            foreach (Face face in solid.Faces)
            {
                material = e.Document.GetElement(face.MaterialElementId) as Material;
                // if no material, no color
                color = (null == material) ? null : material.Color;

                emitter.EmitFace(face, color);
            }
            return 1;
        }