本文整理汇总了C#中Revit.IFC.Export.Utility.ProductWrapper.AddElement方法的典型用法代码示例。如果您正苦于以下问题:C# ProductWrapper.AddElement方法的具体用法?C# ProductWrapper.AddElement怎么用?C# ProductWrapper.AddElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Revit.IFC.Export.Utility.ProductWrapper
的用法示例。
在下文中一共展示了ProductWrapper.AddElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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 = 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 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;
}
}
示例2: ExportZone
/// <summary>
/// Exports an element as a zone.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
public static void ExportZone(ExporterIFC exporterIFC, Zone element,
ProductWrapper productWrapper)
{
if (element == null)
return;
HashSet<IFCAnyHandle> spaceHnds = new HashSet<IFCAnyHandle>();
SpaceSet spaces = element.Spaces;
foreach (Space space in spaces)
{
if (space == null)
continue;
IFCAnyHandle spaceHnd = ExporterCacheManager.SpaceInfoCache.FindSpaceHandle(space.Id);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(spaceHnd))
spaceHnds.Add(spaceHnd);
}
if (spaceHnds.Count == 0)
return;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
string guid = GUIDUtil.CreateGUID(element);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string name = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
IFCAnyHandle zoneHnd = IFCInstanceExporter.CreateZone(file, guid, ownerHistory, name, description, objectType);
productWrapper.AddElement(element, zoneHnd);
string relAssignsGuid = GUIDUtil.CreateSubElementGUID(element, (int) IFCZoneSubElements.RelAssignsToGroup);
IFCInstanceExporter.CreateRelAssignsToGroup(file, relAssignsGuid, ownerHistory, null, null, spaceHnds, null, zoneHnd);
tr.Commit();
return;
}
}
示例3: ExportAreaScheme
/// <summary>
/// Exports an element as a group.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
public static void ExportAreaScheme(ExporterIFC exporterIFC, AreaScheme element,
ProductWrapper productWrapper)
{
if (element == null)
return;
HashSet<IFCAnyHandle> areaHandles = null;
if (!ExporterCacheManager.AreaSchemeCache.TryGetValue(element.Id, out areaHandles))
return;
if (areaHandles == null || areaHandles.Count == 0)
return;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
string guid = GUIDUtil.CreateGUID(element);
IFCAnyHandle ownerHistory = ExporterCacheManager.OwnerHistoryHandle;
string name = NamingUtil.GetNameOverride(element, element.Name);
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
string elementTag = NamingUtil.CreateIFCElementId(element);
IFCAnyHandle areaScheme = IFCInstanceExporter.CreateGroup(file, guid,
ownerHistory, name, description, objectType);
productWrapper.AddElement(element, areaScheme);
IFCInstanceExporter.CreateRelAssignsToGroup(file, GUIDUtil.CreateGUID(), ownerHistory,
null, null, areaHandles, null, areaScheme);
tr.Commit();
return;
}
}
示例4: ExportGroupElement
/// <summary>
/// Exports a Group as an IfcGroup.
/// </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 ExportGroupElement(ExporterIFC exporterIFC, Group element,
ProductWrapper productWrapper)
{
if (element == null)
return false;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
IFCAnyHandle groupHnd = null;
string guid = GUIDUtil.CreateGUID(element);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string name = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
string ifcEnumType;
IFCExportType exportAs = ExporterUtil.GetExportType(exporterIFC, element, out ifcEnumType);
if (exportAs == IFCExportType.IfcGroup)
{
groupHnd = IFCInstanceExporter.CreateGroup(file, guid, ownerHistory, name, description, objectType);
}
if (groupHnd == null)
return false;
productWrapper.AddElement(element, groupHnd);
ExporterCacheManager.GroupCache.RegisterGroup(element.Id, groupHnd);
tr.Commit();
return true;
}
}
示例5: ExportPile
/// <summary>
/// Exports an element to IfcPile.
/// </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 ProductWrapper.</param>
public static void ExportPile(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement,
string ifcEnumType, ProductWrapper productWrapper)
{
// export parts or not
bool exportParts = PartExporter.CanExportParts(element);
if (exportParts && !PartExporter.CanExportElementInPartExport(element, element.LevelId, false))
return;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (PlacementSetter setter = PlacementSetter.Create(exporterIFC, element))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.SetLocalPlacement(setter.LocalPlacement);
IFCAnyHandle prodRep = null;
ElementId matId = ElementId.InvalidElementId;
if (!exportParts)
{
ElementId catId = CategoryUtil.GetSafeCategoryId(element);
matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, element);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
prodRep = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC,
element, catId, geometryElement, bodyExporterOptions, null, ecData, true);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(prodRep))
{
ecData.ClearOpenings();
return;
}
}
string instanceGUID = GUIDUtil.CreateGUID(element);
string instanceName = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
string instanceDescription = NamingUtil.GetDescriptionOverride(element, null);
string instanceObjectType = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
string instanceTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
string pileType = IFCValidateEntry.GetValidIFCType(element, ifcEnumType);
IFCAnyHandle pile = IFCInstanceExporter.CreatePile(file, instanceGUID, ExporterCacheManager.OwnerHistoryHandle,
instanceName, instanceDescription, instanceObjectType, ecData.GetLocalPlacement(), prodRep, instanceTag, pileType, null);
if (exportParts)
{
PartExporter.ExportHostPart(exporterIFC, element, pile, productWrapper, setter, setter.LocalPlacement, null);
}
else
{
if (matId != ElementId.InvalidElementId)
{
CategoryUtil.CreateMaterialAssociation(exporterIFC, pile, matId);
}
}
productWrapper.AddElement(element, pile, setter, ecData, true);
OpeningUtil.CreateOpeningsIfNecessary(pile, element, ecData, null,
exporterIFC, ecData.GetLocalPlacement(), setter, productWrapper);
}
}
tr.Commit();
}
}
示例6: ExportRoofOrFloorAsContainer
//.........这里部分代码省略.........
else
hostObjectHandle = IFCInstanceExporter.CreateSlab(file, elementGUID, ownerHistory, elementName, elementDescription,
elementObjectType, localPlacement, prodRepHnd, elementId, hostObjectType);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(hostObjectHandle))
return null;
IList<IFCAnyHandle> elementHandles = new List<IFCAnyHandle>();
elementHandles.Add(hostObjectHandle);
// If element is floor, then the profile curve loop of hostObjectSubComponent is computed from the top face of the floor
// else if element is roof, then the profile curve loop is taken from the bottom face of the roof instead
XYZ extrusionDir = elementIsFloor ? new XYZ(0, 0, -1) : new XYZ(0, 0, 1);
ElementId catId = CategoryUtil.GetSafeCategoryId(element);
IList<IFCAnyHandle> slabHandles = new List<IFCAnyHandle>();
IList<CurveLoop> hostObjectOpeningLoops = new List<CurveLoop>();
double maximumScaledDepth = 0.0;
using (IFCExtrusionCreationData slabExtrusionCreationData = new IFCExtrusionCreationData())
{
slabExtrusionCreationData.SetLocalPlacement(extrusionCreationData.GetLocalPlacement());
slabExtrusionCreationData.ReuseLocalPlacement = false;
slabExtrusionCreationData.ForceOffset = true;
int loopNum = 0;
int subElementStart = elementIsRoof ? (int)IFCRoofSubElements.RoofSlabStart : (int)IFCSlabSubElements.SubSlabStart;
string subSlabType = elementIsRoof ? "ROOF" : hostObjectType;
foreach (HostObjectSubcomponentInfo hostObjectSubcomponent in hostObjectSubcomponents)
{
trfSetter.InitializeFromBoundingBox(exporterIFC, geometryList, slabExtrusionCreationData);
Plane plane = hostObjectSubcomponent.GetPlane();
IList<CurveLoop> curveLoops = new List<CurveLoop>();
CurveLoop slabCurveLoop = hostObjectSubcomponent.GetCurveLoop();
curveLoops.Add(slabCurveLoop);
double slope = Math.Abs(plane.Normal.Z);
double scaledDepth = UnitUtil.ScaleLength(hostObjectSubcomponent.Depth);
double scaledExtrusionDepth = scaledDepth * slope;
IFCAnyHandle shapeRep = ExtrusionExporter.CreateExtrudedSolidFromCurveLoop(exporterIFC, null, curveLoops, plane, extrusionDir, scaledExtrusionDepth);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(shapeRep))
return null;
ElementId matId = HostObjectExporter.GetFirstLayerMaterialId(element as HostObject);
BodyExporter.CreateSurfaceStyleForRepItem(exporterIFC, element.Document, shapeRep, matId);
HashSet<IFCAnyHandle> bodyItems = new HashSet<IFCAnyHandle>();
bodyItems.Add(shapeRep);
shapeRep = RepresentationUtil.CreateSweptSolidRep(exporterIFC, element, catId, exporterIFC.Get3DContextHandle("Body"), bodyItems, null);
IList<IFCAnyHandle> shapeReps = new List<IFCAnyHandle>();
shapeReps.Add(shapeRep);
IFCAnyHandle repHnd = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, shapeReps);
// Allow support for up to 256 named IfcSlab components, as defined in IFCSubElementEnums.cs.
string slabGUID = (loopNum < 256) ? GUIDUtil.CreateSubElementGUID(element, subElementStart + loopNum) : GUIDUtil.CreateGUID();
IFCAnyHandle slabPlacement = ExporterUtil.CreateLocalPlacement(file, slabExtrusionCreationData.GetLocalPlacement(), null);
IFCAnyHandle slabHnd = IFCInstanceExporter.CreateSlab(file, slabGUID, ownerHistory, elementName,
elementDescription, elementObjectType, slabPlacement, repHnd, elementId, subSlabType);
//slab quantities
slabExtrusionCreationData.ScaledLength = scaledExtrusionDepth;
slabExtrusionCreationData.ScaledArea = UnitUtil.ScaleArea(UnitUtil.ScaleArea(hostObjectSubcomponent.AreaOfCurveLoop));
slabExtrusionCreationData.ScaledOuterPerimeter = UnitUtil.ScaleLength(curveLoops[0].GetExactLength());
slabExtrusionCreationData.Slope = UnitUtil.ScaleAngle(MathUtil.SafeAcos(Math.Abs(slope)));
productWrapper.AddElement(null, slabHnd, setter, slabExtrusionCreationData, false);
elementHandles.Add(slabHnd);
slabHandles.Add(slabHnd);
hostObjectOpeningLoops.Add(slabCurveLoop);
maximumScaledDepth = Math.Max(maximumScaledDepth, scaledDepth);
loopNum++;
}
}
productWrapper.AddElement(element, hostObjectHandle, setter, extrusionCreationData, true);
ExporterUtil.RelateObjects(exporterIFC, null, hostObjectHandle, slabHandles);
OpeningUtil.AddOpeningsToElement(exporterIFC, elementHandles, hostObjectOpeningLoops, element, null, maximumScaledDepth,
null, setter, localPlacement, productWrapper);
transaction.Commit();
return hostObjectHandle;
}
}
}
finally
{
exporterIFC.ClearFaceWithElementHandleMap();
}
}
}
}
示例7: 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;
}
示例8: 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="productWrapper">The ProductWrapper.</param>
/// <returns>True if exported successfully, false otherwise.</returns>
public static bool ExportAssemblyInstanceElement(ExporterIFC exporterIFC, AssemblyInstance element,
ProductWrapper productWrapper)
{
if (element == null)
return false;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
IFCAnyHandle assemblyInstanceHnd = null;
string guid = GUIDUtil.CreateGUID(element);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string name = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
IFCAnyHandle localPlacement = null;
PlacementSetter placementSetter = null;
IFCLevelInfo levelInfo = null;
string ifcEnumType;
IFCExportType exportAs = ExporterUtil.GetExportType(exporterIFC, element, out ifcEnumType);
if (exportAs == IFCExportType.IfcSystem)
{
assemblyInstanceHnd = IFCInstanceExporter.CreateSystem(file, guid,
ownerHistory, name, description, objectType);
// Create classification reference when System has classification filed name assigned to it
ClassificationUtil.CreateClassification(exporterIFC, file, element, assemblyInstanceHnd);
HashSet<IFCAnyHandle> relatedBuildings = new HashSet<IFCAnyHandle>();
relatedBuildings.Add(ExporterCacheManager.BuildingHandle);
IFCAnyHandle relServicesBuildings = IFCInstanceExporter.CreateRelServicesBuildings(file, GUIDUtil.CreateGUID(),
exporterIFC.GetOwnerHistoryHandle(), null, null, assemblyInstanceHnd, relatedBuildings);
}
else
{
using (placementSetter = PlacementSetter.Create(exporterIFC, element))
{
string elementTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
IFCAnyHandle representation = null;
// We have limited support for exporting assemblies as other container types.
localPlacement = placementSetter.LocalPlacement;
levelInfo = placementSetter.LevelInfo;
ifcEnumType = IFCValidateEntry.GetValidIFCType(element, ifcEnumType);
switch (exportAs)
{
case IFCExportType.IfcCurtainWall:
assemblyInstanceHnd = IFCInstanceExporter.CreateCurtainWall(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag);
break;
case IFCExportType.IfcRamp:
string rampPredefinedType = RampExporter.GetIFCRampType(ifcEnumType);
assemblyInstanceHnd = IFCInstanceExporter.CreateRamp(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag,
rampPredefinedType);
break;
case IFCExportType.IfcRoof:
assemblyInstanceHnd = IFCInstanceExporter.CreateRoof(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag,
ifcEnumType);
break;
case IFCExportType.IfcStair:
string stairPredefinedType = StairsExporter.GetIFCStairType(ifcEnumType);
assemblyInstanceHnd = IFCInstanceExporter.CreateStair(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag,
stairPredefinedType);
break;
case IFCExportType.IfcWall:
assemblyInstanceHnd = IFCInstanceExporter.CreateWall(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag,
ifcEnumType);
break;
default:
IFCElementAssemblyType assemblyPredefinedType = GetPredefinedTypeFromObjectType(objectType);
assemblyInstanceHnd = IFCInstanceExporter.CreateElementAssembly(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag,
IFCAssemblyPlace.NotDefined, assemblyPredefinedType);
break;
}
}
}
if (assemblyInstanceHnd == null)
return false;
bool relateToLevel = (levelInfo != null);
productWrapper.AddElement(element, assemblyInstanceHnd, levelInfo, null, relateToLevel);
//.........这里部分代码省略.........
示例9: 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 PlacementSetter.
/// </param>
/// <param name="productWrapper">
/// The ProductWrapper.
/// </param>
public static void Export(ExporterIFC exporterIFC, Mullion mullion, GeometryElement geometryElement,
IFCAnyHandle localPlacement, PlacementSetter setter, ProductWrapper productWrapper)
{
IFCFile file = exporterIFC.GetFile();
using (PlacementSetter mullionSetter = PlacementSetter.Create(exporterIFC, mullion))
{
using (IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData())
{
IFCAnyHandle mullionPlacement = mullionSetter.LocalPlacement;
Transform relTrf = ExporterIFCUtils.GetRelativeLocalPlacementOffsetTransform(localPlacement, mullionPlacement);
Transform inverseTrf = relTrf.Inverse;
IFCAnyHandle mullionLocalPlacement = ExporterUtil.CreateLocalPlacement(file, localPlacement,
inverseTrf.Origin, inverseTrf.BasisZ, inverseTrf.BasisX);
extraParams.SetLocalPlacement(mullionLocalPlacement);
Transform extrusionLCS = null;
// Add a custom direction for trying to create an extrusion based on the base curve of the mullion, if it is a line and not an arc.
Curve baseCurve = mullion.LocationCurve;
if ((baseCurve != null) && (baseCurve is Line))
{
// We won't use curveBounds and origin yet; just need the axis for now.
IFCRange curveBounds;
XYZ origin, mullionDirection;
GeometryUtil.GetAxisAndRangeFromCurve(baseCurve, out curveBounds, out mullionDirection, out origin);
// approx 1.0/sqrt(2.0)
XYZ planeY = (Math.Abs(mullionDirection.Z) < 0.707) ? XYZ.BasisZ.CrossProduct(mullionDirection) : XYZ.BasisX.CrossProduct(mullionDirection);
planeY.Normalize();
XYZ projDir = mullionDirection.CrossProduct(planeY);
extrusionLCS = Transform.Identity;
extrusionLCS.BasisX = mullionDirection; extrusionLCS.BasisY = planeY; extrusionLCS.BasisZ = projDir; extrusionLCS.Origin = origin;
}
ElementId catId = CategoryUtil.GetSafeCategoryId(mullion);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
bodyExporterOptions.ExtrusionLocalCoordinateSystem = extrusionLCS;
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, "MULLION");
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);
}
}
}
示例10: CreateOpening
/// <summary>
/// Creates an opening from extrusion data.
/// </summary>
/// <param name="exporterIFC">The exporter.</param>
/// <param name="hostObjHnd">The host handle.</param>
/// <param name="hostPlacement">The host placement.</param>
/// <param name="hostElement">The host element.</param>
/// <param name="insertElement">The opening element.</param>
/// <param name="openingGUID">The opening GUID.</param>
/// <param name="extrusionData">The extrusion data.</param>
/// <param name="plane">The plane.</param>
/// <param name="isRecess">True if it is a recess.</param>
/// <returns>The opening handle.</returns>
static public IFCAnyHandle CreateOpening(ExporterIFC exporterIFC, IFCAnyHandle hostObjHnd, IFCAnyHandle hostPlacement, Element hostElement,
Element insertElement, string openingGUID, IFCExtrusionData extrusionData, Plane plane, bool isRecess,
PlacementSetter setter, ProductWrapper localWrapper)
{
IFCFile file = exporterIFC.GetFile();
IList<CurveLoop> curveLoops = extrusionData.GetLoops();
if (curveLoops.Count == 0)
return null;
if (plane == null)
{
// assumption: first curve loop defines the plane.
if (!curveLoops[0].HasPlane())
return null;
plane = curveLoops[0].GetPlane();
}
ElementId catId = CategoryUtil.GetSafeCategoryId(insertElement);
IFCAnyHandle openingProdRepHnd = RepresentationUtil.CreateExtrudedProductDefShape(exporterIFC, insertElement, catId,
curveLoops, plane, extrusionData.ExtrusionDirection, extrusionData.ScaledExtrusionLength);
string openingObjectType = isRecess ? "Recess" : "Opening";
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string openingName = NamingUtil.GetNameOverride(insertElement, null);
if (string.IsNullOrEmpty(openingName))
openingName = NamingUtil.GetNameOverride(hostElement, NamingUtil.CreateIFCObjectName(exporterIFC, hostElement));
IFCAnyHandle openingHnd = IFCInstanceExporter.CreateOpeningElement(file, openingGUID, ownerHistory, openingName, null,
openingObjectType, ExporterUtil.CreateLocalPlacement(file, hostPlacement, null), openingProdRepHnd, null);
IFCExtrusionCreationData ecData = null;
if (ExporterCacheManager.ExportOptionsCache.ExportBaseQuantities)
{
double height, width;
ecData = new IFCExtrusionCreationData();
if (GeometryUtil.ComputeHeightWidthOfCurveLoop(curveLoops[0], plane, out height, out width))
{
ecData.ScaledHeight = UnitUtil.ScaleLength(height);
ecData.ScaledWidth = UnitUtil.ScaleLength(width);
}
else
{
double area = ExporterIFCUtils.ComputeAreaOfCurveLoops(curveLoops);
ecData.ScaledArea = UnitUtil.ScaleArea(area);
}
PropertyUtil.CreateOpeningQuantities(exporterIFC, openingHnd, ecData);
}
if (localWrapper != null)
{
Element elementForProperties = null;
if (GUIDUtil.IsGUIDFor(insertElement, openingGUID))
elementForProperties = insertElement;
localWrapper.AddElement(elementForProperties, openingHnd, setter, ecData, true);
}
string voidGuid = GUIDUtil.CreateGUID();
IFCInstanceExporter.CreateRelVoidsElement(file, voidGuid, ownerHistory, null, null, hostObjHnd, openingHnd);
return openingHnd;
}
示例11: ExportGenericSlab
//.........这里部分代码省略.........
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
bodyExporterOptions.TessellationLevel = BodyExporter.GetTessellationLevel();
BodyData bodyData;
IFCAnyHandle prodDefHnd = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC,
slabElement, catId, geometryElement, bodyExporterOptions, null, ecData, out bodyData);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(prodDefHnd))
{
ecData.ClearOpenings();
return;
}
prodReps.Add(prodDefHnd);
repTypes.Add(bodyData.ShapeRepresentationType);
}
// Create the slab from either the extrusion or the BRep information.
string ifcGUID = GUIDUtil.CreateGUID(slabElement);
int numReps = exportParts ? 1 : prodReps.Count;
string entityType = IFCValidateEntry.GetValidIFCType<IFCSlabType>(slabElement, ifcEnumType, "FLOOR");
for (int ii = 0; ii < numReps; ii++)
{
string ifcName = NamingUtil.GetNameOverride(slabElement, NamingUtil.GetIFCNamePlusIndex(slabElement, ii == 0 ? -1 : ii + 1));
string ifcDescription = NamingUtil.GetDescriptionOverride(slabElement, null);
string ifcObjectType = NamingUtil.GetObjectTypeOverride(slabElement, exporterIFC.GetFamilyName());
string ifcTag = NamingUtil.GetTagOverride(slabElement, NamingUtil.CreateIFCElementId(slabElement));
string currentGUID = (ii == 0) ? ifcGUID : GUIDUtil.CreateGUID();
IFCAnyHandle localPlacementHnd = exportedAsInternalExtrusion ? localPlacements[ii] : localPlacement;
IFCAnyHandle slabHnd = IFCInstanceExporter.CreateSlab(file, currentGUID, ownerHistory, ifcName,
ifcDescription, ifcObjectType, localPlacementHnd, exportParts ? null : prodReps[ii],
ifcTag, entityType);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(slabHnd))
return;
if (exportParts)
{
PartExporter.ExportHostPart(exporterIFC, slabElement, slabHnd, productWrapper, placementSetter, localPlacementHnd, null);
}
slabHnds.Add(slabHnd);
if (!exportParts)
{
if (repTypes[ii] == ShapeRepresentationType.Brep)
brepSlabHnds.Add(slabHnd);
else
nonBrepSlabHnds.Add(slabHnd);
}
}
for (int ii = 0; ii < numReps; ii++)
{
IFCExtrusionCreationData loopExtraParam = ii < loopExtraParams.Count ? loopExtraParams[ii] : null;
productWrapper.AddElement(slabElement, slabHnds[ii], placementSetter, loopExtraParam, true);
}
if (exportedAsInternalExtrusion)
ExporterIFCUtils.ExportExtrudedSlabOpenings(exporterIFC, slabElement, placementSetter.LevelInfo,
localPlacements[0], slabHnds, extrusionLoops, floorPlane, productWrapper.ToNative());
}
if (!exportParts)
{
if (slabElement is HostObject)
{
HostObject hostObject = slabElement as HostObject;
if (nonBrepSlabHnds.Count > 0)
{
HostObjectExporter.ExportHostObjectMaterials(exporterIFC, hostObject, nonBrepSlabHnds,
geometryElement, productWrapper, ElementId.InvalidElementId, Toolkit.IFCLayerSetDirection.Axis3, false);
}
if (brepSlabHnds.Count > 0)
{
HostObjectExporter.ExportHostObjectMaterials(exporterIFC, hostObject, brepSlabHnds,
geometryElement, productWrapper, ElementId.InvalidElementId, Toolkit.IFCLayerSetDirection.Axis3, true);
}
}
else if (slabElement is FamilyInstance && slabHnds.Count > 0)
{
ElementId matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, slabElement);
Document doc = slabElement.Document;
foreach (IFCAnyHandle slabHnd in slabHnds)
{
CategoryUtil.CreateMaterialAssociation(exporterIFC, slabHnd, matId);
}
}
}
}
tr.Commit();
return;
}
}
示例12: 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();
}
}
}
示例13: ExportRebar
//.........这里部分代码省略.........
}
IFCAnyHandle prodRep = null;
double totalBarLengthUnscale = GetRebarTotalLength(element);
double volumeUnscale = GetRebarVolume(element);
double totalBarLength = UnitUtil.ScaleLength(totalBarLengthUnscale);
if (MathUtil.IsAlmostZero(totalBarLength))
return null;
ElementId materialId = ElementId.InvalidElementId;
ParameterUtil.GetElementIdValueFromElementOrSymbol(element, BuiltInParameter.MATERIAL_ID_PARAM, out materialId);
Document doc = element.Document;
ElementId typeId = element.GetTypeId();
RebarBarType elementType = doc.GetElement(element.GetTypeId()) as RebarBarType;
double diameter = UnitUtil.ScaleLength(elementType == null ? 1.0 / 12.0 : elementType.BarDiameter);
double radius = diameter / 2.0;
double longitudinalBarNominalDiameter = diameter;
double longitudinalBarCrossSectionArea = UnitUtil.ScaleArea(volumeUnscale / totalBarLengthUnscale);
double barLength = totalBarLength / GetRebarQuantity(element);
IList<Curve> baseCurves = GetRebarCenterlineCurves(element, true, false, false);
int numberOfBarPositions = GetNumberOfBarPositions(element);
string steelGrade = NamingUtil.GetOverrideStringValue(element, "SteelGrade", null);
// Allow use of IFC2x3 or IFC4 naming.
string predefinedType = NamingUtil.GetOverrideStringValue(element, "BarRole", null);
if (string.IsNullOrWhiteSpace(predefinedType))
predefinedType = NamingUtil.GetOverrideStringValue(element, "PredefinedType", null);
IFCReinforcingBarRole role = GetReinforcingBarRole(predefinedType);
string origRebarName = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
string rebarDescription = NamingUtil.GetDescriptionOverride(element, null);
string rebarObjectType = NamingUtil.GetObjectTypeOverride(element, NamingUtil.CreateIFCObjectName(exporterIFC, element));
string rebarTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
const int maxBarGUIDS = IFCReinforcingBarSubElements.BarEnd - IFCReinforcingBarSubElements.BarStart + 1;
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
IFCAnyHandle originalPlacement = setter.LocalPlacement;
for (int i = 0; i < numberOfBarPositions; i++)
{
if (!DoesBarExistAtPosition(element, i))
continue;
string rebarName = NamingUtil.GetNameOverride(element, origRebarName + ": " + i);
Transform barTrf = GetBarPositionTransform(element, i);
IList<Curve> curves = new List<Curve>();
double endParam = 0.0;
foreach (Curve baseCurve in baseCurves)
{
if (baseCurve is Arc || baseCurve is Ellipse)
{
if (baseCurve.IsBound)
endParam += UnitUtil.ScaleAngle(baseCurve.GetEndParameter(1) - baseCurve.GetEndParameter(0));
else
endParam += UnitUtil.ScaleAngle(2 * Math.PI);
}
else
endParam += 1.0;
curves.Add(baseCurve.CreateTransformed(barTrf));
}
IFCAnyHandle compositeCurve = GeometryUtil.CreateCompositeCurve(exporterIFC, curves);
IFCAnyHandle sweptDiskSolid = IFCInstanceExporter.CreateSweptDiskSolid(file, compositeCurve, radius, null, 0, endParam);
HashSet<IFCAnyHandle> bodyItems = new HashSet<IFCAnyHandle>();
bodyItems.Add(sweptDiskSolid);
IFCAnyHandle shapeRep = RepresentationUtil.CreateAdvancedSweptSolidRep(exporterIFC, element, categoryId, exporterIFC.Get3DContextHandle("Body"), bodyItems, null);
IList<IFCAnyHandle> shapeReps = new List<IFCAnyHandle>();
shapeReps.Add(shapeRep);
prodRep = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, shapeReps);
IFCAnyHandle copyLevelPlacement = (i == 0) ? originalPlacement : ExporterUtil.CopyLocalPlacement(file, originalPlacement);
string rebarGUID = (i < maxBarGUIDS) ?
GUIDUtil.CreateSubElementGUID(element, i + (int)IFCReinforcingBarSubElements.BarStart) :
GUIDUtil.CreateGUID();
IFCAnyHandle elemHnd = IFCInstanceExporter.CreateReinforcingBar(file, rebarGUID, exporterIFC.GetOwnerHistoryHandle(),
rebarName, rebarDescription, rebarObjectType, copyLevelPlacement,
prodRep, rebarTag, steelGrade, longitudinalBarNominalDiameter, longitudinalBarCrossSectionArea,
barLength, role, null);
createdRebars.Add(elemHnd);
productWrapper.AddElement(element, elemHnd, setter.LevelInfo, null, true);
ExporterCacheManager.HandleToElementCache.Register(elemHnd, element.Id);
CategoryUtil.CreateMaterialAssociation(exporterIFC, elemHnd, materialId);
}
}
transaction.Commit();
}
return createdRebars;
}
示例14: ExportRailing
//.........这里部分代码省略.........
SolidMeshGeometryInfo subElementSolidMeshInfo = GeometryUtil.GetSplitSolidMeshGeometry(subElementGeom);
IList<Solid> subElementSolids = subElementSolidMeshInfo.GetSolids();
IList<Mesh> subElementMeshes = subElementSolidMeshInfo.GetMeshes();
foreach (Solid subElementSolid in subElementSolids)
solids.Add(subElementSolid);
foreach (Mesh subElementMesh in subElementMeshes)
meshes.Add(subElementMesh);
}
}
ElementId catId = CategoryUtil.GetSafeCategoryId(element);
BodyData bodyData = null;
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
bodyExporterOptions.TessellationLevel = BodyExporter.GetTessellationLevel();
//bodyExporterOptions.UseGroupsIfPossible = true;
//bodyExporterOptions.UseMappedGeometriesIfPossible = true;
if (solids.Count > 0 || meshes.Count > 0)
{
bodyData = BodyExporter.ExportBody(exporterIFC, element, catId, ElementId.InvalidElementId, solids, meshes, bodyExporterOptions, ecData);
}
else
{
IList<GeometryObject> geomlist = new List<GeometryObject>();
geomlist.Add(geomElem);
bodyData = BodyExporter.ExportBody(exporterIFC, element, catId, ElementId.InvalidElementId, geomlist, bodyExporterOptions, ecData);
}
IFCAnyHandle bodyRep = bodyData.RepresentationHnd;
if (IFCAnyHandleUtil.IsNullOrHasNoValue(bodyRep))
{
if (ecData != null)
ecData.ClearOpenings();
return;
}
IList<IFCAnyHandle> representations = new List<IFCAnyHandle>();
representations.Add(bodyRep);
IList<GeometryObject> geomObjects = new List<GeometryObject>();
foreach (Solid solid in solids)
geomObjects.Add(solid);
foreach (Mesh mesh in meshes)
geomObjects.Add(mesh);
Transform boundingBoxTrf = (bodyData.OffsetTransform != null) ? bodyData.OffsetTransform.Inverse : Transform.Identity;
boundingBoxTrf = inverseTrf.Multiply(boundingBoxTrf);
IFCAnyHandle boundingBoxRep = BoundingBoxExporter.ExportBoundingBox(exporterIFC, geomObjects, boundingBoxTrf);
if (boundingBoxRep != null)
representations.Add(boundingBoxRep);
IFCAnyHandle prodRep = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, representations);
IFCAnyHandle ownerHistory = ExporterCacheManager.OwnerHistoryHandle;
string instanceGUID = GUIDUtil.CreateGUID(element);
string instanceName = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
string instanceDescription = NamingUtil.GetDescriptionOverride(element, null);
string instanceObjectType = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
string instanceTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
string railingType = IFCValidateEntry.GetValidIFCType(element, ifcEnumType);
IFCAnyHandle railing = IFCInstanceExporter.CreateRailing(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, ecData.GetLocalPlacement(),
prodRep, instanceTag, railingType);
bool associateToLevel = (hostId == ElementId.InvalidElementId);
productWrapper.AddElement(element, railing, setter, ecData, associateToLevel);
OpeningUtil.CreateOpeningsIfNecessary(railing, element, ecData, bodyData.OffsetTransform,
exporterIFC, ecData.GetLocalPlacement(), setter, productWrapper);
CategoryUtil.CreateMaterialAssociations(exporterIFC, railing, bodyData.MaterialIds);
// Create multi-story duplicates of this railing.
if (stairRampInfo != null)
{
stairRampInfo.AddComponent(0, railing);
List<IFCAnyHandle> stairHandles = stairRampInfo.StairOrRampHandles;
for (int ii = 1; ii < stairHandles.Count; ii++)
{
IFCAnyHandle railingLocalPlacement = stairRampInfo.LocalPlacements[ii];
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(railingLocalPlacement))
{
IFCAnyHandle railingHndCopy = CopyRailingHandle(exporterIFC, element, catId, railingLocalPlacement, railing);
stairRampInfo.AddComponent(ii, railingHndCopy);
productWrapper.AddElement(element, railingHndCopy, (IFCLevelInfo)null, ecData, false);
CategoryUtil.CreateMaterialAssociations(exporterIFC, railingHndCopy, bodyData.MaterialIds);
}
}
ExporterCacheManager.StairRampContainerInfoCache.AddStairRampContainerInfo(hostId, stairRampInfo);
}
}
transaction.Commit();
}
}
}
示例15: ExportRoof
/// <summary>
/// Exports a roof to IfcRoof.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="ifcEnumType">The roof type.</param>
/// <param name="roof">The roof element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
public static void ExportRoof(ExporterIFC exporterIFC, string ifcEnumType, Element roof, GeometryElement geometryElement,
ProductWrapper productWrapper)
{
if (roof == null || geometryElement == null)
return;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (PlacementSetter placementSetter = PlacementSetter.Create(exporterIFC, roof))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
// If the roof is an in-place family, we will allow any arbitrary orientation. While this may result in some
// in-place "cubes" exporting with the wrong direction, it is unlikely that an in-place family would be
// used for this reason in the first place.
ecData.PossibleExtrusionAxes = (roof is FamilyInstance) ? IFCExtrusionAxes.TryXYZ : IFCExtrusionAxes.TryZ;
ecData.AreInnerRegionsOpenings = true;
ecData.SetLocalPlacement(placementSetter.LocalPlacement);
ElementId categoryId = CategoryUtil.GetSafeCategoryId(roof);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
BodyData bodyData;
IFCAnyHandle representation = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, roof,
categoryId, geometryElement, bodyExporterOptions, null, ecData, out bodyData);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(representation))
{
ecData.ClearOpenings();
return;
}
bool exportSlab = ecData.ScaledLength > MathUtil.Eps();
string guid = GUIDUtil.CreateGUID(roof);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string roofName = NamingUtil.GetNameOverride(roof, NamingUtil.GetIFCName(roof));
string roofDescription = NamingUtil.GetDescriptionOverride(roof, null);
string roofObjectType = NamingUtil.GetObjectTypeOverride(roof, NamingUtil.CreateIFCObjectName(exporterIFC, roof));
IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
string elementTag = NamingUtil.GetTagOverride(roof, NamingUtil.CreateIFCElementId(roof));
string roofType = GetIFCRoofType(ifcEnumType);
roofType = IFCValidateEntry.GetValidIFCType(roof, ifcEnumType);
IFCAnyHandle roofHnd = IFCInstanceExporter.CreateRoof(file, guid, ownerHistory, roofName, roofDescription,
roofObjectType, localPlacement, exportSlab ? null : representation, elementTag, roofType);
productWrapper.AddElement(roof, roofHnd, placementSetter.LevelInfo, ecData, true);
// will export its host object materials later if it is a roof
if (!(roof is RoofBase))
CategoryUtil.CreateMaterialAssociations(exporterIFC, roofHnd, bodyData.MaterialIds);
if (exportSlab)
{
string slabGUID = GUIDUtil.CreateSubElementGUID(roof, (int)IFCRoofSubElements.RoofSlabStart);
string slabName = roofName + ":1";
IFCAnyHandle slabLocalPlacementHnd = ExporterUtil.CopyLocalPlacement(file, localPlacement);
IFCAnyHandle slabHnd = IFCInstanceExporter.CreateSlab(file, slabGUID, ownerHistory, slabName,
roofDescription, roofObjectType, slabLocalPlacementHnd, representation, elementTag, "ROOF");
Transform offsetTransform = (bodyData != null) ? bodyData.OffsetTransform : Transform.Identity;
OpeningUtil.CreateOpeningsIfNecessary(slabHnd, roof, ecData, offsetTransform,
exporterIFC, slabLocalPlacementHnd, placementSetter, productWrapper);
ExporterUtil.RelateObject(exporterIFC, roofHnd, slabHnd);
productWrapper.AddElement(null, slabHnd, placementSetter.LevelInfo, ecData, false);
CategoryUtil.CreateMaterialAssociations(exporterIFC, slabHnd, bodyData.MaterialIds);
}
}
tr.Commit();
}
}
}