private static IfcNamedUnit resolveUnit(IIfcPhysicalQuantity quan)
        {
            IEntityCollection ifcModel = quan.Model.Instances;

            if (quan is IfcQuantityLength)
            {
                IfcQuantityLength ifcValue = (IfcQuantityLength)quan;
                return(ifcValue.Unit != null
                    ? ifcValue.Unit
                    : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.LENGTHUNIT)));
            }
            else if (quan is IfcQuantityArea)
            {
                IfcQuantityArea ifcValue = (IfcQuantityArea)quan;
                return(ifcValue.Unit != null
                    ? ifcValue.Unit
                    : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.AREAUNIT)));
            }
            else if (quan is IfcQuantityVolume)
            {
                IfcQuantityVolume ifcValue = (IfcQuantityVolume)quan;
                return(ifcValue.Unit != null
                    ? ifcValue.Unit
                    : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.VOLUMEUNIT)));
            }
            else if (quan is IfcQuantityTime)
            {
                IfcQuantityTime ifcValue = (IfcQuantityTime)quan;
                return(ifcValue.Unit != null
                    ? ifcValue.Unit
                    : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.TIMEUNIT)));
            }
            else if (quan is IfcQuantityWeight)
            {
                IfcQuantityWeight ifcValue = (IfcQuantityWeight)quan;
                return(ifcValue.Unit != null
                    ? ifcValue.Unit
                    : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.MASSUNIT)));
            }
            else if (quan is IfcQuantityCount)
            {
                IfcQuantityCount ifcValue = (IfcQuantityCount)quan;
                return(ifcValue.Unit);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
 BbQuantityRequired()
 {
     IfcQuantityCount = new IfcQuantityCount
                            {
                                Name = "Quantity",
                                CountValue = 0,
                            };
     IfcElementQuantity = new IfcElementQuantity
                              {
                                  GlobalId = IfcGloballyUniqueId.NewGuid(),
                                  OwnerHistory = BbHeaderSetting.Setting3D.IfcOwnerHistory,
                                  Quantities = new List<IfcPhysicalQuantity>{IfcQuantityCount},
                              };
     IfcRelDefinesByProperties = new IfcRelDefinesByProperties
                                     {
                                         GlobalId = IfcGloballyUniqueId.NewGuid(),
                                         OwnerHistory = BbHeaderSetting.Setting3D.IfcOwnerHistory,
                                         RelatedObjects = new List<IfcObject>(),
                                         RelatingPropertyDefinition = IfcElementQuantity,
                                     };
 }
예제 #3
0
 BbQuantityRequired()
 {
     IfcQuantityCount = new IfcQuantityCount
     {
         Name       = "Quantity",
         CountValue = 0,
     };
     IfcElementQuantity = new IfcElementQuantity
     {
         GlobalId     = IfcGloballyUniqueId.NewGuid(),
         OwnerHistory = BbHeaderSetting.Setting3D.IfcOwnerHistory,
         Quantities   = new List <IfcPhysicalQuantity> {
             IfcQuantityCount
         },
     };
     IfcRelDefinesByProperties = new IfcRelDefinesByProperties
     {
         GlobalId                   = IfcGloballyUniqueId.NewGuid(),
         OwnerHistory               = BbHeaderSetting.Setting3D.IfcOwnerHistory,
         RelatedObjects             = new List <IfcObject>(),
         RelatingPropertyDefinition = IfcElementQuantity,
     };
 }
 private static IfcUnit resolveUnit(IIfcPhysicalQuantity quan)
 {
     if (quan is IfcQuantityLength)
     {
         IfcQuantityLength ifcValue = (IfcQuantityLength)quan;
         return(ifcValue.Unit);
     }
     else if (quan is IfcQuantityArea)
     {
         IfcQuantityArea ifcValue = (IfcQuantityArea)quan;
         return(ifcValue.Unit);
     }
     else if (quan is IfcQuantityVolume)
     {
         IfcQuantityVolume ifcValue = (IfcQuantityVolume)quan;
         return(ifcValue.Unit);
     }
     else if (quan is IfcQuantityTime)
     {
         IfcQuantityTime ifcValue = (IfcQuantityTime)quan;
         return(ifcValue.Unit);
     }
     else if (quan is IfcQuantityWeight)
     {
         IfcQuantityWeight ifcValue = (IfcQuantityWeight)quan;
         return(ifcValue.Unit);
     }
     else if (quan is IfcQuantityCount)
     {
         IfcQuantityCount ifcValue = (IfcQuantityCount)quan;
         return(ifcValue.Unit);
     }
     else
     {
         return(null);
     }
 }
 private static IfcValue resolveValue(IIfcPhysicalQuantity quan)
 {
     if (quan is IfcQuantityLength)
     {
         IfcQuantityLength ifcValue = (IfcQuantityLength)quan;
         return(new IfcLengthMeasure(ifcValue.LengthValue.ToString()));
     }
     else if (quan is IfcQuantityArea)
     {
         IfcQuantityArea ifcValue = (IfcQuantityArea)quan;
         return(new IfcAreaMeasure(ifcValue.AreaValue.ToString()));
     }
     else if (quan is IfcQuantityVolume)
     {
         IfcQuantityVolume ifcValue = (IfcQuantityVolume)quan;
         return(new IfcVolumeMeasure(ifcValue.VolumeValue.ToString()));
     }
     else if (quan is IfcQuantityTime)
     {
         IfcQuantityTime ifcValue = (IfcQuantityTime)quan;
         return(new IfcTimeMeasure(ifcValue.TimeValue.ToString()));
     }
     else if (quan is IfcQuantityWeight)
     {
         IfcQuantityWeight ifcValue = (IfcQuantityWeight)quan;
         return(new IfcMassMeasure(ifcValue.WeightValue));
     }
     else if (quan is IfcQuantityCount)
     {
         IfcQuantityCount ifcValue = (IfcQuantityCount)quan;
         return(new IfcCountMeasure(ifcValue.CountValue.ToString()));
     }
     else
     {
         return(null);
     }
 }
예제 #6
0
        private static void CreateElementQuantity(XbimModel model, IfcWallStandardCase wall, IfcOwnerHistory ifcOwnerHistory)
        {
            //Create a IfcElementQuantity
            //first we need a IfcPhysicalSimpleQuantity,first will use IfcQuantityArea
            IfcQuantityArea ifcQuantityArea = model.Instances.New <IfcQuantityArea>(qa =>
            {
                qa.Name        = "IfcQuantityArea:Area";
                qa.Description = "";
                qa.Unit        = model.Instances.New <IfcSIUnit>(siu =>
                {
                    siu.UnitType   = IfcUnitEnum.AREAUNIT;
                    siu.Prefix     = IfcSIPrefix.MILLI;
                    siu.Name       = IfcSIUnitName.SQUARE_METRE;
                    siu.Dimensions = model.Instances.New <IfcDimensionalExponents>(de =>
                    {
                        de.LengthExponent                   = 1;
                        de.MassExponent                     = 0;
                        de.TimeExponent                     = 0;
                        de.ElectricCurrentExponent          = 0;
                        de.ThermodynamicTemperatureExponent = 0;
                        de.AmountOfSubstanceExponent        = 0;
                        de.LuminousIntensityExponent        = 0;
                    });
                });
                qa.AreaValue = 100.0;
            });
            //next quantity IfcQuantityCount using IfcContextDependentUnit
            IfcContextDependentUnit ifcContextDependentUnit = model.Instances.New <IfcContextDependentUnit>(cd =>
            {
                cd.Dimensions = model.Instances.New <IfcDimensionalExponents>(de =>
                {
                    de.LengthExponent                   = 1;
                    de.MassExponent                     = 0;
                    de.TimeExponent                     = 0;
                    de.ElectricCurrentExponent          = 0;
                    de.ThermodynamicTemperatureExponent = 0;
                    de.AmountOfSubstanceExponent        = 0;
                    de.LuminousIntensityExponent        = 0;
                });
                cd.UnitType = IfcUnitEnum.LENGTHUNIT;
                cd.Name     = "Elephants";
            });
            IfcQuantityCount ifcQuantityCount = model.Instances.New <IfcQuantityCount>(qc =>
            {
                qc.Name       = "IfcQuantityCount:Elephant";
                qc.CountValue = 12;
                qc.Unit       = ifcContextDependentUnit;
            });


            //next quantity IfcQuantityLength using IfcConversionBasedUnit
            IfcConversionBasedUnit ifcConversionBasedUnit = model.Instances.New <IfcConversionBasedUnit>(cbu =>
            {
                cbu.ConversionFactor = model.Instances.New <IfcMeasureWithUnit>(mu =>
                {
                    mu.ValueComponent = new IfcRatioMeasure(25.4);
                    mu.UnitComponent  = model.Instances.New <IfcSIUnit>(siu =>
                    {
                        siu.UnitType = IfcUnitEnum.LENGTHUNIT;
                        siu.Prefix   = IfcSIPrefix.MILLI;
                        siu.Name     = IfcSIUnitName.METRE;
                    });
                });
                cbu.Dimensions = model.Instances.New <IfcDimensionalExponents>(de =>
                {
                    de.LengthExponent                   = 1;
                    de.MassExponent                     = 0;
                    de.TimeExponent                     = 0;
                    de.ElectricCurrentExponent          = 0;
                    de.ThermodynamicTemperatureExponent = 0;
                    de.AmountOfSubstanceExponent        = 0;
                    de.LuminousIntensityExponent        = 0;
                });
                cbu.UnitType = IfcUnitEnum.LENGTHUNIT;
                cbu.Name     = "Inch";
            });
            IfcQuantityLength ifcQuantityLength = model.Instances.New <IfcQuantityLength>(qa =>
            {
                qa.Name        = "IfcQuantityLength:Length";
                qa.Description = "";
                qa.Unit        = ifcConversionBasedUnit;
                qa.LengthValue = 24.0;
            });

            //lets create the IfcElementQuantity
            IfcElementQuantity ifcElementQuantity = model.Instances.New <IfcElementQuantity>(eq =>
            {
                eq.OwnerHistory = ifcOwnerHistory;
                eq.Name         = "Test:IfcElementQuantity";
                eq.Description  = "Measurement quantity";
                eq.Quantities.Add(ifcQuantityArea);
                eq.Quantities.Add(ifcQuantityCount);
                eq.Quantities.Add(ifcQuantityLength);
            });

            //need to create the relationship
            IfcRelDefinesByProperties ifcRelDefinesByProperties = model.Instances.New <IfcRelDefinesByProperties>(rdbp =>
            {
                rdbp.OwnerHistory = ifcOwnerHistory;
                rdbp.Name         = "Area Association";
                rdbp.Description  = "IfcElementQuantity associated to wall";
                rdbp.RelatedObjects.Add(wall);
                rdbp.RelatingPropertyDefinition = ifcElementQuantity;
            });
        }