Пример #1
0
        /// <summary>
        /// Converts a list of vectors from the units from an IFC file to the corresponding Revit internal units.
        /// </summary>
        /// <param name="specTypeId">Identifier of the spec for this value.</param>
        /// <param name="inValue">The value to convert.</param>
        /// <returns>The result value in Revit internal units.</returns>
        /// <remarks>Note that the OffsetFactor is ignored.</remarks>
        static public void ProjectScale(ForgeTypeId specTypeId, IList <XYZ> inValues)
        {
            if (inValues == null)
            {
                return;
            }

            IFCUnit projectUnit = IFCImportFile.TheFile.IFCUnits.GetIFCProjectUnit(specTypeId);

            if (projectUnit == null)
            {
                return;
            }

            double factor = projectUnit.ScaleFactor;

            if (MathUtil.IsAlmostEqual(factor, 1.0))
            {
                return;
            }

            int count = inValues.Count;

            for (int ii = 0; ii < count; ii++)
            {
                inValues[ii] *= factor;
            }
        }
Пример #2
0
        /// <summary>
        /// Converts a vector from the units from an IFC file to the corresponding Revit internal units.
        /// </summary>
        /// <param name="inValue">The value to convert.</param>
        /// <returns>The result value in Revit internal units.</returns>
        /// <remarks>Note that the OffsetFactor is ignored.</remarks>
        static public XYZ ScaleLength(XYZ inValue)
        {
            IFCUnit projectUnit = IFCImportFile.TheFile.IFCUnits.GetIFCProjectUnit(SpecTypeId.Length);

            if (projectUnit != null)
            {
                return(inValue * projectUnit.ScaleFactor);
            }

            return(inValue);
        }
Пример #3
0
        /// <summary>
        /// Converts a value from the units from an IFC file to the corresponding Revit internal units.
        /// </summary>
        /// <param name="specTypeId">Identifier of the spec for this value.</param>
        /// <param name="inValue">The value to convert.</param>
        /// Some units we really always want in the standard document units.
        /// For example, angles in Radians.
        /// </param>
        /// <returns>The result value in Revit internal units.</returns>
        static private double ProjectScale(ForgeTypeId specTypeId, double inValue)
        {
            IFCUnit projectUnit = IFCImportFile.TheFile.IFCUnits.GetIFCProjectUnit(specTypeId);

            if (projectUnit != null)
            {
                return(inValue * projectUnit.ScaleFactor - projectUnit.OffsetFactor);
            }

            return(inValue);
        }
Пример #4
0
        /// <summary>
        /// Converts a value from default unit to the project unit.
        /// </summary>
        /// <param name="unitType">The unit type.</param>
        /// <param name="inValue">The value to convert.</param>
        /// <returns>The result value.</returns>
        /// <remarks>Note the the OffsetFactor is ignored, as it is irrelevant for a location.</remarks>
        static public XYZ ProjectScale(UnitType unitType, XYZ inValue)
        {
            IFCUnit projectUnit = IFCImportFile.TheFile.IFCUnits.GetIFCProjectUnit(unitType);

            if (projectUnit != null)
            {
                return(inValue * projectUnit.ScaleFactor);
            }

            return(inValue);
        }
Пример #5
0
        private IFCAnyHandle CreateSIUnit(IFCFile file, UnitType? unitType, IFCUnit ifcUnitType, IFCSIUnitName unitName, IFCSIPrefix? prefix, DisplayUnitType? dut)
        {
            IFCAnyHandle siUnit = IFCInstanceExporter.CreateSIUnit(file, ifcUnitType, prefix, unitName);
            if (unitType.HasValue && dut.HasValue)
            {
                double scaleFactor = UnitUtils.ConvertFromInternalUnits(1.0, dut.Value);
                ExporterCacheManager.UnitsCache.AddUnit(unitType.Value, siUnit, scaleFactor, 0.0);
            }

            return siUnit;
        }
      /// <summary>
      /// Creates a handle representing an IfcConversionBasedUnit and assigns it to the file.
      /// </summary>
      /// <param name="file">The file.</param>
      /// <param name="dimensions">The dimensional exponents of the SI base units by which the named unit is defined.</param>
      /// <param name="unitType">The type of the unit.</param>
      /// <param name="name">The word, or group of words, by which the conversion based unit is referred to.</param>
      /// <param name="conversionFactor">The physical quantity from which the converted unit is derived.</param>
      /// <returns>The handle.</returns>
      public static IFCAnyHandle CreateConversionBasedUnit(IFCFile file, IFCAnyHandle dimensions, IFCUnit unitType,
          string name, IFCAnyHandle conversionFactor)
      {
         ValidateNamedUnit(dimensions, unitType);

         IFCAnyHandleUtil.ValidateSubTypeOf(conversionFactor, false, IFCEntityType.IfcMeasureWithUnit);

         IFCAnyHandle conversionBasedUnit = CreateInstance(file, IFCEntityType.IfcConversionBasedUnit);
         IFCAnyHandleUtil.SetAttribute(conversionBasedUnit, "Name", name);
         IFCAnyHandleUtil.SetAttribute(conversionBasedUnit, "ConversionFactor", conversionFactor);
         SetNamedUnit(conversionBasedUnit, dimensions, unitType);
         return conversionBasedUnit;
      }
 /// <summary>
 /// Creates a handle representing an IfcSIUnit and assigns it to the file.
 /// </summary>
 /// <param name="file">The file.</param>
 /// <param name="unitType">The type of the unit.</param>
 /// <param name="prefix">The SI Prefix for defining decimal multiples and submultiples of the unit.</param>
 /// <param name="name">The word, or group of words, by which the SI unit is referred to.</param>
 /// <returns>The handle.</returns>
 public static IFCAnyHandle CreateSIUnit(IFCFile file, IFCUnit unitType, IFCSIPrefix? prefix,
     IFCSIUnitName name)
 {
    IFCAnyHandle siUnit = CreateInstance(file, IFCEntityType.IfcSIUnit);
    IFCAnyHandleUtil.SetAttribute(siUnit, "Prefix", prefix);
    IFCAnyHandleUtil.SetAttribute(siUnit, "Name", name);
    SetNamedUnit(siUnit, null, unitType);
    return siUnit;
 }
 /// <summary>
 /// Sets attributes to IfcNamedUnit.
 /// </summary>
 /// <param name="namedUnit">The IfcNamedUnit.</param>
 /// <param name="dimensions">The dimensions.</param>
 /// <param name="unitType">The type of the unit.</param>
 private static void SetNamedUnit(IFCAnyHandle namedUnit, IFCAnyHandle dimensions, IFCUnit unitType)
 {
    IFCAnyHandleUtil.SetAttribute(namedUnit, "Dimensions", dimensions);
    IFCAnyHandleUtil.SetAttribute(namedUnit, "UnitType", unitType);
 }
 /// <summary>
 /// Validates the values to be set to IfcNamedUnit.
 /// </summary>
 /// <param name="dimensions">The dimensions.</param>
 /// <param name="unitType">The type of the unit.</param>
 private static void ValidateNamedUnit(IFCAnyHandle dimensions, IFCUnit unitType)
 {
    IFCAnyHandleUtil.ValidateSubTypeOf(dimensions, false, IFCEntityType.IfcDimensionalExponents);
 }
Пример #10
0
 private IFCAnyHandle CreateSIUnit(IFCFile file, IFCUnit ifcUnitType, IFCSIUnitName unitName, IFCSIPrefix? prefix)
 {
     IFCAnyHandle siUnit = IFCInstanceExporter.CreateSIUnit(file, ifcUnitType, prefix, unitName);
     return siUnit;
 }