Beispiel #1
0
        /// <summary>
        /// Creates a shape representation and register it to shape representation layer.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="categoryId">The category id.</param>
        /// <param name="contextOfItems">The context for which the different subtypes of representation are valid.</param>
        /// <param name="identifier">The identifier for the representation.</param>
        /// <param name="representationType">The type handle for the representation.</param>
        /// <param name="items">Collection of geometric representation items that are defined for this representation.</param>
        /// <returns>The handle.</returns>
        public static IFCAnyHandle CreateShapeRepresentation(ExporterIFC exporterIFC, Element element, ElementId categoryId, IFCAnyHandle contextOfItems,
           string identifier, string representationType, ISet<IFCAnyHandle> items)
        {
            IFCAnyHandle newShapeRepresentation = CreateBaseShapeRepresentation(exporterIFC, contextOfItems, identifier, representationType, items);
            if (IFCAnyHandleUtil.IsNullOrHasNoValue(newShapeRepresentation))
                return newShapeRepresentation;

            // Search for old "IFCCadLayer" or new "IfcPresentationLayer".
            string ifcCADLayer = null;
            if ((ParameterUtil.GetStringValueFromElementOrSymbol(element, "IFCCadLayer", out ifcCADLayer) == null) ||
                string.IsNullOrWhiteSpace(ifcCADLayer))
            {
                if ((ParameterUtil.GetStringValueFromElementOrSymbol(element, "IfcPresentationLayer", out ifcCADLayer) == null) ||
                    string.IsNullOrWhiteSpace(ifcCADLayer))
                {
                    ifcCADLayer = ExporterStateManager.GetCurrentCADLayerOverride();
                }
            }

            // We are using the DWG export layer table to correctly map category to DWG layer for the 
            // IfcPresentationLayerAsssignment, if it is not overridden.
            if (!string.IsNullOrWhiteSpace(ifcCADLayer))
                ExporterCacheManager.PresentationLayerSetCache.AddRepresentationToLayer(ifcCADLayer, newShapeRepresentation);
            else
                exporterIFC.RegisterShapeForPresentationLayer(element, categoryId, newShapeRepresentation);
            
            return newShapeRepresentation;
        }
Beispiel #2
0
        /// <summary>
        /// Checks if element should be exported using a variety of different checks.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="element">The element.</param>
        /// <param name="allowSeparateOpeningExport">True if IfcOpeningElement is allowed to be exported.</param>
        /// <returns>True if the element should be exported, false otherwise.</returns>
        /// <remarks>There are some inefficiencies here, as we later check IfcExportAs in other contexts.  We should attempt to get the value only once.</remarks>
        public static bool ShouldElementBeExported(ExporterIFC exporterIFC, Element element, bool allowSeparateOpeningExport)
        {
            // Allow the ExporterStateManager to say that an element should be exported regardless of settings.
            if (ExporterStateManager.CanExportElementOverride())
            {
                return(true);
            }

            // Check to see if the category should be exported.  This overrides the IfcExportAs parameter.
            if (!ShouldCategoryBeExported(exporterIFC, element, allowSeparateOpeningExport))
            {
                return(false);
            }

            string elementClassName;

            if (IsIFCExportAsSetToDontExport(element, out elementClassName))
            {
                return(false);
            }

            // Check whether the intended Entity type is inside the export exclusion set
            IFCEntityType elementClassTypeEnum;

            return
                (!Enum.TryParse(elementClassName, out elementClassTypeEnum) ||
                 !ExporterCacheManager.ExportOptionsCache.IsElementInExcludeList(elementClassTypeEnum));
        }
 /// <summary>
 /// The constructor that sets the current CAD layer override string.  Will do nothing if the string in invalid or null.
 /// </summary>
 /// <param name="overrideString">The value.</param>
 public CADLayerOverrideSetter(string overrideString)
 {
     if (!string.IsNullOrWhiteSpace(overrideString))
     {
         ExporterStateManager.PushCADLayerOverride(overrideString);
         m_ValidString = true;
     }
 }
Beispiel #4
0
        /// <summary>
        /// Checks if element should be exported using a variety of different checks.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC object.</param>
        /// <param name="element">The element.</param>
        /// <param name="allowSeparateOpeningExport">True if IfcOpeningElement is allowed to be exported.</param>
        /// <returns>True if the element should be exported, false otherwise.</returns>
        /// <remarks>There are some inefficiencies here, as we later check IfcExportAs in other contexts.  We should attempt to get the value only once.</remarks>
        public static bool ShouldElementBeExported(ExporterIFC exporterIFC, Element element, bool allowSeparateOpeningExport)
        {
            // Allow the ExporterStateManager to say that an element should be exported regardless of settings.
            if (ExporterStateManager.CanExportElementOverride())
            {
                return(true);
            }

            // Check to see if the category should be exported.  This overrides the IfcExportAs parameter.
            if (!ShouldCategoryBeExported(exporterIFC, element, allowSeparateOpeningExport))
            {
                return(false);
            }

            string exportAsEntity = "IFCExportAs";
            string elementClassName;

            if (ParameterUtil.GetStringValueFromElementOrSymbol(element, exportAsEntity, out elementClassName) != null)
            {
                string enumTypeValue = string.Empty;
                ExporterUtil.ExportEntityAndPredefinedType(elementClassName, out elementClassName, out enumTypeValue);

                if (CompareAlphaOnly(elementClassName, "DONTEXPORT"))
                {
                    return(false);
                }

                // Check whether the intended Entity type is inside the export exclusion set
                Common.Enums.IFCEntityType elementClassTypeEnum;
                if (Enum.TryParse <Common.Enums.IFCEntityType>(elementClassName, out elementClassTypeEnum))
                {
                    if (ExporterCacheManager.ExportOptionsCache.IsElementInExcludeList(elementClassTypeEnum))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
      /// <summary>
      /// Checks if element should be exported using a variety of different checks.
      /// </summary>
      /// <param name="exporterIFC">The ExporterIFC object.</param>
      /// <param name="element">The element.</param>
      /// <param name="allowSeparateOpeningExport">True if IfcOpeningElement is allowed to be exported.</param>
      /// <returns>True if the element should be exported, false otherwise.</returns>
      /// <remarks>There are some inefficiencies here, as we call GetExportInfoFromParameters
      /// in other contexts.  We should attempt to get the value only once.</remarks>
      public static bool ShouldElementBeExported(ExporterIFC exporterIFC, Element element, bool allowSeparateOpeningExport)
      {
         // Allow the ExporterStateManager to say that an element should be exported regardless of settings.
         if (ExporterStateManager.CanExportElementOverride())
            return true;

         // First, check if the element is set explicitly to be exported or not exported.  This
         // overrides category settings.
         Element elementType = element.Document.GetElement(element.GetTypeId());
         IFCExportElement? exportElementState = GetExportElementState(element, elementType);
         if (exportElementState.HasValue)
             return exportElementState.Value == IFCExportElement.Yes;

         // Check to see if the category should be exported if parameters aren't set.
         // Note that in previous versions, the category override the parameter settings.  This is
         // no longer true.
         if (!ShouldCategoryBeExported(exporterIFC, element, allowSeparateOpeningExport))
            return false;

         // Check whether the intended Entity type is inside the export exclusion set
         IFCExportInfoPair exportInfo = ExporterUtil.GetIFCExportElementParameterInfo(element, IFCEntityType.IfcRoot);
         return !ExporterCacheManager.ExportOptionsCache.IsElementInExcludeList(exportInfo.ExportInstance);
      }