/// <summary>
 /// Checks if using IFCBCA - Building Code Authority code checking.
 /// </summary>
 /// <param name="exportOptionsCache">The export options cache.</param>
 /// <returns>True if it is, false otherwise.</returns>
 public static bool DoCodeChecking(ExportOptionsCache exportOptionsCache)
 {
     switch (exportOptionsCache.FileVersion)
     {
         case IFCVersion.IFC2x2:
             {
                 return exportOptionsCache.WallAndColumnSplitting;
             }
         case IFCVersion.IFCBCA:
             return true;
         default:
             return false;
     }
 }
        /// <summary>
        /// Clear all caches contained in this manager.
        /// </summary>
        public static void Clear()
        {
            if (m_AllocatedGeometryObjectCache != null)
                m_AllocatedGeometryObjectCache.DisposeCache();
            ParameterUtil.ClearParameterCache();

            m_AllocatedGeometryObjectCache = null;
            m_AreaSchemeCache = null;
            m_AssemblyInstanceCache = null;
            m_BeamSystemCache = null;
            m_CategoryClassNameCache = null;
            m_CategoryTypeCache = null;
            m_CeilingSpaceRelCache = null;
            m_ClassificationCache = null;
            m_ClassificationLocationCache = null;
            m_ConditionalPropertySetsForTypeCache = null;
            m_ContainmentCache = null;
            m_CurveAnnotationCache = null;
            m_DefaultCartesianTransformationOperator3D = null;
            m_DummyHostCache = null;
            m_ElementToHandleCache = null;
            m_ElementsInAssembliesCache = null;
            m_ExportOptionsCache = null;
            m_FabricAreaHandleCache = null;
            m_GridCache = null;
            m_GroupCache = null;
            m_GroupElementGeometryCache = null;
            m_HandleToElementCache = null;
            m_HostPartsCache = null;
            m_IsExternalParameterValueCache = null;
            m_LevelInfoCache = null;
            m_MaterialIdToStyleHandleCache = null;
            m_MaterialLayerRelationsCache = null;
            m_MaterialLayerSetCache = null;
            m_MaterialHandleCache = null;
            m_MaterialRelationsCache = null;
            m_MEPCache = null;
            m_ParameterCache = null;
            m_PartExportedCache = null;
            m_PresentationLayerSetCache = null;
            m_PresentationStyleCache = null;
            m_PropertyInfoCache = null;
            m_PropertyMapCache = null;
            m_PropertySetsForTypeCache = null;
            m_RailingCache = null;
            m_RailingSubElementCache = null;
            m_SpaceBoundaryCache = null;
            m_SpaceOccupantInfoCache = null;
            m_SpatialElementHandleCache = null;
            m_StairRampContainerInfoCache = null;
            m_SystemsCache = null;
            m_TrussCache = null;
            m_TypeObjectsCache = null;
            m_TypePropertyInfoCache = null;
            m_TypeRelationsCache = null;
            m_ViewScheduleElementCache = null;
            m_WallConnectionDataCache = null;
            m_WallTypeCache = null;
            m_UnitsCache = null;
            m_ZoneCache = null;
            m_ZoneInfoCache = null;
        }
示例#3
0
        /// <summary>
        /// Creates a new property set options cache from the data in the ExporterIFC passed from Revit.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC handle passed during export.</param>
        /// <returns>The new cache.</returns>
        /// <remarks>Please initialize this after all other code, as it relies on a consistent cache otherwise.</remarks>
        public static PropertySetOptions Create(ExporterIFC exporterIFC, Autodesk.Revit.DB.View filterView,
            ExportOptionsCache cache)
        {
            IDictionary<String, String> options = exporterIFC.GetOptions();

            PropertySetOptions propertySetOptions = new PropertySetOptions();

            propertySetOptions.m_ExportInternalRevit = (cache.FileVersion != IFCVersion.IFC2x3CV2);

            // "Revit property sets" override
            propertySetOptions.ExportInternalRevitOverride = ExportOptionsCache.GetNamedBooleanOption(options, "ExportInternalRevitPropertySets");

            // "ExportIFCCommonPropertySets" override
            propertySetOptions.ExportIFCCommonOverride = ExportOptionsCache.GetNamedBooleanOption(options, "ExportIFCCommonPropertySets");

            return propertySetOptions;
        }
        /// <summary>
        /// Creates a new export options cache from the data in the ExporterIFC passed from Revit.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC handle passed during export.</param>
        /// <returns>The new cache.</returns>
        public static ExportOptionsCache Create(ExporterIFC exporterIFC, Autodesk.Revit.DB.View filterView)
        {
            IDictionary<String, String> options = exporterIFC.GetOptions();

            ExportOptionsCache cache = new ExportOptionsCache();
            cache.FileVersion = exporterIFC.FileVersion;
            cache.FileName = exporterIFC.FileName;
            cache.ExportBaseQuantities = exporterIFC.ExportBaseQuantities;
            cache.WallAndColumnSplitting = exporterIFC.WallAndColumnSplitting;
            cache.SpaceBoundaryLevel = exporterIFC.SpaceBoundaryLevel;
            // Export Part element only if 'Current View Only' is checked and 'Show Parts' is selected. 
            cache.ExportParts = filterView != null && filterView.PartsVisibility == PartsVisibility.ShowPartsOnly;
            cache.ExportPartsAsBuildingElementsOverride = null;
            cache.ExportAllLevels = false;
            cache.ExportAnnotationsOverride = null;
            cache.FilterViewForExport = filterView;
            cache.ExportSurfaceStylesOverride = null;
            cache.ExportBoundingBoxOverride = null;
            
            cache.PropertySetOptions = PropertySetOptions.Create(exporterIFC, filterView, cache);

            String use2DRoomBoundary = Environment.GetEnvironmentVariable("Use2DRoomBoundaryForRoomVolumeCalculationOnIFCExport");
            bool? use2DRoomBoundaryOption = GetNamedBooleanOption(options, "Use2DRoomBoundaryForVolume");
            cache.Use2DRoomBoundaryForRoomVolumeCreation =
                ((use2DRoomBoundary != null && use2DRoomBoundary == "1") ||
                cache.ExportAs2x2 ||
                (use2DRoomBoundaryOption != null && use2DRoomBoundaryOption.GetValueOrDefault()));

                bool? exportAdvancedSweptSolids = GetNamedBooleanOption(options, "ExportAdvancedSweptSolids");
            cache.ExportAdvancedSweptSolids = (exportAdvancedSweptSolids.HasValue) ? exportAdvancedSweptSolids.Value : false;
            
            // Set GUIDOptions here.
            cache.GUIDOptions = new GUIDOptions();
            {
                // This option should be rarely used, and is only for consistency with old files.  As such, it is set by environment variable only.
                String use2009GUID = Environment.GetEnvironmentVariable("Assign2009GUIDToBuildingStoriesOnIFCExport");
                cache.GUIDOptions.Use2009BuildingStoreyGUIDs = (use2009GUID != null && use2009GUID == "1");

                bool? allowGUIDParameterOverride = GetNamedBooleanOption(options, "AllowGUIDParameterOverride");
                if (allowGUIDParameterOverride != null)
                    cache.GUIDOptions.AllowGUIDParameterOverride = allowGUIDParameterOverride.Value;
            }

            // Set NamingOptions here.
            cache.NamingOptions = new NamingOptions();
            {
                bool? useFamilyAndTypeNameForReference = GetNamedBooleanOption(options, "UseFamilyAndTypeNameForReference");
                cache.NamingOptions.UseFamilyAndTypeNameForReference =
                    (useFamilyAndTypeNameForReference != null) && useFamilyAndTypeNameForReference.GetValueOrDefault();

                bool? useVisibleRevitNameAsEntityName = GetNamedBooleanOption(options, "UseVisibleRevitNameAsEntityName");
                cache.NamingOptions.UseVisibleRevitNameAsEntityName =
                    (useVisibleRevitNameAsEntityName != null) && useVisibleRevitNameAsEntityName.GetValueOrDefault();
            }

            // "SingleElement" export option - useful for debugging - only one input element will be processed for export
            String singleElementValue;
            String elementsToExportValue;
            if (options.TryGetValue("SingleElement", out singleElementValue))
            {
                int elementIdAsInt;
                if (Int32.TryParse(singleElementValue, out elementIdAsInt))
                {
                    List<ElementId> ids = new List<ElementId>();
                    ids.Add(new ElementId(elementIdAsInt));
                    cache.ElementsForExport = ids;
                }
                else
                {
                    // Error - the option supplied could not be mapped to int.
                    // TODO: consider logging this error later and handling results better.
                    throw new Exception("Option 'SingleElement' did not map to a usable element id");
                }
            }
            else if (options.TryGetValue("ElementsForExport", out elementsToExportValue))
            {
                String[] elements = elementsToExportValue.Split(';');
                List<ElementId> ids = new List<ElementId>();
                foreach (String element in elements)
                {
                    int elementIdAsInt;
                    if (Int32.TryParse(element, out elementIdAsInt))
                    {
                        ids.Add(new ElementId(elementIdAsInt));
                    }
                    else
                    {
                        // Error - the option supplied could not be mapped to int.
                        // TODO: consider logging this error later and handling results better.
                        throw new Exception("Option 'ElementsForExport' substring " + element + " did not map to a usable element id");
                    }
                }
                cache.ElementsForExport = ids;
            }
            else
            {
                cache.ElementsForExport = new List<ElementId>();
            }

            // "ExportAnnotations" override
            cache.ExportAnnotationsOverride = GetNamedBooleanOption(options, "ExportAnnotations");

            // "ExportSeparateParts" override
            cache.ExportPartsAsBuildingElementsOverride = GetNamedBooleanOption(options, "ExportPartsAsBuildingElements");

            // "ExportSurfaceStyles" override
            cache.ExportSurfaceStylesOverride = GetNamedBooleanOption(options, "ExportSurfaceStyles");

            // "ExportBoundingBox" override
            cache.ExportBoundingBoxOverride = GetNamedBooleanOption(options, "ExportBoundingBox");

            // Whether or not to export GSA Gross Design Area.
            cache.ExportGSAGrossDesignArea = GetNamedBooleanOption(options, "ExportGSAGrossDesignArea");

            // Using the alternate UI or not.
            cache.AlternateUIVersionOverride = GetNamedStringOption(options, "AlternateUIVersion");

            // "FileType" - note - setting is not respected yet
            ParseFileType(options, cache);

            cache.SelectedConfigName = GetNamedStringOption(options, "ConfigName");

            return cache;
        }
 /// <summary>
 /// Utility for parsing IFC file type.
 /// </summary>
 /// <remarks>
 /// If the file type can't be retrieved from the options collection, it will parse the file name extension.
 /// </remarks>
 /// <param name="options">The collection of named options for IFC export.</param>
 /// <param name="cache">The export options cache.</param>
 private static void ParseFileType(IDictionary<String, String> options, ExportOptionsCache cache)
 {            
     String fileTypeString;
     if (options.TryGetValue("FileType", out fileTypeString))
     {
         IFCFileFormat fileType;
         if (Enum.TryParse<IFCFileFormat>(fileTypeString, true, out fileType))
         {
             cache.IFCFileFormat = fileType;
         }
         else
         {
             // Error - the option supplied could not be mapped to ExportFileType.
             // TODO: consider logging this error later and handling results better.
             throw new Exception("Option 'FileType' did not match an existing IFCFileFormat value");
         }
     }
     else if (!string.IsNullOrEmpty(cache.FileName))
     {
         if (cache.FileName.EndsWith(".ifcXML")) //localization?
         {
             cache.IFCFileFormat = IFCFileFormat.IfcXML;
         }
         else if (cache.FileName.EndsWith(".ifcZIP"))
         {
             cache.IFCFileFormat = IFCFileFormat.IfcZIP;
         }
         else
         {
             cache.IFCFileFormat = IFCFileFormat.Ifc;
         }
     }
 }
示例#6
0
        /// <summary>
        /// Creates a new export options cache from the data in the ExporterIFC passed from Revit.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC handle passed during export.</param>
        /// <returns>The new cache.</returns>
        public static ExportOptionsCache Create(ExporterIFC exporterIFC, Autodesk.Revit.DB.View filterView)
        {
            IDictionary<String, String> options = exporterIFC.GetOptions();

            ExportOptionsCache cache = new ExportOptionsCache();
            cache.FileVersion = exporterIFC.FileVersion;
            cache.FileName = exporterIFC.FileName;
            cache.ExportBaseQuantities = exporterIFC.ExportBaseQuantities;
            cache.WallAndColumnSplitting = exporterIFC.WallAndColumnSplitting;
            cache.SpaceBoundaryLevel = exporterIFC.SpaceBoundaryLevel;
            // Export Part element only if 'Current View Only' is checked and 'Show Parts' is selected. 
            cache.ExportParts = filterView != null && filterView.PartsVisibility == PartsVisibility.ShowPartsOnly;
            cache.ExportPartsAsBuildingElementsOverride = null;
            cache.ExportAllLevels = false;
            cache.ExportAnnotationsOverride = null;
            cache.ExportInternalRevitPropertySetsOverride = null;
            cache.FilterViewForExport = filterView;

            String use2009GUID = Environment.GetEnvironmentVariable("Assign2009GUIDToBuildingStoriesOnIFCExport");
            cache.Use2009BuildingStoreyGUIDs = (use2009GUID != null && use2009GUID == "1");

            String use2DRoomBoundary = Environment.GetEnvironmentVariable("Use2DRoomBoundaryForRoomVolumeCalculationOnIFCExport");
            bool? use2DRoomBoundaryOption = GetNamedBooleanOption(options, "Use2DRoomBoundaryForVolume");
            cache.Use2DRoomBoundaryForRoomVolumeCreation =
                ((use2DRoomBoundary != null && use2DRoomBoundary == "1") || 
                cache.ExportAs2x2 || 
                (use2DRoomBoundaryOption != null && use2DRoomBoundaryOption.GetValueOrDefault()));

            bool? useFamilyAndTypeNameForReference = GetNamedBooleanOption(options, "UseFamilyAndTypeNameForReference");
            cache.UseFamilyAndTypeNameForReference = (useFamilyAndTypeNameForReference != null) && useFamilyAndTypeNameForReference.GetValueOrDefault();

            // "SingleElement" export option - useful for debugging - only one input element will be processed for export
            String singleElementValue;
            String elementsToExportValue;
            if (options.TryGetValue("SingleElement", out singleElementValue))
            {
                int elementIdAsInt;
                if (Int32.TryParse(singleElementValue, out elementIdAsInt))
                {
                    List<ElementId> ids = new List<ElementId>();
                    ids.Add(new ElementId(elementIdAsInt));
                    cache.ElementsForExport = ids;
                }
                else
                {
                    // Error - the option supplied could not be mapped to int.
                    // TODO: consider logging this error later and handling results better.
                    throw new Exception("Option 'SingleElement' did not map to a usable element id");
                }
            }
            else if (options.TryGetValue("ElementsForExport", out elementsToExportValue))
            {
                String[] elements = elementsToExportValue.Split(';');
                List<ElementId> ids = new List<ElementId>();
                foreach (String element in elements)
                {
                    int elementIdAsInt;
                    if (Int32.TryParse(element, out elementIdAsInt))
                    {
                        ids.Add(new ElementId(elementIdAsInt));
                    }
                    else
                    {
                        // Error - the option supplied could not be mapped to int.
                        // TODO: consider logging this error later and handling results better.
                        throw new Exception("Option 'ElementsForExport' substring " + element + " did not map to a usable element id");
                    }
                }
                cache.ElementsForExport = ids;
            }
            else
            {
                cache.ElementsForExport = new List<ElementId>();
            }

            // "ExportAnnotations" override
            cache.ExportAnnotationsOverride = GetNamedBooleanOption(options, "ExportAnnotations");

            // "Revit property sets" override
            cache.ExportInternalRevitPropertySetsOverride = GetNamedBooleanOption(options, "ExportInternalRevitPropertySets");

            // "ExportSeparateParts" override
            cache.ExportPartsAsBuildingElementsOverride = GetNamedBooleanOption(options, "ExportPartsAsBuildingElements");

            // "FileType" - note - setting is not respected yet
            ParseFileType(options, cache);

            return cache;
        }
示例#7
0
        /// <summary>
        /// Creates a new export options cache from the data in the ExporterIFC passed from Revit.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC handle passed during export.</param>
        /// <returns>The new cache.</returns>
        public static ExportOptionsCache Create(ExporterIFC exporterIFC, Document document, Autodesk.Revit.DB.View filterView)
        {
            IDictionary <String, String> options = exporterIFC.GetOptions();

            ExportOptionsCache cache = new ExportOptionsCache();

            cache.FileVersion            = exporterIFC.FileVersion;
            cache.FileName               = exporterIFC.FileName;
            cache.ExportBaseQuantities   = exporterIFC.ExportBaseQuantities;
            cache.WallAndColumnSplitting = exporterIFC.WallAndColumnSplitting;
            cache.SpaceBoundaryLevel     = exporterIFC.SpaceBoundaryLevel;
            // Export Part element only if 'Current View Only' is checked and 'Show Parts' is selected.
            cache.ExportParts = filterView != null && filterView.PartsVisibility == PartsVisibility.ShowPartsOnly;
            cache.ExportPartsAsBuildingElementsOverride = null;
            cache.ExportAllLevels           = false;
            cache.ExportAnnotationsOverride = null;
            cache.FilterViewForExport       = filterView;
            cache.ExportBoundingBoxOverride = null;
            cache.IncludeSiteElevation      = false;
            cache.UseCoarseTessellation     = true;

            cache.PropertySetOptions = PropertySetOptions.Create(exporterIFC, cache);

            String use2DRoomBoundary       = Environment.GetEnvironmentVariable("Use2DRoomBoundaryForRoomVolumeCalculationOnIFCExport");
            bool?  use2DRoomBoundaryOption = GetNamedBooleanOption(options, "Use2DRoomBoundaryForVolume");

            cache.Use2DRoomBoundaryForRoomVolumeCreation =
                ((use2DRoomBoundary != null && use2DRoomBoundary == "1") ||
                 cache.ExportAs2x2 ||
                 (use2DRoomBoundaryOption != null && use2DRoomBoundaryOption.GetValueOrDefault()));

            bool?exportAdvancedSweptSolids = GetNamedBooleanOption(options, "ExportAdvancedSweptSolids");

            cache.ExportAdvancedSweptSolids = (exportAdvancedSweptSolids.HasValue) ? exportAdvancedSweptSolids.Value : false;

            // Set GUIDOptions here.
            {
                // This option should be rarely used, and is only for consistency with old files.  As such, it is set by environment variable only.
                String use2009GUID = Environment.GetEnvironmentVariable("Assign2009GUIDToBuildingStoriesOnIFCExport");
                cache.GUIDOptions.Use2009BuildingStoreyGUIDs = (use2009GUID != null && use2009GUID == "1");

                bool?allowGUIDParameterOverride = GetNamedBooleanOption(options, "AllowGUIDParameterOverride");
                if (allowGUIDParameterOverride != null)
                {
                    cache.GUIDOptions.AllowGUIDParameterOverride = allowGUIDParameterOverride.Value;
                }

                bool?storeIFCGUID = GetNamedBooleanOption(options, "StoreIFCGUID");
                if (storeIFCGUID != null)
                {
                    cache.GUIDOptions.StoreIFCGUID = storeIFCGUID.Value;
                }
            }

            // Set NamingOptions here.
            cache.NamingOptions = new NamingOptions();
            {
                bool?useFamilyAndTypeNameForReference = GetNamedBooleanOption(options, "UseFamilyAndTypeNameForReference");
                cache.NamingOptions.UseFamilyAndTypeNameForReference =
                    (useFamilyAndTypeNameForReference != null) && useFamilyAndTypeNameForReference.GetValueOrDefault();

                bool?useVisibleRevitNameAsEntityName = GetNamedBooleanOption(options, "UseVisibleRevitNameAsEntityName");
                cache.NamingOptions.UseVisibleRevitNameAsEntityName =
                    (useVisibleRevitNameAsEntityName != null) && useVisibleRevitNameAsEntityName.GetValueOrDefault();
            }

            // "SingleElement" export option - useful for debugging - only one input element will be processed for export
            String singleElementValue;
            String elementsToExportValue;

            if (options.TryGetValue("SingleElement", out singleElementValue))
            {
                ElementId elementId = ParseElementId(singleElementValue);

                List <ElementId> ids = new List <ElementId>();
                ids.Add(elementId);
                cache.ElementsForExport = ids;
            }
            else if (options.TryGetValue("ElementsForExport", out elementsToExportValue))
            {
                IList <ElementId> ids = ParseElementIds(elementsToExportValue);
                cache.ElementsForExport = ids;
            }
            else
            {
                cache.ElementsForExport = new List <ElementId>();
            }

            // "ExportAnnotations" override
            cache.ExportAnnotationsOverride = GetNamedBooleanOption(options, "ExportAnnotations");

            // "ExportSeparateParts" override
            cache.ExportPartsAsBuildingElementsOverride = GetNamedBooleanOption(options, "ExportPartsAsBuildingElements");

            // "ExportBoundingBox" override
            cache.ExportBoundingBoxOverride = GetNamedBooleanOption(options, "ExportBoundingBox");

            // Using the alternate UI or not.
            cache.AlternateUIVersionOverride = GetNamedStringOption(options, "AlternateUIVersion");

            // Include IFCSITE elevation in the site local placement origin
            bool?includeIfcSiteElevation = GetNamedBooleanOption(options, "IncludeSiteElevation");

            cache.IncludeSiteElevation = includeIfcSiteElevation != null ? includeIfcSiteElevation.Value : false;

            // Use coarse tessellation for floors, railings, ramps, spaces and stairs.
            bool?useCoarseTessellation = GetNamedBooleanOption(options, "UseCoarseTessellation");

            cache.UseCoarseTessellation = useCoarseTessellation != null ? useCoarseTessellation.Value : true;

            /// Allow exporting a mix of extrusions and BReps as a solid model, if possible.
            bool?canExportSolidModelRep = GetNamedBooleanOption(options, "ExportSolidModelRep");

            cache.CanExportSolidModelRep = canExportSolidModelRep != null ? canExportSolidModelRep.Value : false;

            // Set the phase we are exporting
            cache.ActivePhase = ElementId.InvalidElementId;

            String activePhaseElementValue;

            if (options.TryGetValue("ActivePhase", out activePhaseElementValue))
            {
                cache.ActivePhase = ParseElementId(activePhaseElementValue);
            }

            if ((cache.ActivePhase == ElementId.InvalidElementId) && (cache.FilterViewForExport != null))
            {
                Parameter currPhase = cache.FilterViewForExport.get_Parameter(BuiltInParameter.VIEW_PHASE);
                if (currPhase != null)
                {
                    cache.ActivePhase = currPhase.AsElementId();
                }
            }

            if (cache.ActivePhase == ElementId.InvalidElementId)
            {
                PhaseArray phaseArray = document.Phases;
                Phase      lastPhase  = phaseArray.get_Item(phaseArray.Size - 1);
                cache.ActivePhase = lastPhase.Id;
            }

            // "FileType" - note - setting is not respected yet
            ParseFileType(options, cache);

            cache.SelectedConfigName = GetNamedStringOption(options, "ConfigName");

            return(cache);
        }
示例#8
0
        /// <summary>
        /// Creates a new export options cache from the data in the ExporterIFC passed from Revit.
        /// </summary>
        /// <param name="exporterIFC">The ExporterIFC handle passed during export.</param>
        /// <returns>The new cache.</returns>
        public static ExportOptionsCache Create(ExporterIFC exporterIFC, Document document, Autodesk.Revit.DB.View filterView)
        {
            IDictionary<String, String> options = exporterIFC.GetOptions();

            ExportOptionsCache cache = new ExportOptionsCache();
            cache.FileVersion = exporterIFC.FileVersion;
            cache.FileName = exporterIFC.FileName;
            cache.ExportBaseQuantities = exporterIFC.ExportBaseQuantities;
            cache.WallAndColumnSplitting = exporterIFC.WallAndColumnSplitting;
            cache.SpaceBoundaryLevel = exporterIFC.SpaceBoundaryLevel;
            // Export Part element only if 'Current View Only' is checked and 'Show Parts' is selected. 
            cache.ExportParts = filterView != null && filterView.PartsVisibility == PartsVisibility.ShowPartsOnly;
            cache.ExportPartsAsBuildingElementsOverride = null;
            cache.ExportAllLevels = false;
            cache.ExportAnnotationsOverride = null;
            cache.FilterViewForExport = filterView;
            cache.ExportBoundingBoxOverride = null;
            cache.IncludeSiteElevation = false;
            cache.UseCoarseTessellation = true;

            cache.PropertySetOptions = PropertySetOptions.Create(exporterIFC, cache);

            String use2DRoomBoundary = Environment.GetEnvironmentVariable("Use2DRoomBoundaryForRoomVolumeCalculationOnIFCExport");
            bool? use2DRoomBoundaryOption = GetNamedBooleanOption(options, "Use2DRoomBoundaryForVolume");
            cache.Use2DRoomBoundaryForRoomVolumeCreation =
                ((use2DRoomBoundary != null && use2DRoomBoundary == "1") ||
                cache.ExportAs2x2 ||
                (use2DRoomBoundaryOption != null && use2DRoomBoundaryOption.GetValueOrDefault()));

            bool? exportAdvancedSweptSolids = GetNamedBooleanOption(options, "ExportAdvancedSweptSolids");
            cache.ExportAdvancedSweptSolids = (exportAdvancedSweptSolids.HasValue) ? exportAdvancedSweptSolids.Value : false;

            // Set GUIDOptions here.
            {
                // This option should be rarely used, and is only for consistency with old files.  As such, it is set by environment variable only.
                String use2009GUID = Environment.GetEnvironmentVariable("Assign2009GUIDToBuildingStoriesOnIFCExport");
                cache.GUIDOptions.Use2009BuildingStoreyGUIDs = (use2009GUID != null && use2009GUID == "1");

                bool? allowGUIDParameterOverride = GetNamedBooleanOption(options, "AllowGUIDParameterOverride");
                if (allowGUIDParameterOverride != null)
                    cache.GUIDOptions.AllowGUIDParameterOverride = allowGUIDParameterOverride.Value;

                bool? storeIFCGUID = GetNamedBooleanOption(options, "StoreIFCGUID");
                if (storeIFCGUID != null)
                    cache.GUIDOptions.StoreIFCGUID = storeIFCGUID.Value;
            }

            // Set NamingOptions here.
            cache.NamingOptions = new NamingOptions();
            {
                bool? useFamilyAndTypeNameForReference = GetNamedBooleanOption(options, "UseFamilyAndTypeNameForReference");
                cache.NamingOptions.UseFamilyAndTypeNameForReference =
                    (useFamilyAndTypeNameForReference != null) && useFamilyAndTypeNameForReference.GetValueOrDefault();

                bool? useVisibleRevitNameAsEntityName = GetNamedBooleanOption(options, "UseVisibleRevitNameAsEntityName");
                cache.NamingOptions.UseVisibleRevitNameAsEntityName =
                    (useVisibleRevitNameAsEntityName != null) && useVisibleRevitNameAsEntityName.GetValueOrDefault();
            }

            // "SingleElement" export option - useful for debugging - only one input element will be processed for export
            String singleElementValue;
            String elementsToExportValue;
            if (options.TryGetValue("SingleElement", out singleElementValue))
            {
                ElementId elementId = ParseElementId(singleElementValue);
                
                List<ElementId> ids = new List<ElementId>();
                ids.Add(elementId);
                cache.ElementsForExport = ids;
            }
            else if (options.TryGetValue("ElementsForExport", out elementsToExportValue))
            {
                IList<ElementId> ids = ParseElementIds(elementsToExportValue);
                cache.ElementsForExport = ids;
            }
            else
            {
                cache.ElementsForExport = new List<ElementId>();
            }

            // "ExportAnnotations" override
            cache.ExportAnnotationsOverride = GetNamedBooleanOption(options, "ExportAnnotations");

            // "ExportSeparateParts" override
            cache.ExportPartsAsBuildingElementsOverride = GetNamedBooleanOption(options, "ExportPartsAsBuildingElements");

            // "ExportBoundingBox" override
            cache.ExportBoundingBoxOverride = GetNamedBooleanOption(options, "ExportBoundingBox");

            // Using the alternate UI or not.
            cache.AlternateUIVersionOverride = GetNamedStringOption(options, "AlternateUIVersion");

            // Include IFCSITE elevation in the site local placement origin
            bool? includeIfcSiteElevation = GetNamedBooleanOption(options, "IncludeSiteElevation");
            cache.IncludeSiteElevation = includeIfcSiteElevation != null ? includeIfcSiteElevation.Value : false;

            // Use coarse tessellation for floors, railings, ramps, spaces and stairs.
            bool? useCoarseTessellation = GetNamedBooleanOption(options, "UseCoarseTessellation");
            cache.UseCoarseTessellation = useCoarseTessellation != null ? useCoarseTessellation.Value : true;

            /// Allow exporting a mix of extrusions and BReps as a solid model, if possible.
            bool? canExportSolidModelRep = GetNamedBooleanOption(options, "ExportSolidModelRep");
            cache.CanExportSolidModelRep = canExportSolidModelRep != null ? canExportSolidModelRep.Value : false;

            // Set the phase we are exporting
            cache.ActivePhase = ElementId.InvalidElementId;
            
            String activePhaseElementValue;
            if (options.TryGetValue("ActivePhase", out activePhaseElementValue))
                cache.ActivePhase = ParseElementId(activePhaseElementValue);

            if ((cache.ActivePhase == ElementId.InvalidElementId) && (cache.FilterViewForExport != null))
            {
                Parameter currPhase = cache.FilterViewForExport.get_Parameter(BuiltInParameter.VIEW_PHASE);
                if (currPhase != null)
                    cache.ActivePhase = currPhase.AsElementId();
            }

            if (cache.ActivePhase == ElementId.InvalidElementId)
            {
                PhaseArray phaseArray = document.Phases;
                Phase lastPhase = phaseArray.get_Item(phaseArray.Size - 1);
                cache.ActivePhase = lastPhase.Id;
            }

            // "FileType" - note - setting is not respected yet
            ParseFileType(options, cache);

            cache.SelectedConfigName = GetNamedStringOption(options, "ConfigName");

            return cache;
        }
示例#9
0
        /// <summary>
        /// Clear all caches contained in this manager.
        /// </summary>
        public static void Clear()
        {
            if (m_AllocatedGeometryObjectCache != null)
                m_AllocatedGeometryObjectCache.DisposeCache();

            m_AllocatedGeometryObjectCache = null;
            m_AssemblyInstanceCache = null;
            m_ClassificationCache = null;
            m_CurveAnnotationCache = null;
            m_DummyHostCache = null;
            m_ElementToHandleCache = null;
            m_ExportOptionsCache = null;
            m_HandleToElementCache = null;
            m_HostPartsCache = null;
            m_LevelInfoCache = null;
            m_MaterialLayerRelationsCache = null;
            m_MaterialLayerSetCache = null;
            m_MaterialHandleCache = null;
            m_MaterialRelationsCache = null;
            m_MEPCache = null;
            m_RailingCache = null;
            m_RailingSubElementCache = null;
            m_ParameterCache = null;
            m_PartExportedCache = null;
            m_PresentationStyleCache = null;
            m_SpaceBoundaryCache = null;
            m_SpaceOccupantInfoCache = null;
            m_SpatialElementHandleCache = null;
            m_TypeObjectsCache = null;
            m_TypeRelationsCache = null;
            m_WallConnectionDataCache = null;
            m_UnitsCache = null;
            m_ZoneInfoCache = null;
            m_TypePropertyInfoCache = null;
            m_DoublePropertyInfoCache = null;
            m_BooleanPropertyInfoCache = null;
            m_IntegerPropertyInfoCache = null;
            m_StringPropertyInfoCache = null;
            m_HandleTypeCache = null;
            m_HandleIsSubTypeOfCache = null;
            m_GroupElementGeometryCache = null;
            m_PropertySetsForTypeCache = null;
            m_ConditionalPropertySetsForTypeCache = null;
            m_MaterialIdToStyleHandleCache = null;
            m_DefaultCartesianTransformationOperator3D = null;
            m_StairRampContainerInfoCache = null;
        }