当前位置: 首页>>代码示例>>C#>>正文


C# IFCAnyHandle.GetAttribute方法代码示例

本文整理汇总了C#中IFCAnyHandle.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# IFCAnyHandle.GetAttribute方法的具体用法?C# IFCAnyHandle.GetAttribute怎么用?C# IFCAnyHandle.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IFCAnyHandle的用法示例。


在下文中一共展示了IFCAnyHandle.GetAttribute方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessIFCPropertyReferenceValue

 /// <summary>
 /// Processes an IFC property reference value.
 /// </summary>
 /// <param name="propertyReferenceValue">The IfcPropertyReferenceValue object.</param>
 void ProcessIFCPropertyReferenceValue(IFCAnyHandle propertyReferenceValue)
 {
     IFCData referenceValue = propertyReferenceValue.GetAttribute("PropertyReference");
     IFCPropertyValues.Add(new IFCPropertyValue(this, referenceValue));
 }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:9,代码来源:IFCSimpleProperty.cs

示例2: Process

        override protected void Process(IFCAnyHandle item)
        {
            base.Process(item);

            IFCAnyHandle surfaceColour = IFCImportHandleUtil.GetRequiredInstanceAttribute(item, "SurfaceColour", false);
            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(surfaceColour))
                m_SurfaceColour = IFCColourRgb.ProcessIFCColourRgb(surfaceColour);

            if (IFCAnyHandleUtil.IsSubTypeOf(item, IFCEntityType.IfcSurfaceStyleRendering))
            {
                Transparency = IFCImportHandleUtil.GetOptionalNormalisedRatioAttribute(item, "Transparency", 0.0);

                IFCData diffuseColour = item.GetAttribute("DiffuseColour");
                if (diffuseColour.PrimitiveType == IFCDataPrimitiveType.Instance)
                    m_DiffuseColour = IFCColourRgb.ProcessIFCColourRgb(diffuseColour.AsInstance());
                else if (diffuseColour.PrimitiveType == IFCDataPrimitiveType.Double)
                    m_DiffuseColourFactor = diffuseColour.AsDouble();

                IFCData transmissionColour = item.GetAttribute("TransmissionColour");
                if (transmissionColour.PrimitiveType == IFCDataPrimitiveType.Instance)
                    m_TransmissionColour = IFCColourRgb.ProcessIFCColourRgb(transmissionColour.AsInstance());
                else if (transmissionColour.PrimitiveType == IFCDataPrimitiveType.Double)
                    m_TransmissionColourFactor = transmissionColour.AsDouble();

                IFCData diffuseTransmissionColour = item.GetAttribute("DiffuseTransmissionColour");
                if (transmissionColour.PrimitiveType == IFCDataPrimitiveType.Instance)
                    m_DiffuseTransmissionColour = IFCColourRgb.ProcessIFCColourRgb(diffuseTransmissionColour.AsInstance());
                else if (transmissionColour.PrimitiveType == IFCDataPrimitiveType.Double)
                    m_DiffuseTransmissionColourFactor = diffuseTransmissionColour.AsDouble();

                IFCData reflectionColour = item.GetAttribute("ReflectionColour");
                if (reflectionColour.PrimitiveType == IFCDataPrimitiveType.Instance)
                    m_ReflectionColour = IFCColourRgb.ProcessIFCColourRgb(reflectionColour.AsInstance());
                else if (reflectionColour.PrimitiveType == IFCDataPrimitiveType.Double)
                    m_ReflectionColourFactor = reflectionColour.AsDouble();

                IFCData specularColour = item.GetAttribute("SpecularColour");
                if (specularColour.PrimitiveType == IFCDataPrimitiveType.Instance)
                    m_SpecularColour = IFCColourRgb.ProcessIFCColourRgb(specularColour.AsInstance());
                else if (specularColour.PrimitiveType == IFCDataPrimitiveType.Double)
                    m_SpecularColourFactor = specularColour.AsDouble();

                IFCData specularHighlight = item.GetAttribute("SpecularHighlight");
                if (specularHighlight.PrimitiveType == IFCDataPrimitiveType.Double)
                {
                    try
                    {
                        string simpleType = specularHighlight.GetSimpleType();
                        if (string.Compare(simpleType, "IfcSpecularExponent", true) == 0)
                            m_SpecularExponent = specularHighlight.AsDouble();
                        else if (string.Compare(simpleType, "IfcSpecularRoughness", true) == 0)
                            m_SpecularRoughness = specularHighlight.AsDouble();
                        else
                            IFCImportFile.TheLog.LogError(item.StepId, "Unknown type of specular highlight, ignoring.", false);
                    }
                    catch
                    {
                        IFCImportFile.TheLog.LogError(item.StepId, "Unspecified type of specular highlight, ignoring.", false);
                    }
                }
                else if (specularHighlight.HasValue)
                {
                    IFCImportFile.TheLog.LogError(item.StepId, "Unknown type of specular highlight, ignoring.", false);
                }
            }
        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:66,代码来源:IFCSurfaceStyleShading.cs

示例3: ProcessIFCPropertySingleValue

 /// <summary>
 /// Processes an IFC property single value.
 /// </summary>
 /// <param name="propertySingleValue">The IfcPropertySingleValue object.</param>
 void ProcessIFCPropertySingleValue(IFCAnyHandle propertySingleValue)
 {
     IFCPropertyValues.Add(new IFCPropertyValue(this, propertySingleValue.GetAttribute("NominalValue")));
     ProcessIFCSimplePropertyUnit(this, propertySingleValue);
 }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:9,代码来源:IFCSimpleProperty.cs

示例4: AssociateClassificationReference

        /// <summary>
        /// Create association (IfcRelAssociatesClassification) between the Element (ElemHnd) and specified classification reference
        /// </summary>
        /// <param name="exporterIFC">The exporterIFC class.</param>
        /// <param name="file">The IFC file class.</param>
        /// <param name="elemHnd">The corresponding IFC entity handle.</param>
        /// <param name="classificationReference">The classification reference to be associated with</param>
        public static void AssociateClassificationReference(ExporterIFC exporterIFC, IFCFile file, IFCAnyHandle elemHnd, IFCAnyHandle classificationReference)
        {
            HashSet<IFCAnyHandle> relatedObjects = new HashSet<IFCAnyHandle>();
            relatedObjects.Add(elemHnd);

            IFCAnyHandle relAssociates = IFCInstanceExporter.CreateRelAssociatesClassification(file, GUIDUtil.CreateGUID(),
               exporterIFC.GetOwnerHistoryHandle(), classificationReference.GetAttribute("ReferencedSource").ToString() + " Classification", "", relatedObjects, classificationReference);

        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:16,代码来源:ClassificationUtil.cs

示例5: Process

        /// <summary>
        /// Processes an IFC physical simple quantity.
        /// </summary>
        /// <param name="ifcPhysicalQuantity">The IfcPhysicalSimpleQuantity object.</param>
        /// <returns>The IFCPhysicalSimpleQuantity object.</returns>
        override protected void Process(IFCAnyHandle ifcPhysicalSimpleQuantity)
        {
            base.Process(ifcPhysicalSimpleQuantity);

            IFCAnyHandle unit = IFCImportHandleUtil.GetOptionalInstanceAttribute(ifcPhysicalSimpleQuantity, "Unit");
            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(unit))
                IFCUnit = IFCUnit.ProcessIFCUnit(unit);

            // Process subtypes of IfcPhysicalSimpleQuantity here.
            string attributeName = ifcPhysicalSimpleQuantity.TypeName.Substring(11) + "Value";
            Value = ifcPhysicalSimpleQuantity.GetAttribute(attributeName);
            BaseUnitType = IFCDataUtil.GetUnitTypeFromData(Value, UnitType.UT_Undefined);
            
            if (BaseUnitType == UnitType.UT_Undefined)
            {
                // Determine it from the attributeName.
                if (string.Compare(attributeName, "LengthValue", true) == 0)
                    BaseUnitType = UnitType.UT_Length;
                else if (string.Compare(attributeName, "AreaValue", true) == 0)
                    BaseUnitType = UnitType.UT_Area;
                else if (string.Compare(attributeName, "VolumeValue", true) == 0)
                    BaseUnitType = UnitType.UT_Volume;
                else if (string.Compare(attributeName, "CountValue", true) == 0)
                    BaseUnitType = UnitType.UT_Number;
                else if (string.Compare(attributeName, "WeightValue", true) == 0)
                    BaseUnitType = UnitType.UT_Mass;
                else if (string.Compare(attributeName, "TimeValue", true) == 0)
                    BaseUnitType = UnitType.UT_Number;  // No time unit type in Revit.
                else
                {
                    Importer.TheLog.LogWarning(Id, "Can't determine unit type for IfcPhysicalSimpleQuantity of type: " + attributeName, true);
                    BaseUnitType = UnitType.UT_Number;
                }
            }


            if (IFCUnit == null)
                IFCUnit = IFCImportFile.TheFile.IFCUnits.GetIFCProjectUnit(BaseUnitType);
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:44,代码来源:IFCPhysicalSimpleQuantity.cs

示例6: Process

      protected override void Process(IFCAnyHandle ifcCurve)
      {
         base.Process(ifcCurve);

         bool found = false;

         bool sameSense = IFCImportHandleUtil.GetRequiredBooleanAttribute(ifcCurve, "SenseAgreement", out found);
         if (!found)
            sameSense = true;

         IFCAnyHandle basisCurve = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcCurve, "BasisCurve", true);
         IFCCurve ifcBasisCurve = IFCCurve.ProcessIFCCurve(basisCurve);
         if (ifcBasisCurve == null || (ifcBasisCurve.Curve == null && ifcBasisCurve.CurveLoop == null))
         {
            // LOG: ERROR: Error processing BasisCurve # for IfcTrimmedCurve #.
            return;
         }
         if (ifcBasisCurve.Curve == null)
         {
            // LOG: ERROR: Expected a single curve, not a curve loop for BasisCurve # for IfcTrimmedCurve #.
            return;
         }

         IFCData trim1 = ifcCurve.GetAttribute("Trim1");
         if (trim1.PrimitiveType != IFCDataPrimitiveType.Aggregate)
         {
            // LOG: ERROR: Invalid data type for Trim1 attribute for IfcTrimmedCurve #.
            return;
         }
         IFCData trim2 = ifcCurve.GetAttribute("Trim2");
         if (trim2.PrimitiveType != IFCDataPrimitiveType.Aggregate)
         {
            // LOG: ERROR: Invalid data type for Trim1 attribute for IfcTrimmedCurve #.
            return;
         }

         IFCTrimmingPreference trimPreference = IFCEnums.GetSafeEnumerationAttribute<IFCTrimmingPreference>(ifcCurve, "MasterRepresentation", IFCTrimmingPreference.Parameter);

         double param1 = 0.0, param2 = 0.0;
         try
         {
            GetTrimParameters(trim1, trim2, ifcBasisCurve, trimPreference, out param1, out param2);
         }
         catch (Exception ex)
         {
            Importer.TheLog.LogError(ifcCurve.StepId, ex.Message, false);
            return;
         }

         Curve baseCurve = ifcBasisCurve.Curve;
         if (baseCurve.IsCyclic)
         {
            if (!sameSense)
               MathUtil.Swap(ref param1, ref param2);

            if (param2 < param1)
               param2 = MathUtil.PutInRange(param2, param1 + Math.PI, 2 * Math.PI);

            if (param2 - param1 > 2.0 * Math.PI - MathUtil.Eps())
            {
               Importer.TheLog.LogWarning(ifcCurve.StepId, "IfcTrimmedCurve length is greater than 2*PI, leaving unbound.", false);
               Curve = baseCurve;
               return;
            }

            Curve = baseCurve.Clone();

            try
            {
               Curve.MakeBound(param1, param2);
            }
            catch (Exception ex)
            {
               if (ex.Message.Contains("too small"))
               {
                  Curve = null;
                  Importer.TheLog.LogError(Id, "curve length is invalid, ignoring.", false);
                  return;
               }
               else
                  throw ex;
            }
         }
         else
         {
            if (MathUtil.IsAlmostEqual(param1, param2))
            {
               Importer.TheLog.LogError(Id, "Param1 = Param2 for IfcTrimmedCurve #, ignoring.", false);
               return;
            }

            if (param1 > param2 - MathUtil.Eps())
            {
               Importer.TheLog.LogWarning(Id, "Param1 > Param2 for IfcTrimmedCurve #, reversing.", false);
               MathUtil.Swap(ref param1, ref param2);
               return;
            }

            Curve copyCurve = baseCurve.Clone();

//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:101,代码来源:IFCTrimmedCurve.cs

示例7: GetListOfListOfInstanceAttribute

        /// <summary>
        /// Get attribute of type IList of IList of Entity 
        /// </summary>
        /// <param name="handle">The handle</param>
        /// <param name="name">attribute name</param>
        /// <returns>IList of IList of Entity</returns>
        public static IList<IList<IFCAnyHandle>> GetListOfListOfInstanceAttribute(IFCAnyHandle handle, string name)
        {
            if (handle == null)
                throw new ArgumentNullException("handle");

            if (!handle.HasValue)
                throw new ArgumentException("Invalid handle.");

            IList<IList<IFCAnyHandle>> outerList = null;

            IFCData ifcData = handle.GetAttribute(name);

            if (ifcData.PrimitiveType == IFCDataPrimitiveType.Aggregate)
            {
                IFCAggregate outer = ifcData.AsAggregate();
                if (outer != null)
                {
                    outerList = new List<IList<IFCAnyHandle>>();

                    foreach (IFCData outerVal in outer)
                    {
                        IFCAggregate inner = outerVal.AsAggregate();

                        if (inner != null)
                        {
                            IList<IFCAnyHandle> innerList = new List<IFCAnyHandle>();
                            foreach (IFCData innerVal in inner)
                            {
                                innerList.Add(innerVal.AsInstance());
                            }
                            outerList.Add(innerList);
                        }
                    }
                }
            }
            return outerList;
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:43,代码来源:IFCImportHandleUtil.cs

示例8: ProcessIFCTrimmedCurve

        private void ProcessIFCTrimmedCurve(IFCAnyHandle ifcCurve)
        {
            bool found = false;

            bool sameSense = IFCImportHandleUtil.GetRequiredBooleanAttribute(ifcCurve, "SenseAgreement", out found);
            if (!found)
                sameSense = true;

            IFCAnyHandle basisCurve = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcCurve, "BasisCurve", true);
            IFCCurve ifcBasisCurve = IFCCurve.ProcessIFCCurve(basisCurve);
            if (ifcBasisCurve == null || (ifcBasisCurve.Curve == null && ifcBasisCurve.CurveLoop == null))
            {
                // LOG: ERROR: Error processing BasisCurve # for IfcTrimmedCurve #.
                return;
            }
            if (ifcBasisCurve.Curve == null)
            {
                // LOG: ERROR: Expected a single curve, not a curve loop for BasisCurve # for IfcTrimmedCurve #.
                return;
            }

            IFCData trim1 = ifcCurve.GetAttribute("Trim1");
            if (trim1.PrimitiveType != IFCDataPrimitiveType.Aggregate)
            {
                // LOG: ERROR: Invalid data type for Trim1 attribute for IfcTrimmedCurve #.
                return;
            }
            IFCData trim2 = ifcCurve.GetAttribute("Trim2");
            if (trim2.PrimitiveType != IFCDataPrimitiveType.Aggregate)
            {
                // LOG: ERROR: Invalid data type for Trim1 attribute for IfcTrimmedCurve #.
                return;
            }

            string trimPreferenceAsString = IFCAnyHandleUtil.GetEnumerationAttribute(ifcCurve, "MasterRepresentation");
            IFCTrimmingPreference trimPreference = IFCTrimmingPreference.Parameter;
            if (trimPreferenceAsString != null)
                trimPreference = (IFCTrimmingPreference)Enum.Parse(typeof(IFCTrimmingPreference), trimPreferenceAsString, true);

            double param1 = 0.0, param2 = 0.0;
            try
            {
                GetTrimParameters(trim1, trim2, ifcBasisCurve, trimPreference, out param1, out param2);
            }
            catch (Exception ex)
            {
                IFCImportFile.TheLog.LogError(ifcCurve.StepId, ex.Message, false);
                return;
            }

            Curve baseCurve = ifcBasisCurve.Curve;
            if (baseCurve.IsCyclic)
            {
                if (!sameSense)
                    MathUtil.Swap(ref param1, ref param2);

                if (param2 < param1)
                    param2 = MathUtil.PutInRange(param2, param1 + Math.PI, 2 * Math.PI);
                
                if (param2 - param1 > 2.0 * Math.PI - MathUtil.Eps())
                {
                    // LOG: WARNING: #Id: IfcTrimmedCurve length is greater than 2*PI, leaving unbound.
                    Curve = baseCurve;
                    return;
                }

                Curve = baseCurve.Clone();
                Curve.MakeBound(param1, param2);
            }
            else
            {
                if (MathUtil.IsAlmostEqual(param1, param2))
                {
                    // LOG: ERROR: Param1 = Param2 for IfcTrimmedCurve #, ignoring.
                    return;
                }

                if (param1 >  param2 - MathUtil.Eps())
                {
                    // LOG: WARNING: Param1 > Param2 for IfcTrimmedCurve #, reversing.
                    MathUtil.Swap(ref param1, ref param2);
                    return;
                } 
                
                Curve copyCurve = baseCurve.Clone();
                copyCurve.MakeBound(param1, param2);
                if (sameSense)
                {
                    Curve = copyCurve;
                }
                else
                {
                    Curve = copyCurve.CreateReversed();
                }
            }
        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:96,代码来源:IFCCurve.cs

示例9: ProcessIFCMeasureWithUnit

        /// <summary>
        /// Processes measure with unit.
        /// </summary>
        /// <param name="measureUnitHnd">The measure unit handle.</param>
        void ProcessIFCMeasureWithUnit(IFCAnyHandle measureUnitHnd)
        {
            double baseScale = 0.0;

            IFCData ifcData = measureUnitHnd.GetAttribute("ValueComponent");
            if (!ifcData.HasValue)
                throw new InvalidOperationException("#" + measureUnitHnd.StepId + ": Missing required attribute ValueComponent.");

            if (ifcData.PrimitiveType == IFCDataPrimitiveType.Double)
                baseScale = ifcData.AsDouble();
            else if (ifcData.PrimitiveType == IFCDataPrimitiveType.Integer)
                baseScale = (double)ifcData.AsInteger();

            if (MathUtil.IsAlmostZero(baseScale))
                throw new InvalidOperationException("#" + measureUnitHnd.StepId + ": ValueComponent should not be almost zero.");

            IFCAnyHandle unitHnd = IFCImportHandleUtil.GetRequiredInstanceAttribute(measureUnitHnd, "UnitComponent", true);

            IFCUnit unit = ProcessIFCUnit(unitHnd);
            CopyUnit(unit);
            ScaleFactor = unit.ScaleFactor * baseScale;
        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:26,代码来源:IFCUnit.cs

示例10: Process

      /// <summary>
      /// Processes an IFC bounded value property.
      /// </summary>
      /// <param name="ifcPropertyBoundedValue">The IfcPropertyBoundedValue object.</param>
      /// <returns>The IFCPropertyBoundedValue object.</returns>
      override protected void Process(IFCAnyHandle ifcPropertyBoundedValue)
      {
         base.Process(ifcPropertyBoundedValue);

         IFCData lowerBoundValue = ifcPropertyBoundedValue.GetAttribute("LowerBoundValue");
         IFCData upperBoundValue = ifcPropertyBoundedValue.GetAttribute("UpperBoundValue");
         IFCData setPointValue = (IFCImportFile.TheFile.SchemaVersion > IFCSchemaVersion.IFC2x3) ? ifcPropertyBoundedValue.GetAttribute("SetPointValue") : null;

         if (lowerBoundValue != null)
         {
            m_LowerBoundPropertyIndex = IFCPropertyValues.Count;
            IFCPropertyValues.Add(new IFCPropertyValue(this, lowerBoundValue));
         }

         if (upperBoundValue != null)
         {
            m_UpperBoundPropertyIndex = IFCPropertyValues.Count;
            IFCPropertyValues.Add(new IFCPropertyValue(this, upperBoundValue));
         }

         if (setPointValue != null)
         {
            m_SetPointValueIndex = IFCPropertyValues.Count;
            IFCPropertyValues.Add(new IFCPropertyValue(this, setPointValue));
         }

         ProcessIFCSimplePropertyUnit(this, ifcPropertyBoundedValue);
      }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:33,代码来源:IFCPropertyBoundedValue.cs


注:本文中的IFCAnyHandle.GetAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。