/// <summary> /// Compute the Eastings, Northings, OrthogonalHeight from the selected SiteTransformationBasis and scale values /// </summary> /// <param name="doc">The document</param> /// <param name="wcsBasis">The selected coordinate base</param> /// <returns>A Tuple of scaled values for Eastings, Northings, and OrthogonalHeight</returns> public static (double eastings, double northings, double orthogonalHeight, double angleTN, double origAngleTN) ScaledGeoReferenceInformation (Document doc, SiteTransformBasis wcsBasis, ProjectLocation projLocation = null) { (double eastings, double northings, double orthogonalHeight, double angleTN, double origAngleTN)geoRef = GeoReferenceInformation(doc, wcsBasis, projLocation); FormatOptions lenFormatOptions = doc.GetUnits().GetFormatOptions(SpecTypeId.Length); ForgeTypeId lengthUnit = lenFormatOptions.GetUnitTypeId(); geoRef.eastings = UnitUtils.ConvertFromInternalUnits(geoRef.eastings, lengthUnit); geoRef.northings = UnitUtils.ConvertFromInternalUnits(geoRef.northings, lengthUnit); geoRef.orthogonalHeight = UnitUtils.ConvertFromInternalUnits(geoRef.orthogonalHeight, lengthUnit); FormatOptions angleFormatOptions = doc.GetUnits().GetFormatOptions(SpecTypeId.Angle); ForgeTypeId angleUnit = angleFormatOptions.GetUnitTypeId(); geoRef.angleTN = UnitUtils.ConvertFromInternalUnits(geoRef.angleTN, angleUnit); return(geoRef); }
/// <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. Or if it is exported as IFC4RV cache.ExportParts = (filterView != null && filterView.PartsVisibility == PartsVisibility.ShowPartsOnly); cache.ExportPartsAsBuildingElementsOverride = null; cache.ExportAnnotationsOverride = null; // We are going to default to "true" for IncludeSteelElements to allow the default API // export to match the default UI. bool?includeSteelElements = OptionsUtil.GetNamedBooleanOption(options, "IncludeSteelElements"); cache.IncludeSteelElements = includeSteelElements.HasValue && includeSteelElements.Value; // There is a bug in the native code that doesn't allow us to cast the filterView to any sub-type of View. Work around this by re-getting the element pointer. if (filterView != null) { cache.FilterViewForExport = filterView.Document.GetElement(filterView.Id) as View; } else { cache.FilterViewForExport = null; } cache.ExportBoundingBoxOverride = null; cache.IncludeSiteElevation = false; cache.PropertySetOptions = PropertySetOptions.Create(exporterIFC, cache); String use2DRoomBoundary = Environment.GetEnvironmentVariable("Use2DRoomBoundaryForRoomVolumeCalculationOnIFCExport"); bool? use2DRoomBoundaryOption = OptionsUtil.GetNamedBooleanOption(options, "Use2DRoomBoundaryForVolume"); cache.Use2DRoomBoundaryForRoomVolumeCreation = ((use2DRoomBoundary != null && use2DRoomBoundary == "1") || cache.ExportAs2x2 || (use2DRoomBoundaryOption != null && use2DRoomBoundaryOption.GetValueOrDefault())); bool?exportAdvancedSweptSolids = OptionsUtil.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 = OptionsUtil.GetNamedBooleanOption(options, "AllowGUIDParameterOverride"); if (allowGUIDParameterOverride != null) { cache.GUIDOptions.AllowGUIDParameterOverride = allowGUIDParameterOverride.Value; } bool?storeIFCGUID = OptionsUtil.GetNamedBooleanOption(options, "StoreIFCGUID"); if (storeIFCGUID != null) { cache.GUIDOptions.StoreIFCGUID = storeIFCGUID.Value; } } // Set NamingOptions here. cache.NamingOptions = new NamingOptions(); { bool?useFamilyAndTypeNameForReference = OptionsUtil.GetNamedBooleanOption(options, "UseFamilyAndTypeNameForReference"); cache.NamingOptions.UseFamilyAndTypeNameForReference = (useFamilyAndTypeNameForReference != null) && useFamilyAndTypeNameForReference.GetValueOrDefault(); bool?useVisibleRevitNameAsEntityName = OptionsUtil.GetNamedBooleanOption(options, "UseVisibleRevitNameAsEntityName"); cache.NamingOptions.UseVisibleRevitNameAsEntityName = (useVisibleRevitNameAsEntityName != null) && useVisibleRevitNameAsEntityName.GetValueOrDefault(); bool?useOnlyTypeNameForIfcType = OptionsUtil.GetNamedBooleanOption(options, "UseTypeNameOnlyForIfcType"); cache.NamingOptions.UseTypeNameOnlyForIfcType = (useOnlyTypeNameForIfcType != null) && useOnlyTypeNameForIfcType.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 = OptionsUtil.GetNamedBooleanOption(options, "ExportAnnotations"); // "ExportSeparateParts" override cache.ExportPartsAsBuildingElementsOverride = OptionsUtil.GetNamedBooleanOption(options, "ExportPartsAsBuildingElements"); // "ExportBoundingBox" override cache.ExportBoundingBoxOverride = OptionsUtil.GetNamedBooleanOption(options, "ExportBoundingBox"); bool?exportRoomsInView = OptionsUtil.GetNamedBooleanOption(options, "ExportRoomsInView"); cache.ExportRoomsInView = exportRoomsInView != null ? exportRoomsInView.Value : false; // Using the alternate UI or not. cache.AlternateUIVersionOverride = OptionsUtil.GetNamedStringOption(options, "AlternateUIVersion"); // Include IFCSITE elevation in the site local placement origin bool?includeIfcSiteElevation = OptionsUtil.GetNamedBooleanOption(options, "IncludeSiteElevation"); cache.IncludeSiteElevation = includeIfcSiteElevation != null ? includeIfcSiteElevation.Value : false; string siteTransformation = OptionsUtil.GetNamedStringOption(options, "SitePlacement"); if (!string.IsNullOrEmpty(siteTransformation)) { SiteTransformBasis trfBasis = SiteTransformBasis.Shared; if (Enum.TryParse(siteTransformation, out trfBasis)) { cache.SiteTransformation = trfBasis; } } // We have two ways to get information about level of detail: // 1. The old Boolean "UseCoarseTessellation". // 2. The new double "TessellationLevelOfDetail". // We will combine these both into a LevelOfDetail integer that can be used by different elements differently. // The scale is from 1 (Extra Low) to 4 (High), where : // UseCoarseTessellation = true -> 1, UseCoarseTessellation = false -> 4 // TessellationLevelOfDetail * 4 = LevelOfDetail // TessellationLevelOfDetail takes precedence over UseCoarseTessellation. cache.LevelOfDetail = ExportTessellationLevel.Low; bool?useCoarseTessellation = OptionsUtil.GetNamedBooleanOption(options, "UseCoarseTessellation"); if (useCoarseTessellation.HasValue) { cache.LevelOfDetail = useCoarseTessellation.Value ? ExportTessellationLevel.ExtraLow : ExportTessellationLevel.High; } double?tessellationLOD = OptionsUtil.GetNamedDoubleOption(options, "TessellationLevelOfDetail"); if (tessellationLOD.HasValue) { int levelOfDetail = (int)(tessellationLOD.Value * 4.0 + 0.5); // Ensure LOD is between 1 to 4, inclusive. levelOfDetail = Math.Min(Math.Max(levelOfDetail, 1), 4); cache.LevelOfDetail = (ExportTessellationLevel)levelOfDetail; } bool?useOnlyTriangulation = OptionsUtil.GetNamedBooleanOption(options, "UseOnlyTriangulation"); cache.UseOnlyTriangulation = useOnlyTriangulation.HasValue ? useOnlyTriangulation.Value : false; /// Allow exporting a mix of extrusions and BReps as a solid model, if possible. bool?canExportSolidModelRep = OptionsUtil.GetNamedBooleanOption(options, "ExportSolidModelRep"); cache.CanExportSolidModelRep = canExportSolidModelRep != null ? canExportSolidModelRep.Value : false; // Set the phase we are exporting cache.ActivePhaseId = ElementId.InvalidElementId; String activePhaseElementValue; if (options.TryGetValue("ActivePhase", out activePhaseElementValue)) { cache.ActivePhaseId = ParseElementId(activePhaseElementValue); } if ((cache.ActivePhaseId == ElementId.InvalidElementId) && (cache.FilterViewForExport != null)) { Parameter currPhase = cache.FilterViewForExport.get_Parameter(BuiltInParameter.VIEW_PHASE); if (currPhase != null) { cache.ActivePhaseId = currPhase.AsElementId(); } } if (cache.ActivePhaseId == ElementId.InvalidElementId) { PhaseArray phaseArray = document.Phases; Phase lastPhase = phaseArray.get_Item(phaseArray.Size - 1); cache.ActivePhaseId = lastPhase.Id; cache.ActivePhaseElement = lastPhase; } else { cache.ActivePhaseElement = document.GetElement(cache.ActivePhaseId) as Phase; } bool?useActiveViewGeometry = OptionsUtil.GetNamedBooleanOption(options, "UseActiveViewGeometry"); cache.UseActiveViewGeometry = useActiveViewGeometry.HasValue ? useActiveViewGeometry.Value : false; if (cache.UseActiveViewGeometry) { int? viewId = OptionsUtil.GetNamedIntOption(options, "ActiveViewId"); int activeViewId = viewId.HasValue ? viewId.Value : -1; View activeView = null; try { activeView = document.GetElement(new ElementId(activeViewId)) as View; } catch { } cache.ActiveView = activeView; } // "FileType" - note - setting is not respected yet ParseFileType(options, cache); string erName = OptionsUtil.GetNamedStringOption(options, "ExchangeRequirement"); Enum.TryParse(erName, out cache.m_exchangeRequirement); // Get stored File Header information from the UI and use it for export IFCFileHeaderItem fileHeaderItem = new IFCFileHeaderItem(); new IFCFileHeader().GetSavedFileHeader(document, out fileHeaderItem); if (cache.m_exchangeRequirement != KnownERNames.NotDefined) { // It override existing value (if present) in the saved FileHeader, to use the selected ER from the UI fileHeaderItem.FileDescription = "ExchangeRequirement [" + erName + "]"; } cache.FileHeaderItem = fileHeaderItem; cache.SelectedConfigName = OptionsUtil.GetNamedStringOption(options, "ConfigName"); cache.SelectedParametermappingTableName = OptionsUtil.GetNamedStringOption(options, "ExportUserDefinedParameterMappingFileName"); bool?bExportLinks = OptionsUtil.GetNamedBooleanOption(options, "ExportingLinks"); cache.ExportingLink = (bExportLinks.HasValue && bExportLinks.Value == true); if (cache.ExportingLink) { int?numInstances = OptionsUtil.GetNamedIntOption(options, "NumberOfExportedLinkInstances"); for (int ii = 0; ii < numInstances; ii++) { string optionName = (ii == 0) ? "ExportLinkInstanceTransform" : "ExportLinkInstanceTransform" + (ii + 1).ToString(); String aLinkInstanceTransform = OptionsUtil.GetNamedStringOption(options, optionName); Transform currTransform = null; if (!String.IsNullOrEmpty(aLinkInstanceTransform)) { //reconstruct transform Transform tr = ParseTransform(aLinkInstanceTransform); //set to cache if (tr != null) { currTransform = tr; } } string fileName = null; if (ii > 0) { optionName = "ExportLinkInstanceFileName" + (ii + 1).ToString(); fileName = OptionsUtil.GetNamedStringOption(options, optionName); } if (currTransform == null) { cache.m_LinkInstanceInfos.Add(new Tuple <string, Transform>(fileName, Transform.Identity)); } else { cache.m_LinkInstanceInfos.Add(new Tuple <string, Transform>(fileName, currTransform)); } } } cache.ExcludeFilter = OptionsUtil.GetNamedStringOption(options, "ExcludeFilter"); // Geo Reference info cache.GeoRefCRSName = OptionsUtil.GetNamedStringOption(options, "GeoRefCRSName"); cache.GeoRefCRSDesc = OptionsUtil.GetNamedStringOption(options, "GeoRefCRSDesc"); cache.GeoRefEPSGCode = OptionsUtil.GetNamedStringOption(options, "GeoRefEPSGCode"); cache.GeoRefGeodeticDatum = OptionsUtil.GetNamedStringOption(options, "GeoRefGeodeticDatum"); cache.GeoRefMapUnit = OptionsUtil.GetNamedStringOption(options, "GeoRefMapUnit"); return(cache); }
public IFCSitePlacementAttributes(SiteTransformBasis transformBasis) { TransformBasis = transformBasis; }
/// <summary> /// Compute the Eastings, Northings, OrthogonalHeight from the selected SiteTransformationBasis /// </summary> /// <param name="doc">The document</param> /// <param name="wcsBasis">The selected coordinate base</param> /// <returns>A Tuple for Eastings, Northings, and OrthogonalHeight</returns> public static (double eastings, double northings, double orthogonalHeight) GeoReferenceInformation(Document doc, SiteTransformBasis wcsBasis) { double eastings = 0.0; double northings = 0.0; double orthogonalHeight = 0.0; BasePoint surveyPoint = BasePoint.GetSurveyPoint(doc); BasePoint projectBasePoint = BasePoint.GetProjectBasePoint(doc); switch (wcsBasis) { case SiteTransformBasis.Internal: northings = surveyPoint.SharedPosition.Y - surveyPoint.Position.Y; eastings = surveyPoint.SharedPosition.X - surveyPoint.Position.X; orthogonalHeight = surveyPoint.SharedPosition.Z - surveyPoint.Position.Z; break; case SiteTransformBasis.Project: northings = projectBasePoint.SharedPosition.Y; eastings = projectBasePoint.SharedPosition.X; orthogonalHeight = projectBasePoint.SharedPosition.Z; break; case SiteTransformBasis.Shared: northings = 0.0; eastings = 0.0; orthogonalHeight = 0.0; break; case SiteTransformBasis.Site: northings = surveyPoint.SharedPosition.Y; eastings = surveyPoint.SharedPosition.X; orthogonalHeight = surveyPoint.SharedPosition.Z; break; default: northings = 0.0; eastings = 0.0; orthogonalHeight = 0.0; break; } return(eastings, northings, orthogonalHeight); }
/// <summary> /// Compute the Eastings, Northings, OrthogonalHeight from the selected SiteTransformationBasis and scale values /// </summary> /// <param name="doc">The document</param> /// <param name="wcsBasis">The selected coordinate base</param> /// <returns>A Tuple of scaled values for Eastings, Northings, and OrthogonalHeight</returns> public static (double eastings, double northings, double orthogonalHeight) ScaledGeoReferenceInformation(Document doc, SiteTransformBasis wcsBasis) { (double eastings, double northings, double orthogonalHeight)geoRef = GeoReferenceInformation(doc, wcsBasis); FormatOptions lenFormatOptions = doc.GetUnits().GetFormatOptions(SpecTypeId.Length); ForgeTypeId lengthUnit = lenFormatOptions.GetUnitTypeId(); geoRef.eastings = UnitUtils.ConvertFromInternalUnits(geoRef.eastings, lengthUnit); geoRef.northings = UnitUtils.ConvertFromInternalUnits(geoRef.northings, lengthUnit); geoRef.orthogonalHeight = UnitUtils.ConvertFromInternalUnits(geoRef.orthogonalHeight, lengthUnit); return(geoRef); }
/// <summary> /// Adds the saved configuration from document to the map. /// </summary> public void AddSavedConfigurations() { try { // find the config in old schema. if (m_OldSchema == null) { m_OldSchema = Schema.Lookup(s_OldSchemaId); if (m_OldSchema != null) { foreach (DataStorage storedSetup in GetSavedConfigurations(m_OldSchema)) { Entity configEntity = storedSetup.GetEntity(m_OldSchema); IFCExportConfiguration configuration = IFCExportConfiguration.CreateDefaultConfiguration(); configuration.Name = configEntity.Get <String>(s_setupName); configuration.IFCVersion = (IFCVersion)configEntity.Get <int>(s_setupVersion); configuration.ExchangeRequirement = IFCExchangeRequirements.ParseEREnum(configEntity.Get <String>(s_exchangeRequirement)); configuration.IFCFileType = (IFCFileFormat)configEntity.Get <int>(s_setupFileFormat); configuration.SpaceBoundaries = configEntity.Get <int>(s_setupSpaceBoundaries); configuration.ExportBaseQuantities = configEntity.Get <bool>(s_setupQTO); configuration.SplitWallsAndColumns = configEntity.Get <bool>(s_splitWallsAndColumns); configuration.Export2DElements = configEntity.Get <bool>(s_setupExport2D); configuration.ExportInternalRevitPropertySets = configEntity.Get <bool>(s_setupExportRevitProps); Field fieldIFCCommonPropertySets = m_OldSchema.GetField(s_setupExportIFCCommonProperty); if (fieldIFCCommonPropertySets != null) { configuration.ExportIFCCommonPropertySets = configEntity.Get <bool>(s_setupExportIFCCommonProperty); } configuration.Use2DRoomBoundaryForVolume = configEntity.Get <bool>(s_setupUse2DForRoomVolume); configuration.UseFamilyAndTypeNameForReference = configEntity.Get <bool>(s_setupUseFamilyAndTypeName); Field fieldPartsAsBuildingElements = m_OldSchema.GetField(s_setupExportPartsAsBuildingElements); if (fieldPartsAsBuildingElements != null) { configuration.ExportPartsAsBuildingElements = configEntity.Get <bool>(s_setupExportPartsAsBuildingElements); } Field fieldExportBoundingBox = m_OldSchema.GetField(s_setupExportBoundingBox); if (fieldExportBoundingBox != null) { configuration.ExportBoundingBox = configEntity.Get <bool>(s_setupExportBoundingBox); } Field fieldExportSolidModelRep = m_OldSchema.GetField(s_setupExportSolidModelRep); if (fieldExportSolidModelRep != null) { configuration.ExportSolidModelRep = configEntity.Get <bool>(s_setupExportSolidModelRep); } Field fieldExportSchedulesAsPsets = m_OldSchema.GetField(s_setupExportSchedulesAsPsets); if (fieldExportSchedulesAsPsets != null) { configuration.ExportSchedulesAsPsets = configEntity.Get <bool>(s_setupExportSchedulesAsPsets); } Field fieldExportUserDefinedPsets = m_OldSchema.GetField(s_setupExportUserDefinedPsets); if (fieldExportUserDefinedPsets != null) { configuration.ExportUserDefinedPsets = configEntity.Get <bool>(s_setupExportUserDefinedPsets); } Field fieldExportUserDefinedPsetsFileName = m_OldSchema.GetField(s_setupExportUserDefinedPsetsFileName); if (fieldExportUserDefinedPsetsFileName != null) { configuration.ExportUserDefinedPsetsFileName = configEntity.Get <string>(s_setupExportUserDefinedPsetsFileName); } Field fieldExportUserDefinedParameterMapingTable = m_OldSchema.GetField(s_setupExportUserDefinedParameterMapping); if (fieldExportUserDefinedParameterMapingTable != null) { configuration.ExportUserDefinedParameterMapping = configEntity.Get <bool>(s_setupExportUserDefinedParameterMapping); } Field fieldExportUserDefinedParameterMappingFileName = m_OldSchema.GetField(s_setupExportUserDefinedParameterMappingFileName); if (fieldExportUserDefinedParameterMappingFileName != null) { configuration.ExportUserDefinedParameterMappingFileName = configEntity.Get <string>(s_setupExportUserDefinedParameterMappingFileName); } Field fieldExportLinkedFiles = m_OldSchema.GetField(s_setupExportLinkedFiles); if (fieldExportLinkedFiles != null) { configuration.ExportLinkedFiles = configEntity.Get <bool>(s_setupExportLinkedFiles); } Field fieldIncludeSiteElevation = m_OldSchema.GetField(s_setupIncludeSiteElevation); if (fieldIncludeSiteElevation != null) { configuration.IncludeSiteElevation = configEntity.Get <bool>(s_setupIncludeSiteElevation); } Field fieldStoreIFCGUID = m_OldSchema.GetField(s_setupStoreIFCGUID); if (fieldStoreIFCGUID != null) { configuration.StoreIFCGUID = configEntity.Get <bool>(s_setupStoreIFCGUID); } Field fieldActivePhase = m_OldSchema.GetField(s_setupActivePhase); if (fieldActivePhase != null) { configuration.ActivePhaseId = int.Parse(configEntity.Get <string>(s_setupActivePhase)); } Field fieldExportRoomsInView = m_OldSchema.GetField(s_setupExportRoomsInView); if (fieldExportRoomsInView != null) { configuration.ExportRoomsInView = configEntity.Get <bool>(s_setupExportRoomsInView); } Field fieldIncludeSteelElements = m_OldSchema.GetField(s_includeSteelElements); if (fieldIncludeSteelElements != null) { configuration.IncludeSteelElements = configEntity.Get <bool>(s_includeSteelElements); } Field fieldUseOnlyTriangulation = m_OldSchema.GetField(s_useOnlyTriangulation); if (fieldUseOnlyTriangulation != null) { configuration.UseOnlyTriangulation = configEntity.Get <bool>(s_useOnlyTriangulation); } Field fieldUseTypeNameOnlyForIfcType = m_OldSchema.GetField(s_useTypeNameOnlyForIfcType); if (fieldUseTypeNameOnlyForIfcType != null) { configuration.UseTypeNameOnlyForIfcType = configEntity.Get <bool>(s_useTypeNameOnlyForIfcType); } Field fieldUseVisibleRevitNameAsEntityName = m_OldSchema.GetField(s_useVisibleRevitNameAsEntityName); if (fieldUseVisibleRevitNameAsEntityName != null) { configuration.UseVisibleRevitNameAsEntityName = configEntity.Get <bool>(s_useVisibleRevitNameAsEntityName); } Field fieldTessellationLevelOfDetail = m_OldSchema.GetField(s_setupTessellationLevelOfDetail); if (fieldTessellationLevelOfDetail != null) { configuration.TessellationLevelOfDetail = configEntity.Get <double>(s_setupTessellationLevelOfDetail); } AddOrReplace(configuration); } } } // This is the newer schema if (m_mapSchema == null) { m_mapSchema = Schema.Lookup(s_mapSchemaId); if (m_mapSchema != null) { foreach (DataStorage storedSetup in GetSavedConfigurations(m_mapSchema)) { Entity configEntity = storedSetup.GetEntity(m_mapSchema); IDictionary <string, string> configMap = configEntity.Get <IDictionary <string, string> >(s_configMapField); IFCExportConfiguration configuration = IFCExportConfiguration.CreateDefaultConfiguration(); if (configMap.ContainsKey(s_setupName)) { configuration.Name = configMap[s_setupName]; } if (configMap.ContainsKey(s_setupVersion)) { configuration.IFCVersion = (IFCVersion)Enum.Parse(typeof(IFCVersion), configMap[s_setupVersion]); } if (configMap.ContainsKey(s_exchangeRequirement)) { configuration.ExchangeRequirement = IFCExchangeRequirements.ParseEREnum(configMap[s_exchangeRequirement]); } if (configMap.ContainsKey(s_setupFileFormat)) { configuration.IFCFileType = (IFCFileFormat)Enum.Parse(typeof(IFCFileFormat), configMap[s_setupFileFormat]); } if (configMap.ContainsKey(s_setupSpaceBoundaries)) { configuration.SpaceBoundaries = int.Parse(configMap[s_setupSpaceBoundaries]); } if (configMap.ContainsKey(s_setupActivePhase)) { configuration.ActivePhaseId = int.Parse(configMap[s_setupActivePhase]); } if (configMap.ContainsKey(s_setupQTO)) { configuration.ExportBaseQuantities = bool.Parse(configMap[s_setupQTO]); } if (configMap.ContainsKey(s_setupCurrentView)) { configuration.VisibleElementsOfCurrentView = bool.Parse(configMap[s_setupCurrentView]); } if (configMap.ContainsKey(s_splitWallsAndColumns)) { configuration.SplitWallsAndColumns = bool.Parse(configMap[s_splitWallsAndColumns]); } if (configMap.ContainsKey(s_setupExport2D)) { configuration.Export2DElements = bool.Parse(configMap[s_setupExport2D]); } if (configMap.ContainsKey(s_setupExportRevitProps)) { configuration.ExportInternalRevitPropertySets = bool.Parse(configMap[s_setupExportRevitProps]); } if (configMap.ContainsKey(s_setupExportIFCCommonProperty)) { configuration.ExportIFCCommonPropertySets = bool.Parse(configMap[s_setupExportIFCCommonProperty]); } if (configMap.ContainsKey(s_setupUse2DForRoomVolume)) { configuration.Use2DRoomBoundaryForVolume = bool.Parse(configMap[s_setupUse2DForRoomVolume]); } if (configMap.ContainsKey(s_setupUseFamilyAndTypeName)) { configuration.UseFamilyAndTypeNameForReference = bool.Parse(configMap[s_setupUseFamilyAndTypeName]); } if (configMap.ContainsKey(s_setupExportPartsAsBuildingElements)) { configuration.ExportPartsAsBuildingElements = bool.Parse(configMap[s_setupExportPartsAsBuildingElements]); } if (configMap.ContainsKey(s_useActiveViewGeometry)) { configuration.UseActiveViewGeometry = bool.Parse(configMap[s_useActiveViewGeometry]); } if (configMap.ContainsKey(s_setupExportSpecificSchedules)) { configuration.ExportSpecificSchedules = bool.Parse(configMap[s_setupExportSpecificSchedules]); } if (configMap.ContainsKey(s_setupExportBoundingBox)) { configuration.ExportBoundingBox = bool.Parse(configMap[s_setupExportBoundingBox]); } if (configMap.ContainsKey(s_setupExportSolidModelRep)) { configuration.ExportSolidModelRep = bool.Parse(configMap[s_setupExportSolidModelRep]); } if (configMap.ContainsKey(s_setupExportSchedulesAsPsets)) { configuration.ExportSchedulesAsPsets = bool.Parse(configMap[s_setupExportSchedulesAsPsets]); } if (configMap.ContainsKey(s_setupExportUserDefinedPsets)) { configuration.ExportUserDefinedPsets = bool.Parse(configMap[s_setupExportUserDefinedPsets]); } if (configMap.ContainsKey(s_setupExportUserDefinedPsetsFileName)) { configuration.ExportUserDefinedPsetsFileName = configMap[s_setupExportUserDefinedPsetsFileName]; } if (configMap.ContainsKey(s_setupExportUserDefinedParameterMapping)) { configuration.ExportUserDefinedParameterMapping = bool.Parse(configMap[s_setupExportUserDefinedParameterMapping]); } if (configMap.ContainsKey(s_setupExportUserDefinedParameterMappingFileName)) { configuration.ExportUserDefinedParameterMappingFileName = configMap[s_setupExportUserDefinedParameterMappingFileName]; } if (configMap.ContainsKey(s_setupExportLinkedFiles)) { configuration.ExportLinkedFiles = bool.Parse(configMap[s_setupExportLinkedFiles]); } if (configMap.ContainsKey(s_setupIncludeSiteElevation)) { configuration.IncludeSiteElevation = bool.Parse(configMap[s_setupIncludeSiteElevation]); } if (configMap.ContainsKey(s_setupStoreIFCGUID)) { configuration.StoreIFCGUID = bool.Parse(configMap[s_setupStoreIFCGUID]); } if (configMap.ContainsKey(s_setupExportRoomsInView)) { configuration.ExportRoomsInView = bool.Parse(configMap[s_setupExportRoomsInView]); } if (configMap.ContainsKey(s_includeSteelElements)) { configuration.IncludeSteelElements = bool.Parse(configMap[s_includeSteelElements]); } if (configMap.ContainsKey(s_useTypeNameOnlyForIfcType)) { configuration.UseTypeNameOnlyForIfcType = bool.Parse(configMap[s_useTypeNameOnlyForIfcType]); } if (configMap.ContainsKey(s_useVisibleRevitNameAsEntityName)) { configuration.UseVisibleRevitNameAsEntityName = bool.Parse(configMap[s_useVisibleRevitNameAsEntityName]); } if (configMap.ContainsKey(s_useOnlyTriangulation)) { configuration.UseOnlyTriangulation = bool.Parse(configMap[s_useOnlyTriangulation]); } if (configMap.ContainsKey(s_setupTessellationLevelOfDetail)) { configuration.TessellationLevelOfDetail = double.Parse(configMap[s_setupTessellationLevelOfDetail]); } if (configMap.ContainsKey(s_setupSitePlacement)) { SiteTransformBasis siteTrfBasis = SiteTransformBasis.Shared; if (Enum.TryParse(configMap[s_setupSitePlacement], out siteTrfBasis)) { configuration.SitePlacement = siteTrfBasis; } } // Geo Reference info if (configMap.ContainsKey(s_selectedSite)) { configuration.SelectedSite = configMap[s_selectedSite]; } if (configMap.ContainsKey(s_geoRefCRSName)) { configuration.GeoRefCRSName = configMap[s_geoRefCRSName]; } if (configMap.ContainsKey(s_geoRefCRSDesc)) { configuration.GeoRefCRSDesc = configMap[s_geoRefCRSDesc]; } if (configMap.ContainsKey(s_geoRefEPSGCode)) { configuration.GeoRefEPSGCode = configMap[s_geoRefEPSGCode]; } if (configMap.ContainsKey(s_geoRefGeodeticDatum)) { configuration.GeoRefGeodeticDatum = configMap[s_geoRefGeodeticDatum]; } if (configMap.ContainsKey(s_geoRefMapUnit)) { configuration.GeoRefMapUnit = configMap[s_geoRefMapUnit]; } AddOrReplace(configuration); } } } // In this latest schema, the entire configuration for one config is stored as a json string in the entirety if (m_jsonSchema == null) { m_jsonSchema = Schema.Lookup(s_jsonSchemaId); if (m_jsonSchema != null) { foreach (DataStorage storedSetup in GetSavedConfigurations(m_jsonSchema)) { Entity configEntity = storedSetup.GetEntity(m_jsonSchema); string configData = configEntity.Get <string>(s_configMapField); JavaScriptSerializer ser = new JavaScriptSerializer(); IFCExportConfiguration configuration = ser.Deserialize <IFCExportConfiguration>(configData); AddOrReplace(configuration); } } } // Add the last selected configurations if any if (IFCExport.LastSelectedConfig != null && IFCExport.LastSelectedConfig.Count > 0) { foreach (KeyValuePair <string, IFCExportConfiguration> lastSelConfig in IFCExport.LastSelectedConfig) { AddOrReplace(lastSelConfig.Value); } } } catch (System.Exception) { // to avoid fail to show the dialog if any exception throws in reading schema. } }
/// <summary> /// Compute the Eastings, Northings, OrthogonalHeight from the selected SiteTransformationBasis /// </summary> /// <param name="doc">The document</param> /// <param name="wcsBasis">The selected coordinate base</param> /// <returns>A Tuple for Eastings, Northings, and OrthogonalHeight</returns> public static (double eastings, double northings, double orthogonalHeight, double angleTN, double origAngleTN) GeoReferenceInformation (Document doc, SiteTransformBasis wcsBasis, ProjectLocation projLocation = null) { double eastings = 0.0; double northings = 0.0; double orthogonalHeight = 0.0; double angleTN = 0.0; double origAngleTN = 0.0; using (Transaction tr = new Transaction(doc)) { try { tr.Start("Temp Project Location change"); } catch { } using (SubTransaction tempSiteLocTr = new SubTransaction(doc)) { tempSiteLocTr.Start(); if (projLocation != null) { doc.ActiveProjectLocation = projLocation; } BasePoint surveyPoint = BasePoint.GetSurveyPoint(doc); BasePoint projectBasePoint = BasePoint.GetProjectBasePoint(doc); (double svNorthings, double svEastings, double svElevation, double svAngle, double pbNorthings, double pbEastings, double pbElevation, double pbAngle) = ProjectLocationInfo(doc, surveyPoint.Position, projectBasePoint.Position); origAngleTN = pbAngle; switch (wcsBasis) { case SiteTransformBasis.Internal: Transform rotationTrfAtInternal = Transform.CreateRotationAtPoint(new XYZ(0, 0, 1), svAngle, XYZ.Zero); XYZ intPointOffset = rotationTrfAtInternal.OfPoint(surveyPoint.Position); northings = svNorthings - intPointOffset.Y; eastings = svEastings - intPointOffset.X; orthogonalHeight = surveyPoint.SharedPosition.Z - surveyPoint.Position.Z; angleTN = -svAngle; break; case SiteTransformBasis.InternalInTN: rotationTrfAtInternal = Transform.CreateRotationAtPoint(new XYZ(0, 0, 1), svAngle, XYZ.Zero); intPointOffset = rotationTrfAtInternal.OfPoint(surveyPoint.Position); northings = svNorthings - intPointOffset.Y; eastings = svEastings - intPointOffset.X; orthogonalHeight = surveyPoint.SharedPosition.Z - surveyPoint.Position.Z; angleTN = 0.0; break; case SiteTransformBasis.Project: northings = pbNorthings; eastings = pbEastings; orthogonalHeight = pbElevation; angleTN = -pbAngle; break; case SiteTransformBasis.ProjectInTN: northings = pbNorthings; eastings = pbEastings; orthogonalHeight = pbElevation; angleTN = 0.0; break; case SiteTransformBasis.Shared: northings = 0.0; eastings = 0.0; orthogonalHeight = 0.0; angleTN = 0.0; break; case SiteTransformBasis.Site: northings = svNorthings; eastings = svEastings; orthogonalHeight = svElevation; angleTN = 0.0; break; default: northings = 0.0; eastings = 0.0; orthogonalHeight = 0.0; angleTN = 0.0; break; } tempSiteLocTr.RollBack(); } } return(eastings, northings, orthogonalHeight, angleTN, origAngleTN); }