Ejemplo n.º 1
0
        /// <summary>
        /// Exports Walls.
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="wallElement">
        /// The wall element.
        /// </param>
        /// <param name="geometryElement">
        /// The geometry element.
        /// </param>
        /// <param name="productWrapper">
        /// The IFCProductWrapper.
        /// </param>
        public static void Export(ExporterIFC exporterIFC, Wall wallElement, GeometryElement geometryElement, IFCProductWrapper productWrapper)
        {
            IFCFile file = exporterIFC.GetFile();
            using (IFCTransaction tr = new IFCTransaction(file))
            {
                bool exportAsOldCurtainWall = ExporterIFCUtils.IsLegacyCurtainWall(wallElement);
                bool exportAsCurtainWall = (wallElement.CurtainGrid != null);

                try
                {
                    if (exportAsOldCurtainWall)
                        ExporterIFCUtils.ExportLegacyCurtainWall(exporterIFC, wallElement, geometryElement, productWrapper);
                    else if (exportAsCurtainWall)
                        ExporterIFCUtils.ExportCurtainWall(exporterIFC, wallElement, geometryElement, productWrapper);
                    else
                        ExportWall(exporterIFC, wallElement, geometryElement, productWrapper);
                }
                catch (System.Exception ex)
                {
                    throw ex;
                }

                // create join information.
                ElementId id = wallElement.Id;

                IList<IList<IFCConnectedWallData>> connectedWalls = new List<IList<IFCConnectedWallData>>();
                connectedWalls.Add(ExporterIFCUtils.GetConnectedWalls(wallElement, IFCConnectedWallDataLocation.Start));
                connectedWalls.Add(ExporterIFCUtils.GetConnectedWalls(wallElement, IFCConnectedWallDataLocation.End));
                for (int ii = 0; ii < 2; ii++)
                {
                    int count = connectedWalls[ii].Count;
                    IFCConnectedWallDataLocation currConnection = (ii == 0) ? IFCConnectedWallDataLocation.Start : IFCConnectedWallDataLocation.End;
                    for (int jj = 0; jj < count; jj++)
                    {
                        ElementId otherId = connectedWalls[ii][jj].ElementId;
                        IFCConnectedWallDataLocation joinedEnd = connectedWalls[ii][jj].Location;

                        if ((otherId == id) && (joinedEnd == currConnection))  //self-reference
                            continue;

                        exporterIFC.RegisterWallConnectionData(id, otherId, currConnection, joinedEnd, IFCAnyHandle.Create());
                    }
                }

                // look for connected columns.  Note that this is only for columns that interrupt the wall path.
                IList<FamilyInstance> attachedColumns = ExporterIFCUtils.GetAttachedColumns(wallElement);
                int numAttachedColumns = attachedColumns.Count;
                for (int ii = 0; ii < numAttachedColumns; ii++)
                {
                    ElementId otherId = attachedColumns[ii].Id;

                    IFCConnectedWallDataLocation connect1 = IFCConnectedWallDataLocation.NotDefined;   // can't determine at the moment.
                    IFCConnectedWallDataLocation connect2 = IFCConnectedWallDataLocation.NotDefined;   // meaningless for column

                    exporterIFC.RegisterWallConnectionData(id, otherId, connect1, connect2, IFCAnyHandle.Create());
                }

                tr.Commit();
            }
        }