/// <summary> /// Base implementation to export IFC site object. /// </summary> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="document"> /// The Revit document. /// </param> /// <param name="element"> /// The element. /// </param> /// <param name="geometryElement"> /// The geometry element. /// </param> /// <param name="productWrapper"> /// The IFCProductWrapper. /// </param> private static void ExportSiteBase(ExporterIFC exporterIFC, Document document, Element element, GeometryElement geometryElement, IFCProductWrapper productWrapper) { IFCAnyHandle siteHandle = exporterIFC.GetSite(); int numSiteElements = (!IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle) ? 1 : 0); if (element == null && (numSiteElements != 0)) return; Document doc = document; if (doc == null) { if (element != null) doc = element.Document; else throw new ArgumentException("Both document and element are null."); } IFCFile file = exporterIFC.GetFile(); using (IFCTransaction tr = new IFCTransaction(file)) { IFCAnyHandle siteRepresentation = null; if (element != null) { // It would be possible that they actually represent several different sites with different buildings, // but until we have a concept of a building in Revit, we have to assume 0-1 sites, 1 building. bool appendedToSite = false; if (!IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle)) { IList<IFCAnyHandle> representations = IFCAnyHandleUtil.GetProductRepresentations(siteHandle); if (representations.Count > 0) { IFCAnyHandle bodyRep = representations[0]; IFCAnyHandle boundaryRep = null; if (representations.Count > 1) boundaryRep = representations[1]; siteRepresentation = RepresentationUtil.CreateSurfaceProductDefinitionShape(exporterIFC, element, geometryElement, true, true, ref bodyRep, ref boundaryRep); appendedToSite = true; } } if (!appendedToSite) { siteRepresentation = RepresentationUtil.CreateSurfaceProductDefinitionShape(exporterIFC, element, geometryElement, true, true); } } List<int> latitude = new List<int>(); List<int> longitude = new List<int>(); ProjectLocation projLocation = doc.ActiveProjectLocation; IFCAnyHandle relativePlacement = null; double elevation = 0.0; if (projLocation != null) { double latitudeInDeg = projLocation.SiteLocation.Latitude * 180 / Math.PI; double longitudeInDeg = projLocation.SiteLocation.Longitude * 180 / Math.PI; int latDeg = ((int)latitudeInDeg); latitudeInDeg -= latDeg; latitudeInDeg *= 60; int latMin = ((int)latitudeInDeg); latitudeInDeg -= latMin; latitudeInDeg *= 60; int latSec = ((int)latitudeInDeg); latitudeInDeg -= latSec; latitudeInDeg *= 1000000; int latFracSec = ((int)latitudeInDeg); latitude.Add(latDeg); latitude.Add(latMin); latitude.Add(latSec); if (!exporterIFC.ExportAs2x2) latitude.Add(latFracSec); int longDeg = ((int)longitudeInDeg); longitudeInDeg -= longDeg; longitudeInDeg *= 60; int longMin = ((int)longitudeInDeg); longitudeInDeg -= longMin; longitudeInDeg *= 60; int longSec = ((int)longitudeInDeg); longitudeInDeg -= longSec; longitudeInDeg *= 1000000; int longFracSec = ((int)longitudeInDeg); longitude.Add(longDeg); longitude.Add(longMin); longitude.Add(longSec); if (!exporterIFC.ExportAs2x2) longitude.Add(longFracSec); Transform siteSharedCoordinatesTrf = projLocation.GetTransform().Inverse; if (!siteSharedCoordinatesTrf.IsIdentity) { XYZ orig = siteSharedCoordinatesTrf.Origin; orig = orig.Multiply(exporterIFC.LinearScale); relativePlacement = ExporterUtil.CreateAxis2Placement3D(file, orig, siteSharedCoordinatesTrf.BasisZ, siteSharedCoordinatesTrf.BasisX); } } // Get elevation for site. elevation = -LevelUtil.GetReferenceHeightForRelativeElevation(doc) * exporterIFC.LinearScale; if (IFCAnyHandleUtil.IsNullOrHasNoValue(relativePlacement)) relativePlacement = ExporterUtil.CreateAxis2Placement3D(file); IFCAnyHandle localPlacement = IFCInstanceExporter.CreateLocalPlacement(file, null, relativePlacement); IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle(); string objectType = NamingUtil.CreateIFCObjectName(exporterIFC, element); if (element != null) { if (IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle)) { string instanceGUID = ExporterIFCUtils.CreateGUID(element); string origInstanceName = exporterIFC.GetName(); string instanceName = NamingUtil.GetNameOverride(element, origInstanceName); string instanceDescription = NamingUtil.GetDescriptionOverride(element, null); string instanceObjectType = NamingUtil.GetObjectTypeOverride(element, objectType); string instanceElemId = NamingUtil.CreateIFCElementId(element); siteHandle = IFCInstanceExporter.CreateSite(file, instanceGUID, ownerHistory, instanceName, instanceDescription, instanceObjectType, localPlacement, siteRepresentation, null, Toolkit.IFCElementComposition.Element, latitude, longitude, elevation, null, null); } } else { // don't bother if we have nothing in the site whatsoever. if ((latitude.Count == 0 || longitude.Count == 0) && IFCAnyHandleUtil.IsNullOrHasNoValue(relativePlacement)) return; string defaultSiteName = "Default"; siteHandle = IFCInstanceExporter.CreateSite(file, ExporterIFCUtils.CreateProjectLevelGUID(doc, IFCProjectLevelGUIDType.Site), ownerHistory, defaultSiteName, null, objectType, localPlacement, null, null, Toolkit.IFCElementComposition.Element, latitude, longitude, elevation, null, null); } productWrapper.AddSite(siteHandle); exporterIFC.SetSite(siteHandle); tr.Commit(); } }
/// <summary> /// Base implementation to export IFC site object. /// </summary> /// <param name="exporterIFC">The ExporterIFC object.</param> /// <param name="document">The Revit document. It may be null if element isn't.</param> /// <param name="element">The element. It may be null if document isn't.</param> /// <param name="geometryElement">The geometry element.</param> /// <param name="productWrapper">The ProductWrapper.</param> private static void ExportSiteBase(ExporterIFC exporterIFC, Document document, Element element, GeometryElement geometryElement, ProductWrapper productWrapper) { IFCAnyHandle siteHandle = exporterIFC.GetSite(); int numSiteElements = (!IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle) ? 1 : 0); if (element == null && (numSiteElements != 0)) return; Document doc = document; if (doc == null) { if (element != null) doc = element.Document; else throw new ArgumentException("Both document and element are null."); } IFCFile file = exporterIFC.GetFile(); using (IFCTransaction tr = new IFCTransaction(file)) { IFCAnyHandle siteRepresentation = null; if (element != null) { // It would be possible that they actually represent several different sites with different buildings, // but until we have a concept of a building in Revit, we have to assume 0-1 sites, 1 building. bool appendedToSite = false; bool exportAsFacetation = !ExporterCacheManager.ExportOptionsCache.ExportAsCoordinationView2; if (!IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle)) { IList<IFCAnyHandle> representations = IFCAnyHandleUtil.GetProductRepresentations(siteHandle); if (representations.Count > 0) { IFCAnyHandle bodyRep = representations[0]; IFCAnyHandle boundaryRep = null; if (representations.Count > 1) boundaryRep = representations[1]; siteRepresentation = RepresentationUtil.CreateSurfaceProductDefinitionShape(exporterIFC, element, geometryElement, true, exportAsFacetation, ref bodyRep, ref boundaryRep); if (representations.Count == 1 && !IFCAnyHandleUtil.IsNullOrHasNoValue(boundaryRep)) { // If the first site has no boundaryRep, // we will add the boundaryRep from second site to it. representations.Clear(); representations.Add(boundaryRep); IFCAnyHandleUtil.AddProductRepresentations(siteHandle, representations); } appendedToSite = true; } } if (!appendedToSite) { siteRepresentation = RepresentationUtil.CreateSurfaceProductDefinitionShape(exporterIFC, element, geometryElement, true, exportAsFacetation); } } List<int> latitude = new List<int>(); List<int> longitude = new List<int>(); ProjectLocation projLocation = doc.ActiveProjectLocation; IFCAnyHandle relativePlacement = null; double unscaledElevation = 0.0; if (projLocation != null) { const double scaleToDegrees = 180 / Math.PI; double latitudeInDeg = projLocation.SiteLocation.Latitude * scaleToDegrees; double longitudeInDeg = projLocation.SiteLocation.Longitude * scaleToDegrees; ExporterUtil.GetSafeProjectPositionAngle(doc, out unscaledElevation); int latDeg = ((int)latitudeInDeg); latitudeInDeg -= latDeg; latitudeInDeg *= 60; int latMin = ((int)latitudeInDeg); latitudeInDeg -= latMin; latitudeInDeg *= 60; int latSec = ((int)latitudeInDeg); latitudeInDeg -= latSec; latitudeInDeg *= 1000000; int latFracSec = ((int)latitudeInDeg); latitude.Add(latDeg); latitude.Add(latMin); latitude.Add(latSec); if (!ExporterCacheManager.ExportOptionsCache.ExportAs2x2) latitude.Add(latFracSec); int longDeg = ((int)longitudeInDeg); longitudeInDeg -= longDeg; longitudeInDeg *= 60; int longMin = ((int)longitudeInDeg); longitudeInDeg -= longMin; longitudeInDeg *= 60; int longSec = ((int)longitudeInDeg); longitudeInDeg -= longSec; longitudeInDeg *= 1000000; int longFracSec = ((int)longitudeInDeg); longitude.Add(longDeg); longitude.Add(longMin); longitude.Add(longSec); if (!ExporterCacheManager.ExportOptionsCache.ExportAs2x2) longitude.Add(longFracSec); Transform siteSharedCoordinatesTrf = projLocation.GetTransform().Inverse; if (!siteSharedCoordinatesTrf.IsIdentity) { double unscaledSiteElevation = ExporterCacheManager.ExportOptionsCache.IncludeSiteElevation ? 0.0 : unscaledElevation; XYZ orig = UnitUtil.ScaleLength(siteSharedCoordinatesTrf.Origin - new XYZ(0, 0, unscaledSiteElevation)); relativePlacement = ExporterUtil.CreateAxis2Placement3D(file, orig, siteSharedCoordinatesTrf.BasisZ, siteSharedCoordinatesTrf.BasisX); } } // Get elevation for site. double elevation = UnitUtil.ScaleLength(unscaledElevation); if (IFCAnyHandleUtil.IsNullOrHasNoValue(relativePlacement)) relativePlacement = ExporterUtil.CreateAxis2Placement3D(file); IFCAnyHandle localPlacement = IFCInstanceExporter.CreateLocalPlacement(file, null, relativePlacement); IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle(); string siteObjectType = NamingUtil.CreateIFCObjectName(exporterIFC, element); ProjectInfo projectInfo = doc.ProjectInformation; Element mainSiteElement = (element != null) ? element : projectInfo; bool exportSite = false; string siteGUID = null; string siteName = null; string siteLongName = null; string siteLandTitleNumber = null; string siteDescription = null; if (element != null) { if (IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle)) { exportSite = true; // We will use the Project Information site name as the primary name, if it exists. siteGUID = GUIDUtil.CreateSiteGUID(doc, element); siteName = NamingUtil.GetOverrideStringValue(projectInfo, "SiteName", NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element))); siteDescription = NamingUtil.GetDescriptionOverride(element, null); siteObjectType = NamingUtil.GetObjectTypeOverride(element, siteObjectType); // Look in site element for "IfcLongName" or project information for either "IfcLongName" or "SiteLongName". siteLongName = NamingUtil.GetLongNameOverride(projectInfo, NamingUtil.GetLongNameOverride(element, null)); if (string.IsNullOrWhiteSpace(siteLongName)) siteLongName = NamingUtil.GetOverrideStringValue(projectInfo, "SiteLongName", null); // Look in site element for "IfcLandTitleNumber" or project information for "SiteLandTitleNumber". siteLandTitleNumber = NamingUtil.GetOverrideStringValue(element, "IfcLandTitleNumber", null); if (string.IsNullOrWhiteSpace(siteLandTitleNumber)) siteLandTitleNumber = NamingUtil.GetOverrideStringValue(projectInfo, "SiteLandTitleNumber", null); } } else { exportSite = true; siteGUID = GUIDUtil.CreateProjectLevelGUID(doc, IFCProjectLevelGUIDType.Site); siteName = NamingUtil.GetOverrideStringValue(projectInfo, "SiteName", "Default"); siteLongName = NamingUtil.GetLongNameOverride(projectInfo, NamingUtil.GetOverrideStringValue(projectInfo, "SiteLongName", null)); siteLandTitleNumber = NamingUtil.GetOverrideStringValue(projectInfo, "SiteLandTitleNumber", null); // don't bother if we have nothing in the site whatsoever. if ((latitude.Count == 0 || longitude.Count == 0) && IFCAnyHandleUtil.IsNullOrHasNoValue(relativePlacement) && string.IsNullOrWhiteSpace(siteLongName) && string.IsNullOrWhiteSpace(siteLandTitleNumber)) return; } if (exportSite) { siteHandle = IFCInstanceExporter.CreateSite(file, siteGUID, ownerHistory, siteName, siteDescription, siteObjectType, localPlacement, siteRepresentation, siteLongName, Toolkit.IFCElementComposition.Element, latitude, longitude, elevation, siteLandTitleNumber, null); productWrapper.AddSite(mainSiteElement, siteHandle); exporterIFC.SetSite(siteHandle); } tr.Commit(); } }
/// <summary> /// Base implementation to export IFC site object. /// </summary> /// <param name="exporterIFC">The ExporterIFC object.</param> /// <param name="document">The Revit document. It may be null if element isn't.</param> /// <param name="element">The element. It may be null if document isn't.</param> /// <param name="geometryElement">The geometry element.</param> /// <param name="productWrapper">The ProductWrapper.</param> private static void ExportSiteBase(ExporterIFC exporterIFC, Document document, Element element, GeometryElement geometryElement, ProductWrapper productWrapper) { IFCAnyHandle siteHandle = exporterIFC.GetSite(); int numSiteElements = (!IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle) ? 1 : 0); if (element == null && (numSiteElements != 0)) { return; } Document doc = document; if (doc == null) { if (element != null) { doc = element.Document; } else { throw new ArgumentException("Both document and element are null."); } } IFCFile file = exporterIFC.GetFile(); using (IFCTransaction tr = new IFCTransaction(file)) { IFCAnyHandle siteRepresentation = null; if (element != null) { // It would be possible that they actually represent several different sites with different buildings, // but until we have a concept of a building in Revit, we have to assume 0-1 sites, 1 building. bool appendedToSite = false; bool exportAsFacetation = !ExporterCacheManager.ExportOptionsCache.ExportAsCoordinationView2; if (!IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle)) { IList <IFCAnyHandle> representations = IFCAnyHandleUtil.GetProductRepresentations(siteHandle); if (representations.Count > 0) { IFCAnyHandle bodyRep = representations[0]; IFCAnyHandle boundaryRep = null; if (representations.Count > 1) { boundaryRep = representations[1]; } siteRepresentation = RepresentationUtil.CreateSurfaceProductDefinitionShape(exporterIFC, element, geometryElement, true, exportAsFacetation, ref bodyRep, ref boundaryRep); if (representations.Count == 1 && !IFCAnyHandleUtil.IsNullOrHasNoValue(boundaryRep)) { // If the first site has no boundaryRep, // we will add the boundaryRep from second site to it. representations.Clear(); representations.Add(boundaryRep); IFCAnyHandleUtil.AddProductRepresentations(siteHandle, representations); } appendedToSite = true; } } if (!appendedToSite) { siteRepresentation = RepresentationUtil.CreateSurfaceProductDefinitionShape(exporterIFC, element, geometryElement, true, exportAsFacetation); } } List <int> latitude = new List <int>(); List <int> longitude = new List <int>(); ProjectLocation projLocation = doc.ActiveProjectLocation; IFCAnyHandle relativePlacement = null; double unscaledElevation = 0.0; if (projLocation != null) { const double scaleToDegrees = 180 / Math.PI; double latitudeInDeg = projLocation.SiteLocation.Latitude * scaleToDegrees; double longitudeInDeg = projLocation.SiteLocation.Longitude * scaleToDegrees; ExporterUtil.GetSafeProjectPositionAngle(doc, out unscaledElevation); int latDeg = ((int)latitudeInDeg); latitudeInDeg -= latDeg; latitudeInDeg *= 60; int latMin = ((int)latitudeInDeg); latitudeInDeg -= latMin; latitudeInDeg *= 60; int latSec = ((int)latitudeInDeg); latitudeInDeg -= latSec; latitudeInDeg *= 1000000; int latFracSec = ((int)latitudeInDeg); latitude.Add(latDeg); latitude.Add(latMin); latitude.Add(latSec); if (!ExporterCacheManager.ExportOptionsCache.ExportAs2x2) { latitude.Add(latFracSec); } int longDeg = ((int)longitudeInDeg); longitudeInDeg -= longDeg; longitudeInDeg *= 60; int longMin = ((int)longitudeInDeg); longitudeInDeg -= longMin; longitudeInDeg *= 60; int longSec = ((int)longitudeInDeg); longitudeInDeg -= longSec; longitudeInDeg *= 1000000; int longFracSec = ((int)longitudeInDeg); longitude.Add(longDeg); longitude.Add(longMin); longitude.Add(longSec); if (!ExporterCacheManager.ExportOptionsCache.ExportAs2x2) { longitude.Add(longFracSec); } Transform siteSharedCoordinatesTrf = projLocation.GetTransform().Inverse; if (!siteSharedCoordinatesTrf.IsIdentity) { double unscaledSiteElevation = ExporterCacheManager.ExportOptionsCache.IncludeSiteElevation ? 0.0 : unscaledElevation; XYZ orig = UnitUtil.ScaleLength(siteSharedCoordinatesTrf.Origin - new XYZ(0, 0, unscaledSiteElevation)); relativePlacement = ExporterUtil.CreateAxis2Placement3D(file, orig, siteSharedCoordinatesTrf.BasisZ, siteSharedCoordinatesTrf.BasisX); } } // Get elevation for site. double elevation = UnitUtil.ScaleLength(unscaledElevation); if (IFCAnyHandleUtil.IsNullOrHasNoValue(relativePlacement)) { relativePlacement = ExporterUtil.CreateAxis2Placement3D(file); } IFCAnyHandle localPlacement = IFCInstanceExporter.CreateLocalPlacement(file, null, relativePlacement); IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle(); string siteObjectType = NamingUtil.CreateIFCObjectName(exporterIFC, element); ProjectInfo projectInfo = doc.ProjectInformation; Element mainSiteElement = (element != null) ? element : projectInfo; bool exportSite = false; string siteGUID = null; string siteName = null; string siteLongName = null; string siteLandTitleNumber = null; string siteDescription = null; if (element != null) { if (IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle)) { exportSite = true; // We will use the Project Information site name as the primary name, if it exists. siteGUID = GUIDUtil.CreateSiteGUID(doc, element); siteName = NamingUtil.GetOverrideStringValue(projectInfo, "SiteName", NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element))); siteDescription = NamingUtil.GetDescriptionOverride(element, null); siteObjectType = NamingUtil.GetObjectTypeOverride(element, siteObjectType); // Look in site element for "IfcLongName" or project information for either "IfcLongName" or "SiteLongName". siteLongName = NamingUtil.GetLongNameOverride(projectInfo, NamingUtil.GetLongNameOverride(element, null)); if (string.IsNullOrWhiteSpace(siteLongName)) { siteLongName = NamingUtil.GetOverrideStringValue(projectInfo, "SiteLongName", null); } // Look in site element for "IfcLandTitleNumber" or project information for "SiteLandTitleNumber". siteLandTitleNumber = NamingUtil.GetOverrideStringValue(element, "IfcLandTitleNumber", null); if (string.IsNullOrWhiteSpace(siteLandTitleNumber)) { siteLandTitleNumber = NamingUtil.GetOverrideStringValue(projectInfo, "SiteLandTitleNumber", null); } } } else { exportSite = true; siteGUID = GUIDUtil.CreateProjectLevelGUID(doc, IFCProjectLevelGUIDType.Site); siteName = NamingUtil.GetOverrideStringValue(projectInfo, "SiteName", "Default"); siteLongName = NamingUtil.GetLongNameOverride(projectInfo, NamingUtil.GetOverrideStringValue(projectInfo, "SiteLongName", null)); siteLandTitleNumber = NamingUtil.GetOverrideStringValue(projectInfo, "SiteLandTitleNumber", null); // don't bother if we have nothing in the site whatsoever. if ((latitude.Count == 0 || longitude.Count == 0) && IFCAnyHandleUtil.IsNullOrHasNoValue(relativePlacement) && string.IsNullOrWhiteSpace(siteLongName) && string.IsNullOrWhiteSpace(siteLandTitleNumber)) { return; } } if (exportSite) { siteHandle = IFCInstanceExporter.CreateSite(file, siteGUID, ownerHistory, siteName, siteDescription, siteObjectType, localPlacement, siteRepresentation, siteLongName, Toolkit.IFCElementComposition.Element, latitude, longitude, elevation, siteLandTitleNumber, null); productWrapper.AddSite(mainSiteElement, siteHandle); exporterIFC.SetSite(siteHandle); } tr.Commit(); } }
/// <summary> /// Base implementation to export IFC site object. /// </summary> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="document"> /// The Revit document. /// </param> /// <param name="element"> /// The element. /// </param> /// <param name="geometryElement"> /// The geometry element. /// </param> /// <param name="productWrapper"> /// The IFCProductWrapper. /// </param> private static void ExportSiteBase(ExporterIFC exporterIFC, Document document, Element element, GeometryElement geometryElement, IFCProductWrapper productWrapper) { IFCAnyHandle siteHandle = exporterIFC.GetSite(); int numSiteElements = (!IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle) ? 1 : 0); if (element == null && (numSiteElements != 0)) { return; } Document doc = document; if (doc == null) { if (element != null) { doc = element.Document; } else { throw new ArgumentException("Both document and element are null."); } } IFCFile file = exporterIFC.GetFile(); using (IFCTransaction tr = new IFCTransaction(file)) { IFCAnyHandle siteRepresentation = null; if (element != null) { // It would be possible that they actually represent several different sites with different buildings, // but until we have a concept of a building in Revit, we have to assume 0-1 sites, 1 building. bool appendedToSite = false; if (!IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle)) { IList <IFCAnyHandle> representations = IFCAnyHandleUtil.GetProductRepresentations(siteHandle); if (representations.Count > 0) { IFCAnyHandle bodyRep = representations[0]; IFCAnyHandle boundaryRep = null; if (representations.Count > 1) { boundaryRep = representations[1]; } siteRepresentation = RepresentationUtil.CreateSurfaceProductDefinitionShape(exporterIFC, element, geometryElement, true, true, ref bodyRep, ref boundaryRep); appendedToSite = true; } } if (!appendedToSite) { siteRepresentation = RepresentationUtil.CreateSurfaceProductDefinitionShape(exporterIFC, element, geometryElement, true, true); } } List <int> latitude = new List <int>(); List <int> longitude = new List <int>(); ProjectLocation projLocation = doc.ActiveProjectLocation; IFCAnyHandle relativePlacement = null; double elevation = 0.0; if (projLocation != null) { double latitudeInDeg = projLocation.SiteLocation.Latitude * 180 / Math.PI; double longitudeInDeg = projLocation.SiteLocation.Longitude * 180 / Math.PI; int latDeg = ((int)latitudeInDeg); latitudeInDeg -= latDeg; latitudeInDeg *= 60; int latMin = ((int)latitudeInDeg); latitudeInDeg -= latMin; latitudeInDeg *= 60; int latSec = ((int)latitudeInDeg); latitudeInDeg -= latSec; latitudeInDeg *= 1000000; int latFracSec = ((int)latitudeInDeg); latitude.Add(latDeg); latitude.Add(latMin); latitude.Add(latSec); if (!exporterIFC.ExportAs2x2) { latitude.Add(latFracSec); } int longDeg = ((int)longitudeInDeg); longitudeInDeg -= longDeg; longitudeInDeg *= 60; int longMin = ((int)longitudeInDeg); longitudeInDeg -= longMin; longitudeInDeg *= 60; int longSec = ((int)longitudeInDeg); longitudeInDeg -= longSec; longitudeInDeg *= 1000000; int longFracSec = ((int)longitudeInDeg); longitude.Add(longDeg); longitude.Add(longMin); longitude.Add(longSec); if (!exporterIFC.ExportAs2x2) { longitude.Add(longFracSec); } Transform siteSharedCoordinatesTrf = projLocation.GetTransform().Inverse; if (!siteSharedCoordinatesTrf.IsIdentity) { XYZ orig = siteSharedCoordinatesTrf.Origin; orig = orig.Multiply(exporterIFC.LinearScale); relativePlacement = ExporterUtil.CreateAxis2Placement3D(file, orig, siteSharedCoordinatesTrf.BasisZ, siteSharedCoordinatesTrf.BasisX); } } // Get elevation for site. elevation = -LevelUtil.GetReferenceHeightForRelativeElevation(doc) * exporterIFC.LinearScale; if (IFCAnyHandleUtil.IsNullOrHasNoValue(relativePlacement)) { relativePlacement = ExporterUtil.CreateAxis2Placement3D(file); } IFCAnyHandle localPlacement = IFCInstanceExporter.CreateLocalPlacement(file, null, relativePlacement); IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle(); string objectType = NamingUtil.CreateIFCObjectName(exporterIFC, element); if (element != null) { if (IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle)) { string instanceGUID = ExporterIFCUtils.CreateGUID(element); string origInstanceName = exporterIFC.GetName(); string instanceName = NamingUtil.GetNameOverride(element, origInstanceName); string instanceDescription = NamingUtil.GetDescriptionOverride(element, null); string instanceObjectType = NamingUtil.GetObjectTypeOverride(element, objectType); string instanceElemId = NamingUtil.CreateIFCElementId(element); siteHandle = IFCInstanceExporter.CreateSite(file, instanceGUID, ownerHistory, instanceName, instanceDescription, instanceObjectType, localPlacement, siteRepresentation, null, Toolkit.IFCElementComposition.Element, latitude, longitude, elevation, null, null); } } else { // don't bother if we have nothing in the site whatsoever. if ((latitude.Count == 0 || longitude.Count == 0) && IFCAnyHandleUtil.IsNullOrHasNoValue(relativePlacement)) { return; } string defaultSiteName = "Default"; siteHandle = IFCInstanceExporter.CreateSite(file, ExporterIFCUtils.CreateProjectLevelGUID(doc, IFCProjectLevelGUIDType.Site), ownerHistory, defaultSiteName, null, objectType, localPlacement, null, null, Toolkit.IFCElementComposition.Element, latitude, longitude, elevation, null, null); } productWrapper.AddSite(siteHandle); exporterIFC.SetSite(siteHandle); tr.Commit(); } }