コード例 #1
0
ファイル: DoorWindowInfo.cs プロジェクト: tornadory/revit-ifc
        private void Initialize(bool isDoor, bool isWindow, FamilyInstance famInst, HostObject hostObject)
        {
            HostObject     = hostObject;
            InsertInstance = famInst;

            ExportingDoor = isDoor;
            if (isDoor)
            {
                PreDefinedType = "DOOR";
            }

            ExportingWindow = isWindow;
            if (isWindow)
            {
                PreDefinedType = "WINDOW";
            }

            FlippedSymbol = false;

            DoorOperationTypeString      = "NOTDEFINED";
            WindowPartitioningTypeString = "NOTDEFINED";

            FlippedX = (famInst == null) ? false : famInst.HandFlipped;
            FlippedY = (famInst == null) ? false : famInst.FacingFlipped;

            Wall  wall        = (hostObject == null) ? null : hostObject as Wall;
            Curve centerCurve = WallExporter.GetWallAxis(wall);

            HasRealWallHost = ((wall != null) && (centerCurve != null) && ((centerCurve is Line) || (centerCurve is Arc)));
        }
コード例 #2
0
ファイル: OpeningUtil.cs プロジェクト: xinhuaibuhui/revit-ifc
        static bool GetOpeningDirection(Element hostElem, out XYZ perpToWall)
        {
            bool isLinearWall = false;
             perpToWall = new XYZ(0, 0, 0);
             Wall wall = hostElem as Wall;
             if (wall != null)
             {
            Curve curve = WallExporter.GetWallAxis(wall);
            if (curve is Line)
            {
               isLinearWall = true;
               XYZ wallDir = (curve as Line).Direction;
               perpToWall = XYZ.BasisZ.CrossProduct(wallDir);
            }
             }

             return isLinearWall;
        }
コード例 #3
0
        private void Initialize(bool isDoor, bool isWindow, FamilyInstance famInst, HostObject hostObject, IFCExportInfoPair exportType)
        {
            HostObject     = hostObject;
            InsertInstance = famInst;

            ExportingDoor = isDoor;
            if (isDoor)
            {
                if (exportType.ValidatedPredefinedType.Equals("NOTDEFINED", StringComparison.InvariantCultureIgnoreCase))
                {
                    PreDefinedType = "DOOR";
                }
                else
                {
                    PreDefinedType = exportType.ValidatedPredefinedType;
                }
            }

            ExportingWindow = isWindow;
            if (isWindow)
            {
                if (exportType.ValidatedPredefinedType.Equals("NOTDEFINED", StringComparison.InvariantCultureIgnoreCase))
                {
                    PreDefinedType = "WINDOW";
                }
                else
                {
                    PreDefinedType = exportType.ValidatedPredefinedType;
                }
            }

            FlippedSymbol = false;

            DoorOperationTypeString      = "NOTDEFINED";
            WindowPartitioningTypeString = "NOTDEFINED";

            FlippedX = (famInst == null) ? false : famInst.HandFlipped;
            FlippedY = (famInst == null) ? false : famInst.FacingFlipped;

            Wall  wall        = (hostObject == null) ? null : hostObject as Wall;
            Curve centerCurve = WallExporter.GetWallAxis(wall);

            HasRealWallHost = ((wall != null) && (centerCurve != null) && ((centerCurve is Line) || (centerCurve is Arc)));
        }
コード例 #4
0
ファイル: DoorWindowInfo.cs プロジェクト: tornadory/revit-ifc
        private void CalculateDoorWindowInformation(ExporterIFC exporterIFC, FamilyInstance famInst,
                                                    ElementId overrideLevelId, Transform trf)
        {
            IFCFile file = exporterIFC.GetFile();

            if (ExportingDoor)
            {
                string doorOperationType = null;

                Element doorType = famInst.Document.GetElement(famInst.GetTypeId());
                if (doorType != null)
                {
                    // Look at the "Operation" override first, then the built-in parameter.
                    ParameterUtil.GetStringValueFromElementOrSymbol(doorType, "Operation", out doorOperationType);
                    if (!string.IsNullOrWhiteSpace(doorOperationType))
                    {
                        ParameterUtil.GetStringValueFromElement(doorType, BuiltInParameter.DOOR_OPERATION_TYPE, out doorOperationType);
                    }
                }

                DoorOperationTypeString = "NOTDEFINED";
                if (!string.IsNullOrWhiteSpace(doorOperationType))
                {
                    Type enumType = null;
                    if (ExporterCacheManager.ExportOptionsCache.ExportAs4)
                    {
                        enumType = typeof(Toolkit.IFC4.IFCDoorStyleOperation);
                    }
                    else
                    {
                        enumType = typeof(Toolkit.IFCDoorStyleOperation);
                    }

                    foreach (Enum ifcDoorStyleOperation in Enum.GetValues(enumType))
                    {
                        string enumAsString = ifcDoorStyleOperation.ToString();
                        if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(enumAsString, doorOperationType))
                        {
                            DoorOperationTypeString = enumAsString;
                            break;
                        }
                    }
                }

                if (DoorOperationTypeString == "NOTDEFINED")
                {
                    // We are going to try to guess the hinge placement.
                    DoorOperationTypeString = CalculateDoorOperationStyle(famInst);
                }

                if (FlippedX ^ FlippedY)
                {
                    DoorOperationTypeString = ReverseDoorStyleOperation(DoorOperationTypeString);
                }

                if (String.Compare(DoorOperationTypeString, "USERDEFINED", true) == 0)
                {
                    string userDefinedOperationType;
                    ParameterUtil.GetStringValueFromElementOrSymbol(doorType, "UserDefinedOperationType", out userDefinedOperationType);
                    if (!string.IsNullOrEmpty(userDefinedOperationType))
                    {
                        UserDefinedOperationType = userDefinedOperationType;
                    }
                    else
                    {
                        DoorOperationTypeString = "NOTDEFINED";   //re-set to NotDefined if operation type is set to UserDefined but the userDefinedOperationType parameter is empty!
                    }
                }
            }

            if (HasRealWallHost)
            {
                // do hingeside calculation
                Wall wall = HostObject as Wall;
                PosHingeSide = true;

                BoundingBoxXYZ  famBBox     = null;
                Options         options     = GeometryUtil.GetIFCExportGeometryOptions();
                GeometryElement geomElement = famInst.GetOriginalGeometry(options);
                if (geomElement != null)
                {
                    famBBox = geomElement.GetBoundingBox();
                }

                if (famBBox != null)
                {
                    XYZ bboxCtr = trf.OfPoint((famBBox.Min + famBBox.Max) / 2.0);

                    Curve curve = WallExporter.GetWallAxis(wall);

                    XYZ wallZDir = WallExporter.GetWallHeightDirection(wall);

                    // famInst.HostParameter will fail if FamilyPlacementType is WorkPlaneBased, regardless of whether or not the reported host is a Wall.
                    // In this case, just use the start parameter of the curve.
                    bool   hasHostParameter = famInst.Symbol.Family.FamilyPlacementType != FamilyPlacementType.WorkPlaneBased;
                    double param            = hasHostParameter ? famInst.HostParameter : curve.GetEndParameter(0);

                    Transform wallTrf  = curve.ComputeDerivatives(param, false);
                    XYZ       wallOrig = wallTrf.Origin;
                    XYZ       wallXDir = wallTrf.BasisX;
                    XYZ       wallYDir = wallZDir.CrossProduct(wallXDir);

                    double eps = MathUtil.Eps();

                    bboxCtr     -= wallOrig;
                    PosHingeSide = (bboxCtr.DotProduct(wallYDir) > -eps);

                    XYZ famInstYDir = trf.BasisY;
                    FlippedSymbol = (PosHingeSide != (wallYDir.DotProduct(famInstYDir) > -eps));
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Exports curtain object as container.
        /// </summary>
        /// <param name="allSubElements">
        /// Collection of elements contained in the host curtain element.
        /// </param>
        /// <param name="wallElement">
        /// The curtain wall element.
        /// </param>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="productWrapper">
        /// The ProductWrapper.
        /// </param>
        public static void ExportCurtainObjectCommonAsContainer(ICollection <ElementId> allSubElements, Element wallElement,
                                                                ExporterIFC exporterIFC, ProductWrapper origWrapper, PlacementSetter currSetter)
        {
            if (wallElement == null)
            {
                return;
            }

            string overrideCADLayer = null;

            ParameterUtil.GetStringValueFromElementOrSymbol(wallElement, "IFCCadLayer", out overrideCADLayer);

            using (ExporterStateManager.CADLayerOverrideSetter layerSetter = new ExporterStateManager.CADLayerOverrideSetter(overrideCADLayer))
            {
                HashSet <ElementId> alreadyVisited = new HashSet <ElementId>(); // just in case.
                Options             geomOptions    = GeometryUtil.GetIFCExportGeometryOptions();
                {
                    foreach (ElementId subElemId in allSubElements)
                    {
                        using (ProductWrapper productWrapper = ProductWrapper.Create(origWrapper))
                        {
                            Element subElem = wallElement.Document.GetElement(subElemId);
                            if (subElem == null)
                            {
                                continue;
                            }

                            if (alreadyVisited.Contains(subElem.Id))
                            {
                                continue;
                            }
                            alreadyVisited.Add(subElem.Id);

                            // Respect element visibility settings.
                            if (!ElementFilteringUtil.CanExportElement(exporterIFC, subElem, false) || !ElementFilteringUtil.IsElementVisible(subElem))
                            {
                                continue;
                            }

                            GeometryElement geomElem = subElem.get_Geometry(geomOptions);
                            if (geomElem == null)
                            {
                                continue;
                            }

                            try
                            {
                                if (subElem is FamilyInstance)
                                {
                                    string            ifcEnumType;
                                    IFCExportInfoPair exportType = ExporterUtil.GetExportType(exporterIFC, subElem, out ifcEnumType);

                                    if (subElem is Mullion)
                                    {
                                        if (ExporterCacheManager.ExportOptionsCache.ExportAs2x2)
                                        {
                                            ProxyElementExporter.Export(exporterIFC, subElem, geomElem, productWrapper);
                                        }
                                        else
                                        {
                                            IFCAnyHandle currLocalPlacement = currSetter.LocalPlacement;

                                            if (exportType.ExportInstance == IFCEntityType.IfcCurtainWall)
                                            {
                                                // By default, panels and mullions are set to the same category as their parent.  In this case,
                                                // ask to get the exportType from the category id, since we don't want to inherit the parent class.
                                                exportType.SetValueWithPair(IFCEntityType.IfcMemberType);
                                                ifcEnumType = "MULLION";
                                            }

                                            FamilyInstanceExporter.ExportFamilyInstanceAsMappedItem(exporterIFC, subElem as Mullion, exportType, ifcEnumType, productWrapper,
                                                                                                    ElementId.InvalidElementId, null, currLocalPlacement);
                                        }
                                    }
                                    else
                                    {
                                        FamilyInstance subFamInst = subElem as FamilyInstance;

                                        if (exportType.ExportInstance == IFCEntityType.IfcCurtainWall)
                                        {
                                            // By default, panels and mullions are set to the same category as their parent.  In this case,
                                            // ask to get the exportType from the category id, since we don't want to inherit the parent class.
                                            ElementId catId = CategoryUtil.GetSafeCategoryId(subElem);
                                            exportType = ElementFilteringUtil.GetExportTypeFromCategoryId(catId, out ifcEnumType);
                                        }


                                        if (ExporterCacheManager.ExportOptionsCache.ExportAs2x2)
                                        {
                                            if ((exportType.ExportInstance == IFCEntityType.UnKnown) ||
                                                (exportType.ExportInstance == IFCEntityType.IfcPlate) ||
                                                (exportType.ExportInstance == IFCEntityType.IfcMember))
                                            {
                                                exportType.SetValueWithPair(IFCEntityType.IfcBuildingElementProxy);
                                            }
                                        }
                                        else
                                        {
                                            if (exportType.ExportInstance == IFCEntityType.UnKnown)
                                            {
                                                ifcEnumType = "CURTAIN_PANEL";
                                                exportType.SetValueWithPair(IFCEntityType.IfcPlateType);
                                            }
                                        }

                                        IFCAnyHandle currLocalPlacement = currSetter.LocalPlacement;
                                        using (IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData())
                                        {
                                            FamilyInstanceExporter.ExportFamilyInstanceAsMappedItem(exporterIFC, subFamInst, exportType, ifcEnumType, productWrapper,
                                                                                                    ElementId.InvalidElementId, null, currLocalPlacement);
                                        }
                                    }
                                }
                                else if (subElem is CurtainGridLine)
                                {
                                    ProxyElementExporter.Export(exporterIFC, subElem, geomElem, productWrapper);
                                }
                                else if (subElem is Wall)
                                {
                                    WallExporter.ExportWall(exporterIFC, null, subElem, null, geomElem, productWrapper);
                                }
                            }
                            catch (Exception ex)
                            {
                                if (ExporterUtil.IsFatalException(wallElement.Document, ex))
                                {
                                    throw ex;
                                }
                                continue;
                            }
                        }
                    }
                }
            }
        }