/// <summary>
        /// Creates a SweptSolidExporter.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="element">The element.</param>
        /// <param name="solid">The solid.</param>
        /// <param name="normal">The normal of the plane that the path lies on.</param>
        /// <returns>The SweptSolidExporter.</returns>
        public static SweptSolidExporter Create(ExporterIFC exporterIFC, Element element, Solid solid, XYZ normal)
        {
            try
            {
                SweptSolidExporter       sweptSolidExporter = null;
                SimpleSweptSolidAnalyzer sweptAnalyzer      = SimpleSweptSolidAnalyzer.Create(element.Document.Application.Create, solid, normal);
                if (sweptAnalyzer != null)
                {
                    // TODO: support openings and recess for a swept solid
                    if (sweptAnalyzer.UnalignedFaces != null && sweptAnalyzer.UnalignedFaces.Count > 0)
                    {
                        return(null);
                    }

                    IList <GeometryUtil.FaceBoundaryType> faceBoundaryTypes;
                    IList <CurveLoop> faceBoundaries = GeometryUtil.GetFaceBoundaries(sweptAnalyzer.ProfileFace, null, out faceBoundaryTypes);

                    string profileName = null;
                    if (element != null)
                    {
                        ElementType type = element.Document.GetElement(element.GetTypeId()) as ElementType;
                        if (type != null)
                        {
                            profileName = type.Name;
                        }
                    }

                    // is extrusion?
                    if (sweptAnalyzer.PathCurve is Line)
                    {
                        Line line = sweptAnalyzer.PathCurve as Line;

                        // invalid case
                        if (MathUtil.VectorsAreOrthogonal(line.Direction, sweptAnalyzer.ProfileFace.Normal))
                        {
                            return(null);
                        }

                        sweptSolidExporter = new SweptSolidExporter();
                        sweptSolidExporter.m_IsExtrusion = true;
                        Plane plane = new Plane(sweptAnalyzer.ProfileFace.Normal, sweptAnalyzer.ProfileFace.Origin);
                        sweptSolidExporter.m_RepresentationItem = ExtrusionExporter.CreateExtrudedSolidFromCurveLoop(exporterIFC, profileName, faceBoundaries, plane,
                                                                                                                     line.Direction, line.Length * exporterIFC.LinearScale);
                    }
                    else
                    {
                        sweptSolidExporter = new SweptSolidExporter();
                        sweptSolidExporter.m_RepresentationItem = CreateSimpleSweptSolid(exporterIFC, profileName, faceBoundaries, normal, sweptAnalyzer.PathCurve);
                    }
                }
                return(sweptSolidExporter);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a SweptSolidExporter.
        /// </summary>
        /// <param name="exporterIFC">The exporter.</param>
        /// <param name="element">The element.</param>
        /// <param name="solid">The solid.</param>
        /// <param name="normal">The normal of the plane that the path lies on.</param>
        /// <returns>The SweptSolidExporter.</returns>
        public static SweptSolidExporter Create(ExporterIFC exporterIFC, Element element, Solid solid, XYZ normal)
        {
            try
            {
                SweptSolidExporter sweptSolidExporter = null;
                SimpleSweptSolidAnalyzer sweptAnalyzer = SimpleSweptSolidAnalyzer.Create(element.Document.Application.Create, solid, normal);
                if (sweptAnalyzer != null)
                {
                    // TODO: support openings and recess for a swept solid
                    if (sweptAnalyzer.UnalignedFaces != null && sweptAnalyzer.UnalignedFaces.Count > 0)
                        return null;

                    IList<GeometryUtil.FaceBoundaryType> faceBoundaryTypes;
                    IList<CurveLoop> faceBoundaries = GeometryUtil.GetFaceBoundaries(sweptAnalyzer.ProfileFace, null, out faceBoundaryTypes);

                    string profileName = null;
                    if (element != null)
                    {
                        ElementType type = element.Document.GetElement(element.GetTypeId()) as ElementType;
                        if (type != null)
                            profileName = type.Name;
                    }

                    // is extrusion?
                    if (sweptAnalyzer.PathCurve is Line)
                    {
                        Line line = sweptAnalyzer.PathCurve as Line;

                        // invalid case
                        if (MathUtil.VectorsAreOrthogonal(line.Direction, sweptAnalyzer.ProfileFace.Normal))
                            return null;

                        sweptSolidExporter = new SweptSolidExporter();
                        sweptSolidExporter.m_IsExtrusion = true;
                        Plane plane = new Plane(sweptAnalyzer.ProfileFace.Normal, sweptAnalyzer.ProfileFace.Origin);
                        sweptSolidExporter.m_RepresentationItem = ExtrusionExporter.CreateExtrudedSolidFromCurveLoop(exporterIFC, profileName, faceBoundaries, plane,
                            line.Direction, line.Length * exporterIFC.LinearScale);
                    }
                    else
                    {
                        sweptSolidExporter = new SweptSolidExporter();
                        sweptSolidExporter.m_RepresentationItem = CreateSimpleSweptSolid(exporterIFC, profileName, faceBoundaries, normal, sweptAnalyzer.PathCurve);
                    }
                }
                return sweptSolidExporter;
            }
            catch (Exception)
            {
                return null;
            }
        }