本文整理汇总了C#中ExporterIFC.GetFile方法的典型用法代码示例。如果您正苦于以下问题:C# ExporterIFC.GetFile方法的具体用法?C# ExporterIFC.GetFile怎么用?C# ExporterIFC.GetFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExporterIFC
的用法示例。
在下文中一共展示了ExporterIFC.GetFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportFooting
/// <summary>
/// Exports an element to IFC footing.
/// </summary>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="element">
/// The element.
/// </param>
/// <param name="geometryElement">
/// The geometry element.
/// </param>
/// <param name="ifcEnumType">
/// The string value represents the IFC type.
/// </param>
/// <param name="productWrapper">
/// The IFCProductWrapper.
/// </param>
public static void ExportFooting(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement,
string ifcEnumType, IFCProductWrapper productWrapper)
{
// export parts or not
bool exportParts = PartExporter.CanExportParts(element);
if (exportParts && !PartExporter.CanExportElementInPartExport(element, element.Level.Id, false))
return;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (IFCPlacementSetter setter = IFCPlacementSetter.Create(exporterIFC, element))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.SetLocalPlacement(setter.GetPlacement());
IFCAnyHandle prodRep = null;
if (!exportParts)
{
ElementId catId = CategoryUtil.GetSafeCategoryId(element);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
prodRep = RepresentationUtil.CreateBRepProductDefinitionShape(element.Document.Application, exporterIFC,
element, catId, geometryElement, bodyExporterOptions, null, ecData);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(prodRep))
{
ecData.ClearOpenings();
return;
}
}
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, exporterIFC.GetFamilyName());
string instanceElemId = NamingUtil.CreateIFCElementId(element);
Toolkit.IFCFootingType footingType = GetIFCFootingType(element, ifcEnumType);
IFCAnyHandle footing = IFCInstanceExporter.CreateFooting(file, instanceGUID, exporterIFC.GetOwnerHistoryHandle(),
instanceName, instanceDescription, instanceObjectType, ecData.GetLocalPlacement(), prodRep, instanceElemId, footingType);
if (exportParts)
{
PartExporter.ExportHostPart(exporterIFC, element, footing, productWrapper, setter, setter.GetPlacement(), null);
}
productWrapper.AddElement(footing, setter, ecData, LevelUtil.AssociateElementToLevel(element));
OpeningUtil.CreateOpeningsIfNecessary(footing, element, ecData, exporterIFC, ecData.GetLocalPlacement(), setter, productWrapper);
PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, element, productWrapper);
}
}
tr.Commit();
}
}
示例2: Export
/// <summary>
/// Exports mullion.
/// </summary>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="mullion">
/// The mullion object.
/// </param>
/// <param name="geometryElement">
/// The geometry element.
/// </param>
/// <param name="localPlacement">
/// The local placement handle.
/// </param>
/// <param name="extraParams">
/// The extrusion creation data.
/// </param>
/// <param name="setter">
/// The IFCPlacementSetter.
/// </param>
/// <param name="productWrapper">
/// The IFCProductWrapper.
/// </param>
public static void Export(ExporterIFC exporterIFC, Mullion mullion, GeometryElement geometryElement,
IFCAnyHandle localPlacement, IFCExtrusionCreationData extraParams, IFCPlacementSetter setter, IFCProductWrapper productWrapper)
{
IFCFile file = exporterIFC.GetFile();
ElementId catId = CategoryUtil.GetSafeCategoryId(mullion);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
IFCAnyHandle repHnd = RepresentationUtil.CreateBRepProductDefinitionShape(mullion.Document.Application, exporterIFC, mullion, catId,
geometryElement, bodyExporterOptions, null, extraParams);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(repHnd))
{
extraParams.ClearOpenings();
return;
}
string elemGUID = ExporterIFCUtils.CreateGUID(mullion);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string elemObjectType = NamingUtil.CreateIFCObjectName(exporterIFC, mullion);
string elemId = NamingUtil.CreateIFCElementId(mullion);
IFCAnyHandle mullionHnd = IFCInstanceExporter.CreateMember(file, elemGUID, ownerHistory, elemObjectType, null, elemObjectType,
localPlacement, repHnd, elemId);
productWrapper.AddElement(mullionHnd, setter, extraParams, LevelUtil.AssociateElementToLevel(mullion));
PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, mullion, productWrapper);
}
示例3: CreateBaseShapeRepresentation
/// <summary>
/// Creates a shape representation and register it to shape representation layer.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="contextOfItems">The context for which the different subtypes of representation are valid.</param>
/// <param name="identifier">The identifier for the representation.</param>
/// <param name="representationType">The type handle for the representation.</param>
/// <param name="items">Collection of geometric representation items that are defined for this representation.</param>
/// <returns>The handle.</returns>
public static IFCAnyHandle CreateBaseShapeRepresentation(ExporterIFC exporterIFC, IFCAnyHandle contextOfItems,
string identifier, string representationType, ISet<IFCAnyHandle> items)
{
IFCFile file = exporterIFC.GetFile();
IFCAnyHandle newShapeRepresentation = IFCInstanceExporter.CreateShapeRepresentation(file, contextOfItems, identifier, representationType, items);
return newShapeRepresentation;
}
示例4: ExportFabricArea
/// <summary>
/// Exports a FabricArea as an IfcGroup. There is no geometry to export.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
/// <returns>True if exported successfully, false otherwise.</returns>
public static bool ExportFabricArea(ExporterIFC exporterIFC, Element element, ProductWrapper productWrapper)
{
if (element == null)
return false;
HashSet<IFCAnyHandle> fabricSheetHandles = null;
if (!ExporterCacheManager.FabricAreaHandleCache.TryGetValue(element.Id, out fabricSheetHandles))
return false;
if (fabricSheetHandles == null || fabricSheetHandles.Count == 0)
return false;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
string guid = GUIDUtil.CreateGUID(element);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string revitObjectType = exporterIFC.GetFamilyName();
string name = NamingUtil.GetNameOverride(element, revitObjectType);
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, revitObjectType);
IFCAnyHandle fabricArea = IFCInstanceExporter.CreateGroup(file, guid,
ownerHistory, name, description, objectType);
productWrapper.AddElement(element, fabricArea);
IFCInstanceExporter.CreateRelAssignsToGroup(file, GUIDUtil.CreateGUID(), ownerHistory,
null, null, fabricSheetHandles, null, fabricArea);
tr.Commit();
return true;
}
}
示例5: ExportAssemblyInstanceElement
/// <summary>
/// Exports an element as an IFC assembly.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The IFCProductWrapper.</param>
/// <returns>True if exported successfully, false otherwise.</returns>
public static bool ExportAssemblyInstanceElement(ExporterIFC exporterIFC, AssemblyInstance element,
IFCProductWrapper productWrapper)
{
if (element == null)
return false;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (IFCPlacementSetter placementSetter = IFCPlacementSetter.Create(exporterIFC, element))
{
string guid = ExporterIFCUtils.CreateGUID(element);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string name = exporterIFC.GetName();
string objectType = exporterIFC.GetFamilyName();
IFCAnyHandle localPlacement = placementSetter.GetPlacement();
IFCAnyHandle representation = null;
string elementTag = NamingUtil.CreateIFCElementId(element);
IFCElementAssemblyType predefinedType = GetPredefinedTypeFromObjectType(objectType);
IFCAnyHandle assemblyInstanceHnd = IFCInstanceExporter.CreateElementAssembly(file, guid,
ownerHistory, name, null, objectType, localPlacement, representation, elementTag,
IFCAssemblyPlace.NotDefined, predefinedType);
productWrapper.AddElement(assemblyInstanceHnd, placementSetter.GetLevelInfo(), null, true);
PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, element, productWrapper);
ExporterCacheManager.AssemblyInstanceCache.RegisterAssemblyInstance(element.Id, assemblyInstanceHnd);
}
tr.Commit();
return true;
}
}
示例6: Export
/// <summary>
/// Exports mullion.
/// </summary>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="mullion">
/// The mullion object.
/// </param>
/// <param name="geometryElement">
/// The geometry element.
/// </param>
/// <param name="localPlacement">
/// The local placement handle.
/// </param>
/// <param name="extraParams">
/// The extrusion creation data.
/// </param>
/// <param name="setter">
/// The IFCPlacementSetter.
/// </param>
/// <param name="productWrapper">
/// The IFCProductWrapper.
/// </param>
public static void Export(ExporterIFC exporterIFC, Mullion mullion, GeometryElement geometryElement,
IFCAnyHandle localPlacement, IFCExtrusionCreationData extraParams, IFCPlacementSetter setter, IFCProductWrapper productWrapper)
{
IFCFile file = exporterIFC.GetFile();
ElementId catId = CategoryUtil.GetSafeCategoryId(mullion);
IFCSolidMeshGeometryInfo solidMeshInfo = ExporterIFCUtils.GetSolidMeshGeometry(exporterIFC, geometryElement, Transform.Identity);
IList<Solid> solids = solidMeshInfo.GetSolids();
IList<Mesh> polyMeshes = solidMeshInfo.GetMeshes();
bool tryToExportAsExtrusion = true;
if (solids.Count != 1 || polyMeshes.Count != 0)
tryToExportAsExtrusion = false;
IFCAnyHandle shapeRep = BodyExporter.ExportBody(mullion.Document.Application, exporterIFC, catId, solids, polyMeshes, tryToExportAsExtrusion, extraParams);
IList<IFCAnyHandle> shapeReps = new List<IFCAnyHandle>();
shapeReps.Add(shapeRep);
IFCAnyHandle repHnd = file.CreateProductDefinitionShape(IFCLabel.Create(), IFCLabel.Create(), shapeReps);
IFCLabel elemGUID = IFCLabel.CreateGUID(mullion);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
IFCLabel elemObjectType = NamingUtil.CreateIFCObjectName(exporterIFC, mullion);
IFCLabel elemId = NamingUtil.CreateIFCElementId(mullion);
//IFCLabel elemType = IFCLabel.Create("MULLION");
IFCAnyHandle mullionHnd = file.CreateMember(elemGUID, ownerHistory, elemObjectType, IFCLabel.Create(), elemObjectType,
localPlacement, repHnd, elemId);
productWrapper.AddElement(mullionHnd, setter, extraParams, true);
}
示例7: CreateOpeningsIfNecessaryBase
/// <summary>
/// Creates openings if there is necessary.
/// </summary>
/// <param name="elementHandle">The element handle to create openings.</param>
/// <param name="element">The element to create openings.</param>
/// <param name="info">The extrusion data.</param>
/// <param name="extraParams">The extrusion creation data.</param>
/// <param name="offsetTransform">The offset transform from ExportBody, or the identity transform.</param>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="originalPlacement">The original placement handle.</param>
/// <param name="setter">The PlacementSetter.</param>
/// <param name="wrapper">The ProductWrapper.</param>
private static void CreateOpeningsIfNecessaryBase(IFCAnyHandle elementHandle, Element element, IList<IFCExtrusionData> info,
IFCExtrusionCreationData extraParams, Transform offsetTransform, ExporterIFC exporterIFC,
IFCAnyHandle originalPlacement, PlacementSetter setter, ProductWrapper wrapper)
{
if (IFCAnyHandleUtil.IsNullOrHasNoValue(elementHandle))
return;
int sz = info.Count;
if (sz == 0)
return;
using (TransformSetter transformSetter = TransformSetter.Create())
{
if (offsetTransform != null)
transformSetter.Initialize(exporterIFC, offsetTransform.Inverse);
IFCFile file = exporterIFC.GetFile();
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
Document document = element.Document;
string openingObjectType = "Opening";
int openingNumber = 1;
for (int curr = info.Count - 1; curr >= 0; curr--)
{
IFCAnyHandle extrusionHandle = ExtrusionExporter.CreateExtrudedSolidFromExtrusionData(exporterIFC, element, info[curr]);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(extrusionHandle))
continue;
IFCAnyHandle styledItemHnd = BodyExporter.CreateSurfaceStyleForRepItem(exporterIFC, document,
extrusionHandle, ElementId.InvalidElementId);
HashSet<IFCAnyHandle> bodyItems = new HashSet<IFCAnyHandle>();
bodyItems.Add(extrusionHandle);
IFCAnyHandle contextOfItems = exporterIFC.Get3DContextHandle("Body");
IFCAnyHandle bodyRep = RepresentationUtil.CreateSweptSolidRep(exporterIFC, element, categoryId, contextOfItems, bodyItems, null);
IList<IFCAnyHandle> representations = new List<IFCAnyHandle>();
representations.Add(bodyRep);
IFCAnyHandle openingRep = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, representations);
IFCAnyHandle openingPlacement = ExporterUtil.CopyLocalPlacement(file, originalPlacement);
string guid = GUIDUtil.CreateGUID();
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string openingName = NamingUtil.GetIFCNamePlusIndex(element, openingNumber++);
string elementId = NamingUtil.CreateIFCElementId(element);
IFCAnyHandle openingElement = IFCInstanceExporter.CreateOpeningElement(file, guid, ownerHistory,
openingName, null, openingObjectType, openingPlacement, openingRep, elementId);
wrapper.AddElement(null, openingElement, setter, extraParams, true);
if (ExporterCacheManager.ExportOptionsCache.ExportBaseQuantities && (extraParams != null))
PropertyUtil.CreateOpeningQuantities(exporterIFC, openingElement, extraParams);
string voidGuid = GUIDUtil.CreateGUID();
IFCInstanceExporter.CreateRelVoidsElement(file, voidGuid, ownerHistory, null, null, elementHandle, openingElement);
}
}
}
示例8: Export
/// <summary>
/// Exports a Rebar, AreaReinforcement or PathReinforcement to IFC ReinforcingBar.
/// </summary>
/// <param name="exporterIFC">The exporter.</param>
/// <param name="element">The element.</param>
/// <param name="productWrapper">The product wrapper.</param>
public static void Export(ExporterIFC exporterIFC, Element element, ProductWrapper productWrapper)
{
ISet<IFCAnyHandle> createdRebars = null;
if (element is Rebar)
{
ExportRebar(exporterIFC, element, productWrapper);
}
else if (element is AreaReinforcement)
{
AreaReinforcement areaReinforcement = element as AreaReinforcement;
IList<ElementId> rebarIds = areaReinforcement.GetRebarInSystemIds();
Document doc = areaReinforcement.Document;
foreach (ElementId id in rebarIds)
{
Element rebarInSystem = doc.GetElement(id);
createdRebars = ExportRebar(exporterIFC, rebarInSystem, productWrapper);
}
}
else if (element is PathReinforcement)
{
PathReinforcement pathReinforcement = element as PathReinforcement;
IList<ElementId> rebarIds = pathReinforcement.GetRebarInSystemIds();
Document doc = pathReinforcement.Document;
foreach (ElementId id in rebarIds)
{
Element rebarInSystem = doc.GetElement(id);
createdRebars = ExportRebar(exporterIFC, rebarInSystem, productWrapper);
}
}
if (createdRebars != null && createdRebars.Count > 1)
{
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
string guid = GUIDUtil.CreateGUID(element);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string revitObjectType = exporterIFC.GetFamilyName();
string name = NamingUtil.GetNameOverride(element, revitObjectType);
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, revitObjectType);
IFCAnyHandle rebarGroup = IFCInstanceExporter.CreateGroup(file, guid,
ownerHistory, name, description, objectType);
productWrapper.AddElement(element, rebarGroup);
IFCInstanceExporter.CreateRelAssignsToGroup(file, GUIDUtil.CreateGUID(), ownerHistory,
null, null, createdRebars, null, rebarGroup);
tr.Commit();
}
}
}
示例9: ExportSurface
/// <summary>
/// Exports a geometry element to boundary representation.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="exportBoundaryRep">True if to export boundary representation.</param>
/// <param name="exportAsFacetation">True if to export the geometry as facetation.</param>
/// <param name="bodyRep">Body representation.</param>
/// <param name="boundaryRep">Boundary representation.</param>
/// <returns>True if success, false if fail.</returns>
public static bool ExportSurface(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement,
bool exportBoundaryRep, bool exportAsFacetation, ref IFCAnyHandle bodyRep, ref IFCAnyHandle boundaryRep)
{
if (geometryElement == null)
return false;
IFCGeometryInfo ifcGeomInfo = null;
Document doc = element.Document;
Plane plane = GeometryUtil.CreateDefaultPlane();
XYZ projDir = new XYZ(0, 0, 1);
double eps = UnitUtil.ScaleLength(doc.Application.VertexTolerance);
ifcGeomInfo = IFCGeometryInfo.CreateFaceGeometryInfo(exporterIFC, plane, projDir, eps, exportBoundaryRep);
ExporterIFCUtils.CollectGeometryInfo(exporterIFC, ifcGeomInfo, geometryElement, XYZ.Zero, true);
IFCFile file = exporterIFC.GetFile();
HashSet<IFCAnyHandle> faceSets = new HashSet<IFCAnyHandle>();
IList<ICollection<IFCAnyHandle>> faceList = ifcGeomInfo.GetFaces();
foreach (ICollection<IFCAnyHandle> faces in faceList)
{
// no faces, don't complain.
if (faces.Count == 0)
continue;
HashSet<IFCAnyHandle> faceSet = new HashSet<IFCAnyHandle>(faces);
faceSets.Add(IFCInstanceExporter.CreateConnectedFaceSet(file, faceSet));
}
if (faceSets.Count == 0)
return false;
IFCAnyHandle surface = IFCInstanceExporter.CreateFaceBasedSurfaceModel(file, faceSets);
BodyExporter.CreateSurfaceStyleForRepItem(exporterIFC, doc, surface, BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, element));
ISet<IFCAnyHandle> surfaceItems = new HashSet<IFCAnyHandle>();
surfaceItems.Add(surface);
ElementId catId = CategoryUtil.GetSafeCategoryId(element);
bodyRep = RepresentationUtil.CreateSurfaceRep(exporterIFC, element, catId, exporterIFC.Get3DContextHandle("Body"), surfaceItems,
exportAsFacetation, bodyRep);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(bodyRep))
return false;
ICollection<IFCAnyHandle> boundaryRepresentations = ifcGeomInfo.GetRepresentations();
if (exportBoundaryRep && boundaryRepresentations.Count > 0)
{
HashSet<IFCAnyHandle> boundaryRepresentationSet = new HashSet<IFCAnyHandle>();
boundaryRepresentationSet.UnionWith(boundaryRepresentations);
boundaryRep = RepresentationUtil.CreateBoundaryRep(exporterIFC, element, catId, exporterIFC.Get3DContextHandle("FootPrint"), boundaryRepresentationSet,
boundaryRep);
}
return true;
}
示例10: ExportDuctLining
/// <summary>
/// Exports an element as a covering of type insulation.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
/// <returns>True if exported successfully, false otherwise.</returns>
public static bool ExportDuctLining(ExporterIFC exporterIFC, Element element,
GeometryElement geometryElement, ProductWrapper productWrapper)
{
if (element == null || geometryElement == null)
return false;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (PlacementSetter placementSetter = PlacementSetter.Create(exporterIFC, element))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.SetLocalPlacement(placementSetter.LocalPlacement);
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
IFCAnyHandle representation = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, element,
categoryId, geometryElement, bodyExporterOptions, null, ecData, true);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(representation))
{
ecData.ClearOpenings();
return false;
}
string guid = GUIDUtil.CreateGUID(element);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string revitObjectType = exporterIFC.GetFamilyName();
string name = NamingUtil.GetNameOverride(element, revitObjectType);
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, revitObjectType);
IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
string elementTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
IFCAnyHandle ductLining = IFCInstanceExporter.CreateCovering(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag, "Wrapping");
ExporterCacheManager.ElementToHandleCache.Register(element.Id, ductLining);
productWrapper.AddElement(element, ductLining, placementSetter.LevelInfo, ecData, true);
ElementId matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, element);
CategoryUtil.CreateMaterialAssociation(exporterIFC, ductLining, matId);
}
}
tr.Commit();
return true;
}
}
示例11: ExportDuctLining
/// <summary>
/// Exports an element as a covering of type insulation.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
/// <returns>True if exported successfully, false otherwise.</returns>
public static bool ExportDuctLining(ExporterIFC exporterIFC, Element element,
GeometryElement geometryElement, ProductWrapper productWrapper)
{
if (element == null || geometryElement == null)
return false;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (IFCPlacementSetter placementSetter = IFCPlacementSetter.Create(exporterIFC, element))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.SetLocalPlacement(placementSetter.GetPlacement());
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
IFCAnyHandle representation = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, element,
categoryId, geometryElement, bodyExporterOptions, null, ecData);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(representation))
{
ecData.ClearOpenings();
return false;
}
string guid = GUIDUtil.CreateGUID(element);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string revitObjectType = exporterIFC.GetFamilyName();
string name = NamingUtil.GetNameOverride(element, revitObjectType);
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, revitObjectType);
IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
string elementTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
IFCAnyHandle ductLining = IFCInstanceExporter.CreateCovering(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag, IFCCoveringType.Wrapping);
productWrapper.AddElement(ductLining, placementSetter.GetLevelInfo(), ecData, LevelUtil.AssociateElementToLevel(element));
PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, element, productWrapper);
}
}
tr.Commit();
return true;
}
}
示例12: Export
/// <summary>
/// Exports mullion.
/// </summary>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="mullion">
/// The mullion object.
/// </param>
/// <param name="geometryElement">
/// The geometry element.
/// </param>
/// <param name="localPlacement">
/// The local placement handle.
/// </param>
/// <param name="setter">
/// The IFCPlacementSetter.
/// </param>
/// <param name="productWrapper">
/// The ProductWrapper.
/// </param>
public static void Export(ExporterIFC exporterIFC, Mullion mullion, GeometryElement geometryElement,
IFCAnyHandle localPlacement, IFCPlacementSetter setter, ProductWrapper productWrapper)
{
IFCFile file = exporterIFC.GetFile();
using (IFCPlacementSetter mullionSetter = IFCPlacementSetter.Create(exporterIFC, mullion, null, null, ExporterUtil.GetBaseLevelIdForElement(mullion)))
{
using (IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData())
{
IFCAnyHandle mullionPlacement = mullionSetter.GetPlacement();
Transform relTrf = ExporterIFCUtils.GetRelativeLocalPlacementOffsetTransform(localPlacement, mullionPlacement);
Transform inverseTrf = relTrf.Inverse;
IFCAnyHandle mullionRelativePlacement = ExporterUtil.CreateAxis2Placement3D(file, inverseTrf.Origin, inverseTrf.BasisZ, inverseTrf.BasisX);
IFCAnyHandle mullionLocalPlacement = IFCInstanceExporter.CreateLocalPlacement(file, localPlacement, mullionRelativePlacement);
extraParams.SetLocalPlacement(mullionLocalPlacement);
ElementId catId = CategoryUtil.GetSafeCategoryId(mullion);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
IFCAnyHandle repHnd = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, mullion, catId,
geometryElement, bodyExporterOptions, null, extraParams, true);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(repHnd))
{
extraParams.ClearOpenings();
return;
}
string elemGUID = GUIDUtil.CreateGUID(mullion);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string elemObjectType = NamingUtil.CreateIFCObjectName(exporterIFC, mullion);
string name = NamingUtil.GetNameOverride(mullion, elemObjectType);
string description = NamingUtil.GetDescriptionOverride(mullion, null);
string objectType = NamingUtil.GetObjectTypeOverride(mullion, elemObjectType);
string elemTag = NamingUtil.GetTagOverride(mullion, NamingUtil.CreateIFCElementId(mullion));
IFCAnyHandle mullionHnd = IFCInstanceExporter.CreateMember(file, elemGUID, ownerHistory, name, description, objectType,
mullionLocalPlacement, repHnd, elemTag);
ExporterCacheManager.HandleToElementCache.Register(mullionHnd, mullion.Id);
productWrapper.AddElement(mullion, mullionHnd, mullionSetter, extraParams, false);
ElementId matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, mullion);
CategoryUtil.CreateMaterialAssociation(exporterIFC, mullionHnd, matId);
}
}
}
示例13: CreateOpeningsIfNecessaryBase
/// <summary>
/// Creates openings if there is necessary.
/// </summary>
/// <param name="elementHandle">
/// The element handle to create openings.
/// </param>
/// <param name="element">
/// The element to create openings.
/// </param>
/// <param name="info">
/// The extrusion datas.
/// </param>
/// <param name="extraParams">
/// The extrusion creation data.
/// </param>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="originalPlacement">
/// The original placement handle.
/// </param>
/// <param name="setter">
/// The IFCPlacementSetter.
/// </param>
/// <param name="wrapper">
/// The IFCProductWrapper.
/// </param>
private static void CreateOpeningsIfNecessaryBase(IFCAnyHandle elementHandle, Element element, IList<IFCExtrusionData> info,
IFCExtrusionCreationData extraParams, ExporterIFC exporterIFC,
IFCAnyHandle originalPlacement, IFCPlacementSetter setter, IFCProductWrapper wrapper)
{
if (!elementHandle.HasValue)
return;
IFCFile file = exporterIFC.GetFile();
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
int sz = info.Count;
if (sz == 0)
return;
IFCLabel openingObjectType = IFCLabel.Create("Opening");
int openingNumber = 1;
for (int curr = info.Count - 1; curr >= 0; curr--)
{
IFCAnyHandle extrusionHandle = BodyExporter.CreateExtrudedSolidFromExtrusionData(exporterIFC, categoryId, info[curr]);
if (!extrusionHandle.HasValue)
continue;
HashSet<IFCAnyHandle> bodyItems = new HashSet<IFCAnyHandle>();
bodyItems.Add(extrusionHandle);
IFCAnyHandle contextOfItems = exporterIFC.Get3DContextHandle();
IFCAnyHandle bodyRep = RepresentationUtil.CreateSweptSolidRep(exporterIFC, categoryId, contextOfItems, bodyItems,
IFCAnyHandle.Create());
IList<IFCAnyHandle> representations = new List<IFCAnyHandle>();
representations.Add(bodyRep);
IFCAnyHandle openingRep = file.CreateProductDefinitionShape(IFCLabel.Create(), IFCLabel.Create(), representations);
IFCAnyHandle openingPlacement = ExporterUtil.CopyLocalPlacement(file, originalPlacement);
IFCLabel guid = IFCLabel.CreateGUID();
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
IFCLabel openingName = NamingUtil.GetNameOverride(element, NamingUtil.CreateIFCName(exporterIFC, openingNumber++));
IFCLabel elementId = NamingUtil.CreateIFCElementId(element);
IFCAnyHandle openingElement = file.CreateOpeningElement(guid, ownerHistory,
openingName, IFCLabel.Create(), openingObjectType, openingPlacement, openingRep, elementId);
wrapper.AddElement(openingElement, setter, extraParams, true);
if (exporterIFC.ExportBaseQuantities && (extraParams != null))
ExporterIFCUtils.CreateOpeningQuantities(exporterIFC, openingElement, extraParams);
IFCLabel voidGuid = IFCLabel.CreateGUID();
file.CreateRelVoidsElement(voidGuid, ownerHistory, IFCLabel.Create(), IFCLabel.Create(), elementHandle, openingElement);
}
}
示例14: ExportBuildingElementProxy
/// <summary>
/// Exports an element as building element proxy.
/// </summary>
/// <remarks>
/// This function is called from the Export function, but can also be called directly if you do not
/// want CreateInternalPropertySets to be called.
/// </remarks>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
/// <returns>The handle if created, null otherwise.</returns>
public static IFCAnyHandle ExportBuildingElementProxy(ExporterIFC exporterIFC, Element element,
GeometryElement geometryElement, ProductWrapper productWrapper)
{
if (element == null || geometryElement == null)
return null;
IFCFile file = exporterIFC.GetFile();
IFCAnyHandle buildingElementProxy = null;
using (IFCTransaction tr = new IFCTransaction(file))
{
using (PlacementSetter placementSetter = PlacementSetter.Create(exporterIFC, element))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.SetLocalPlacement(placementSetter.LocalPlacement);
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
IFCAnyHandle representation = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, element,
categoryId, geometryElement, bodyExporterOptions, null, ecData, true);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(representation))
{
ecData.ClearOpenings();
return null;
}
string guid = GUIDUtil.CreateGUID(element);
IFCAnyHandle ownerHistory = ExporterCacheManager.OwnerHistoryHandle;
string revitObjectType = exporterIFC.GetFamilyName();
string name = NamingUtil.GetNameOverride(element, revitObjectType);
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, revitObjectType);
IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
string elementTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
buildingElementProxy = IFCInstanceExporter.CreateBuildingElementProxy(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag, null);
productWrapper.AddElement(element, buildingElementProxy, placementSetter.LevelInfo, ecData, true);
}
tr.Commit();
}
}
return buildingElementProxy;
}
示例15: ExportBoundingBoxBase
private static IFCAnyHandle ExportBoundingBoxBase(ExporterIFC exporterIFC, XYZ cornerXYZ, double xDim, double yDim, double zDim)
{
double eps = MathUtil.Eps();
if (xDim < eps || yDim < eps || zDim < eps)
return null;
IFCFile file = exporterIFC.GetFile();
IFCAnyHandle cornerHnd = ExporterUtil.CreateCartesianPoint(file, cornerXYZ);
IFCAnyHandle boundingBoxItem = IFCInstanceExporter.CreateBoundingBox(file, cornerHnd, xDim, yDim, zDim);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(boundingBoxItem))
return null;
IFCAnyHandle contextOfItems = exporterIFC.Get3DContextHandle("Box");
return RepresentationUtil.CreateBoundingBoxRep(exporterIFC, contextOfItems, boundingBoxItem);
}