本文整理汇总了C#中ExporterIFC.GetSite方法的典型用法代码示例。如果您正苦于以下问题:C# ExporterIFC.GetSite方法的具体用法?C# ExporterIFC.GetSite怎么用?C# ExporterIFC.GetSite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExporterIFC
的用法示例。
在下文中一共展示了ExporterIFC.GetSite方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportSiteBase
/// <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)
{
//.........这里部分代码省略.........
示例2: EndExport
//.........这里部分代码省略.........
string guid = GUIDUtil.CreateSubElementGUID(group, (int)IFCGroupSubElements.RelAssignsToGroup);
IFCAnyHandle groupHandle = groupInfo.GroupHandle;
HashSet<IFCAnyHandle> elementHandles = groupInfo.ElementHandles;
if (elementHandles != null && groupHandle != null && elementHandles.Contains(groupHandle))
elementHandles.Remove(groupHandle);
if (elementHandles != null && groupHandle != null && elementHandles.Count > 0)
{
IFCInstanceExporter.CreateRelAssignsToGroup(file, guid, ownerHistory, null, null, elementHandles, null, groupHandle);
}
}
}
// create spatial structure holder
ICollection<IFCAnyHandle> relatedElements = exporterIFC.GetRelatedElements();
if (relatedElements.Count > 0)
{
HashSet<IFCAnyHandle> relatedElementSet = new HashSet<IFCAnyHandle>(relatedElements);
string guid = GUIDUtil.CreateSubElementGUID(projectInfo, (int)IFCBuildingSubElements.RelContainedInSpatialStructure);
IFCInstanceExporter.CreateRelContainedInSpatialStructure(file, guid,
ownerHistory, null, null, relatedElementSet, buildingHnd);
}
ICollection<IFCAnyHandle> relatedProducts = exporterIFC.GetRelatedProducts();
if (relatedProducts.Count > 0)
{
string guid = GUIDUtil.CreateSubElementGUID(projectInfo, (int)IFCBuildingSubElements.RelAggregatesProducts);
ExporterCacheManager.ContainmentCache.SetGUIDForRelation(buildingHnd, guid);
ExporterCacheManager.ContainmentCache.AddRelations(buildingHnd, relatedProducts);
}
// create a default site if we have latitude and longitude information.
if (IFCAnyHandleUtil.IsNullOrHasNoValue(exporterIFC.GetSite()))
{
using (ProductWrapper productWrapper = ProductWrapper.Create(exporterIFC, true))
{
SiteExporter.ExportDefaultSite(exporterIFC, document, productWrapper);
}
}
IFCAnyHandle siteHandle = exporterIFC.GetSite();
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle))
{
ExporterCacheManager.ContainmentCache.AddRelation(exporterIFC.GetProject(), siteHandle);
// assoc. site to the building.
ExporterCacheManager.ContainmentCache.AddRelation(siteHandle, buildingHnd);
ExporterUtil.UpdateBuildingRelToPlacement(buildingHnd, siteHandle);
}
else
{
// relate building and project if no site
ExporterCacheManager.ContainmentCache.AddRelation(exporterIFC.GetProject(), buildingHnd);
}
// relate levels and products.
RelateLevels(exporterIFC, document);
// relate objects in containment cache.
foreach (KeyValuePair<IFCAnyHandle, ICollection<IFCAnyHandle>> container in ExporterCacheManager.ContainmentCache)
{
if (container.Value.Count() > 0)
{
string relationGUID = ExporterCacheManager.ContainmentCache.GetGUIDForRelation(container.Key);
示例3: EndExport
/// <summary>
/// Completes the export process by writing information stored incrementally during export to the file.
/// </summary>
/// <param name="exporterIFC">The IFC exporter object.</param>
/// <param name="document">The document to export.</param>
private void EndExport(ExporterIFC exporterIFC, Document document)
{
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction transaction = new IFCTransaction(file))
{
foreach (KeyValuePair<ElementId, StairRampContainerInfo> stairRamp in ExporterCacheManager.StairRampContainerInfoCache)
{
StairRampContainerInfo stairRampInfo = stairRamp.Value;
IList<IFCAnyHandle> hnds = stairRampInfo.StairOrRampHandles;
for (int ii = 0; ii < hnds.Count; ii++)
{
IFCAnyHandle hnd = hnds[ii];
if (IFCAnyHandleUtil.IsNullOrHasNoValue(hnd))
continue;
IList<IFCAnyHandle> comps = stairRampInfo.Components[ii];
if (comps.Count == 0)
continue;
Element elem = document.GetElement(stairRamp.Key);
string guid = ExporterIFCUtils.CreateSubElementGUID(elem, (int)IFCStairSubElements.ContainmentRelation);
ExporterUtil.RelateObjects(exporterIFC, guid, hnd, comps);
}
}
ProjectInfo projectInfo = document.ProjectInformation;
IFCAnyHandle buildingHnd = exporterIFC.GetBuilding();
// relate assembly elements to assemblies
foreach (KeyValuePair<ElementId, AssemblyInstanceInfo> assemblyInfoEntry in ExporterCacheManager.AssemblyInstanceCache)
{
AssemblyInstanceInfo assemblyInfo = assemblyInfoEntry.Value;
if (assemblyInfo == null)
continue;
if (assemblyInfo.AssemblyInstanceHandle != null && assemblyInfo.ElementHandles != null &&
assemblyInfo.ElementHandles.Count != 0)
{
Element assemblyInstance = document.GetElement(assemblyInfoEntry.Key);
string guid = ExporterIFCUtils.CreateSubElementGUID(assemblyInstance, (int)IFCAssemblyInstanceSubElements.RelContainedInSpatialStructure);
ExporterUtil.RelateObjects(exporterIFC, guid, assemblyInfo.AssemblyInstanceHandle, assemblyInfo.ElementHandles);
// Set the PlacementRelTo of assembly elements to assembly instance.
IFCAnyHandle assemblyPlacement = IFCAnyHandleUtil.GetObjectPlacement(assemblyInfo.AssemblyInstanceHandle);
foreach (IFCAnyHandle elementHandle in assemblyInfo.ElementHandles)
{
// NOTE: caution that old IFCAXIS2PLACEMENT3D will be unused as the new one replace it.
// But we cannot delete it safely yet because we don't know if any handle is referencing it.
IFCAnyHandle elementPlacement = IFCAnyHandleUtil.GetObjectPlacement(elementHandle);
Transform relTrf = ExporterIFCUtils.GetRelativeLocalPlacementOffsetTransform(assemblyPlacement, elementPlacement);
Transform inverseTrf = relTrf.Inverse;
IFCAnyHandle relLocalPlacement = ExporterUtil.CreateAxis2Placement3D(file, inverseTrf.Origin, inverseTrf.BasisZ, inverseTrf.BasisX);
IFCAnyHandleUtil.SetAttribute(elementPlacement, "PlacementRelTo", assemblyPlacement);
GeometryUtil.SetRelativePlacement(elementPlacement, relLocalPlacement);
}
}
}
// create spatial structure holder
ICollection<IFCAnyHandle> relatedElements = exporterIFC.GetRelatedElements();
if (relatedElements.Count > 0)
{
HashSet<IFCAnyHandle> relatedElementSet = new HashSet<IFCAnyHandle>(relatedElements);
IFCInstanceExporter.CreateRelContainedInSpatialStructure(file,
ExporterIFCUtils.CreateSubElementGUID(projectInfo, (int)IFCBuildingSubElements.RelContainedInSpatialStructure),
exporterIFC.GetOwnerHistoryHandle(), null, null, relatedElementSet, buildingHnd);
}
ICollection<IFCAnyHandle> relatedProducts = exporterIFC.GetRelatedProducts();
if (relatedProducts.Count > 0)
{
string guid = ExporterIFCUtils.CreateSubElementGUID(projectInfo, (int)IFCBuildingSubElements.RelAggregatesProducts);
ExporterCacheManager.ContainmentCache.SetGUIDForRelation(buildingHnd, guid);
ExporterCacheManager.ContainmentCache.AddRelations(buildingHnd, relatedProducts);
}
// create a default site if we have latitude and longitude information.
if (IFCAnyHandleUtil.IsNullOrHasNoValue(exporterIFC.GetSite()))
{
using (ProductWrapper productWrapper = ProductWrapper.Create(exporterIFC, true))
{
SiteExporter.ExportDefaultSite(exporterIFC, document, productWrapper);
}
}
IFCAnyHandle siteHandle = exporterIFC.GetSite();
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle))
{
ExporterCacheManager.ContainmentCache.AddRelation(exporterIFC.GetProject(), siteHandle);
// assoc. site to the building.
ExporterCacheManager.ContainmentCache.AddRelation(siteHandle, buildingHnd);
ExporterUtil.UpdateBuildingPlacement(buildingHnd, siteHandle);
//.........这里部分代码省略.........
示例4: ExportSiteBase
/// <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)
//.........这里部分代码省略.........
示例5: EndExport
/// <summary>
/// Completes the export process by writing information stored incrementally during export to the file.
/// </summary>
/// <param name="exporterIFC">The IFC exporter object.</param>
/// <param name="document">The document to export.</param>
private void EndExport(ExporterIFC exporterIFC, Document document)
{
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction transaction = new IFCTransaction(file))
{
foreach (KeyValuePair<ElementId, StairRampContainerInfo> stairRamp in ExporterCacheManager.StairRampContainerInfoCache)
{
StairRampContainerInfo stairRampInfo = stairRamp.Value;
IList<IFCAnyHandle> hnds = stairRampInfo.StairOrRampHandles;
for (int ii = 0; ii < hnds.Count; ii++)
{
IFCAnyHandle hnd = hnds[ii];
if (IFCAnyHandleUtil.IsNullOrHasNoValue(hnd))
continue;
IList<IFCAnyHandle> comps = stairRampInfo.Components[ii];
if (comps.Count == 0)
continue;
Element elem = document.GetElement(stairRamp.Key);
string guid = ExporterIFCUtils.CreateSubElementGUID(elem, (int) IFCStairSubElements.ContainmentRelation);
ExporterUtil.RelateObjects(exporterIFC, guid, hnd, comps);
}
}
ProjectInfo projectInfo = document.ProjectInformation;
// relate assembly elements to assemblies
foreach (KeyValuePair<ElementId, AssemblyInstanceInfo> assemblyInfoEntry in ExporterCacheManager.AssemblyInstanceCache)
{
AssemblyInstanceInfo assemblyInfo = assemblyInfoEntry.Value;
if (assemblyInfo == null)
continue;
if (assemblyInfo.AssemblyInstanceHandle != null && assemblyInfo.ElementHandles != null &&
assemblyInfo.ElementHandles.Count != 0)
{
Element assemblyInstance = document.GetElement(assemblyInfoEntry.Key);
string guid = ExporterIFCUtils.CreateSubElementGUID(assemblyInstance, (int)IFCAssemblyInstanceSubElements.RelContainedInSpatialStructure);
ExporterUtil.RelateObjects(exporterIFC, guid, assemblyInfo.AssemblyInstanceHandle, assemblyInfo.ElementHandles);
}
}
// create spatial structure holder
ICollection<IFCAnyHandle> relatedElements = exporterIFC.GetRelatedElements();
if (relatedElements.Count > 0)
{
HashSet<IFCAnyHandle> relatedElementSet = new HashSet<IFCAnyHandle>(relatedElements);
IFCInstanceExporter.CreateRelContainedInSpatialStructure(file,
ExporterIFCUtils.CreateSubElementGUID(projectInfo, (int)IFCBuildingSubElements.RelContainedInSpatialStructure),
exporterIFC.GetOwnerHistoryHandle(), null, null, relatedElementSet, exporterIFC.GetBuilding());
}
ICollection<IFCAnyHandle> relatedProducts = exporterIFC.GetRelatedProducts();
if (relatedProducts.Count > 0)
{
string guid = ExporterIFCUtils.CreateSubElementGUID(projectInfo, (int)IFCBuildingSubElements.RelAggregatesProducts);
ExporterUtil.RelateObjects(exporterIFC, guid, exporterIFC.GetBuilding(), relatedProducts);
}
// create a default site if we have latitude and longitude information.
if (IFCAnyHandleUtil.IsNullOrHasNoValue(exporterIFC.GetSite()))
{
using (IFCProductWrapper productWrapper = IFCProductWrapper.Create(exporterIFC, true))
{
SiteExporter.ExportDefaultSite(exporterIFC, document, productWrapper);
}
}
IFCAnyHandle siteHandle = exporterIFC.GetSite();
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(siteHandle))
{
ExporterUtil.RelateObject(exporterIFC, exporterIFC.GetProject(), siteHandle);
// assoc. site to the building.
ExporterUtil.RelateObject(exporterIFC, siteHandle, exporterIFC.GetBuilding());
ExporterIFCUtils.UpdateBuildingPlacement(exporterIFC);
}
else
{
// relate building and project if no site
ExporterUtil.RelateObject(exporterIFC, exporterIFC.GetProject(), exporterIFC.GetBuilding());
}
// relate levels and products.
RelateLevels(exporterIFC, document);
// These elements are created internally, but we allow custom property sets for them. Create them here.
using (IFCProductWrapper productWrapper = IFCProductWrapper.Create(exporterIFC, true))
{
IFCAnyHandle buildingHnd = exporterIFC.GetBuilding();
productWrapper.AddBuilding(buildingHnd);
ExportElementProperties(exporterIFC, document.ProjectInformation, productWrapper);
//.........这里部分代码省略.........