示例#1
0
        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
        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
        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));
                }
            }
        }