本文整理汇总了C#中BIM.IFC.Utility.ProductWrapper.AddElement方法的典型用法代码示例。如果您正苦于以下问题:C# ProductWrapper.AddElement方法的具体用法?C# ProductWrapper.AddElement怎么用?C# ProductWrapper.AddElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BIM.IFC.Utility.ProductWrapper
的用法示例。
在下文中一共展示了ProductWrapper.AddElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
}
示例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.SpatialElementHandleCache.Find(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 = exporterIFC.GetOwnerHistoryHandle();
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.ExportGroup)
{
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: ExportBeam
//.........这里部分代码省略.........
BodyData bodyData = null;
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
if (solids.Count > 0 || meshes.Count > 0)
{
bodyData = BodyExporter.ExportBody(exporterIFC, element, catId, ElementId.InvalidElementId,
solids, meshes, bodyExporterOptions, extrusionCreationData);
}
else
{
IList<GeometryObject> geomlist = new List<GeometryObject>();
geomlist.Add(geometryElement);
bodyData = BodyExporter.ExportBody(exporterIFC, element, catId, ElementId.InvalidElementId,
geomlist, bodyExporterOptions, extrusionCreationData);
}
repHnd = bodyData.RepresentationHnd;
materialIds = bodyData.MaterialIds;
offsetTransform = bodyData.OffsetTransform;
}
if (IFCAnyHandleUtil.IsNullOrHasNoValue(repHnd))
{
extrusionCreationData.ClearOpenings();
return;
}
IList<IFCAnyHandle> representations = new List<IFCAnyHandle>();
if (canExportAxis)
{
XYZ curveOffset = new XYZ(0, 0, 0);
if (offsetTransform != null)
{
curveOffset = -offsetTransform.Origin / scale;
}
else
{
// Note that we do not have to have any scaling adjustment here, since the curve origin is in the
// same internal coordinate system as the curve.
curveOffset = -plane.Origin;
}
Plane offsetPlane = new Plane(plane.XVec, plane.YVec, XYZ.Zero);
IFCGeometryInfo info = IFCGeometryInfo.CreateCurveGeometryInfo(exporterIFC, offsetPlane, projDir, false);
ExporterIFCUtils.CollectGeometryInfo(exporterIFC, info, curve, curveOffset, true);
IList<IFCAnyHandle> axis_items = info.GetCurves();
if (axis_items.Count > 0)
{
string identifierOpt = "Axis"; // this is by IFC2x2 convention, not temporary
string representationTypeOpt = "Curve2D"; // this is by IFC2x2 convention, not temporary
axisRep = RepresentationUtil.CreateShapeRepresentation(exporterIFC, element, catId, exporterIFC.Get3DContextHandle(identifierOpt),
identifierOpt, representationTypeOpt, axis_items);
representations.Add(axisRep);
}
}
representations.Add(repHnd);
Transform boundingBoxTrf = (offsetTransform == null) ? Transform.Identity : offsetTransform.Inverse;
IFCAnyHandle boundingBoxRep = BoundingBoxExporter.ExportBoundingBox(exporterIFC, geometryElement, boundingBoxTrf);
if (boundingBoxRep != null)
representations.Add(boundingBoxRep);
IFCAnyHandle prodRep = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, representations);
string instanceGUID = GUIDUtil.CreateGUID(element);
string instanceName = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
string instanceDescription = NamingUtil.GetDescriptionOverride(element, null);
string instanceObjectType = NamingUtil.GetObjectTypeOverride(element, NamingUtil.CreateIFCObjectName(exporterIFC, element));
string instanceTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
IFCAnyHandle beam = IFCInstanceExporter.CreateBeam(file, instanceGUID, exporterIFC.GetOwnerHistoryHandle(),
instanceName, instanceDescription, instanceObjectType, extrusionCreationData.GetLocalPlacement(), prodRep, instanceTag);
productWrapper.AddElement(element, beam, setter, extrusionCreationData, true);
OpeningUtil.CreateOpeningsIfNecessary(beam, element, extrusionCreationData, offsetTransform, exporterIFC,
extrusionCreationData.GetLocalPlacement(), setter, productWrapper);
FamilyTypeInfo typeInfo = new FamilyTypeInfo();
typeInfo.ScaledDepth = extrusionCreationData.ScaledLength;
typeInfo.ScaledArea = extrusionCreationData.ScaledArea;
typeInfo.ScaledInnerPerimeter = extrusionCreationData.ScaledInnerPerimeter;
typeInfo.ScaledOuterPerimeter = extrusionCreationData.ScaledOuterPerimeter;
PropertyUtil.CreateBeamColumnBaseQuantities(exporterIFC, beam, element, typeInfo);
if (materialIds.Count != 0)
{
CategoryUtil.CreateMaterialAssociations(exporterIFC, beam, materialIds);
}
// Register the beam's IFC handle for later use by truss and beam system export.
ExporterCacheManager.ElementToHandleCache.Register(element.Id, beam);
}
}
transaction.Commit();
}
}
示例6: ExportGutter
/// <summary>
/// Exports a gutter element.
/// </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>
public static void ExportGutter(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement, ProductWrapper productWrapper)
{
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());
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions();
IFCAnyHandle bodyRep = BodyExporter.ExportBody(exporterIFC, element, categoryId, ElementId.InvalidElementId,
geometryElement, bodyExporterOptions, ecData).RepresentationHnd;
if (IFCAnyHandleUtil.IsNullOrHasNoValue(bodyRep))
{
if (ecData != null)
ecData.ClearOpenings();
return;
}
IFCAnyHandle origin = ExporterUtil.CreateAxis2Placement3D(file);
IFCAnyHandle repMap3dHnd = IFCInstanceExporter.CreateRepresentationMap(file, origin, bodyRep);
List<IFCAnyHandle> repMapList = new List<IFCAnyHandle>();
repMapList.Add(repMap3dHnd);
string elementTypeName = NamingUtil.CreateIFCObjectName(exporterIFC, element);
IFCAnyHandle style = IFCInstanceExporter.CreatePipeSegmentType(file, GUIDUtil.CreateGUID(element), exporterIFC.GetOwnerHistoryHandle(),
elementTypeName, null, null, null, repMapList, NamingUtil.CreateIFCElementId(element), elementTypeName, IFCPipeSegmentType.Gutter);
List<IFCAnyHandle> representationMaps = GeometryUtil.GetRepresentationMaps(style);
IFCAnyHandle mappedItem = ExporterUtil.CreateDefaultMappedItem(file, representationMaps[0]);
IList<IFCAnyHandle> representations = new List<IFCAnyHandle>();
representations.Add(mappedItem);
IFCAnyHandle bodyMappedItemRep = RepresentationUtil.CreateBodyMappedItemRep(exporterIFC,
element, categoryId, exporterIFC.Get3DContextHandle("Body"), representations);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(bodyMappedItemRep))
return;
List<IFCAnyHandle> shapeReps = new List<IFCAnyHandle>();
shapeReps.Add(bodyMappedItemRep);
IFCAnyHandle boundingBoxRep = BoundingBoxExporter.ExportBoundingBox(exporterIFC, geometryElement, Transform.Identity);
if (boundingBoxRep != null)
shapeReps.Add(boundingBoxRep);
IFCAnyHandle prodRep = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, shapeReps);
IFCAnyHandle localPlacementToUse;
ElementId roomId = setter.UpdateRoomRelativeCoordinates(element, out localPlacementToUse);
if (roomId == ElementId.InvalidElementId)
localPlacementToUse = ecData.GetLocalPlacement();
string name = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, elementTypeName);
string Tag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
IFCAnyHandle elemHnd = IFCInstanceExporter.CreateFlowSegment(file, GUIDUtil.CreateGUID(element),
exporterIFC.GetOwnerHistoryHandle(), name, description, objectType, localPlacementToUse, prodRep,
Tag);
if (roomId == ElementId.InvalidElementId)
{
productWrapper.AddElement(elemHnd, setter.GetLevelInfo(), ecData, true);
}
else
{
exporterIFC.RelateSpatialElement(roomId, elemHnd);
productWrapper.AddElement(elemHnd, setter.GetLevelInfo(), ecData, false);
}
OpeningUtil.CreateOpeningsIfNecessary(elemHnd, element, ecData, exporterIFC,
localPlacementToUse, setter, productWrapper);
}
tr.Commit();
}
}
}
示例7: ExportPart
//.........这里部分代码省略.........
{
bodyData = BodyExporter.ExportBody(exporterIFC, partElement, catId, ElementId.InvalidElementId, solids, meshes,
bodyExporterOptions, extrusionCreationData);
}
else
{
IList<GeometryObject> geomlist = new List<GeometryObject>();
geomlist.Add(geometryElement);
bodyData = BodyExporter.ExportBody(exporterIFC, partElement, catId, ElementId.InvalidElementId, geomlist,
bodyExporterOptions, extrusionCreationData);
}
IFCAnyHandle bodyRep = bodyData.RepresentationHnd;
if (IFCAnyHandleUtil.IsNullOrHasNoValue(bodyRep))
{
extrusionCreationData.ClearOpenings();
return;
}
IList<IFCAnyHandle> representations = new List<IFCAnyHandle>();
representations.Add(bodyRep);
IFCAnyHandle boundingBoxRep = BoundingBoxExporter.ExportBoundingBox(exporterIFC, geometryElement, Transform.Identity);
if (boundingBoxRep != null)
representations.Add(boundingBoxRep);
IFCAnyHandle prodRep = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, representations);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string partGUID = GUIDUtil.CreateGUID(partElement);
string partName = NamingUtil.GetNameOverride(partElement, NamingUtil.GetIFCName(partElement));
string partDescription = NamingUtil.GetDescriptionOverride(partElement, null);
string partObjectType = NamingUtil.GetObjectTypeOverride(partElement, NamingUtil.CreateIFCObjectName(exporterIFC, partElement));
string partTag = NamingUtil.GetTagOverride(partElement, NamingUtil.CreateIFCElementId(partElement));
IFCAnyHandle ifcPart = null;
if (!asBuildingElement)
{
ifcPart = IFCInstanceExporter.CreateBuildingElementPart(file, partGUID, ownerHistory, partName, partDescription,
partObjectType, extrusionCreationData.GetLocalPlacement(), prodRep, partTag);
}
else
{
string ifcEnumType;
IFCExportType exportType = ExporterUtil.GetExportType(exporterIFC, hostElement, out ifcEnumType);
switch (exportType)
{
case IFCExportType.ExportColumnType:
ifcPart = IFCInstanceExporter.CreateColumn(file, partGUID, ownerHistory, partName, partDescription, partObjectType,
extrusionCreationData.GetLocalPlacement(), prodRep, partTag);
break;
case IFCExportType.ExportCovering:
IFCCoveringType coveringType = CeilingExporter.GetIFCCoveringType(hostElement, ifcEnumType);
ifcPart = IFCInstanceExporter.CreateCovering(file, partGUID, ownerHistory, partName, partDescription, partObjectType,
extrusionCreationData.GetLocalPlacement(), prodRep, partTag, coveringType);
break;
case IFCExportType.ExportFooting:
IFCFootingType footingType = FootingExporter.GetIFCFootingType(hostElement, ifcEnumType);
ifcPart = IFCInstanceExporter.CreateFooting(file, partGUID, ownerHistory, partName, partDescription, partObjectType,
extrusionCreationData.GetLocalPlacement(), prodRep, partTag, footingType);
break;
case IFCExportType.ExportRoof:
IFCRoofType roofType = RoofExporter.GetIFCRoofType(ifcEnumType);
ifcPart = IFCInstanceExporter.CreateRoof(file, partGUID, ownerHistory, partName, partDescription, partObjectType,
extrusionCreationData.GetLocalPlacement(), prodRep, partTag, roofType);
break;
case IFCExportType.ExportSlab:
IFCSlabType slabType = FloorExporter.GetIFCSlabType(ifcEnumType);
ifcPart = IFCInstanceExporter.CreateSlab(file, partGUID, ownerHistory, partName, partDescription, partObjectType,
extrusionCreationData.GetLocalPlacement(), prodRep, partTag, slabType);
break;
case IFCExportType.ExportWall:
ifcPart = IFCInstanceExporter.CreateWallStandardCase(file, partGUID, ownerHistory, partName, partDescription,
partObjectType, extrusionCreationData.GetLocalPlacement(), prodRep, partTag);
break;
default:
ifcPart = IFCInstanceExporter.CreateBuildingElementProxy(file, partGUID, ownerHistory, partName, partDescription,
partObjectType, extrusionCreationData.GetLocalPlacement(), prodRep, partTag, IFCElementComposition.Element);
break;
}
}
productWrapper.AddElement(ifcPart, standaloneExport || asBuildingElement ? standalonePlacementSetter : placementSetter, extrusionCreationData, standaloneExport || asBuildingElement);
//Add the exported part to exported cache.
TraceExportedParts(partElement, partExportLevel, standaloneExport || asBuildingElement ? ElementId.InvalidElementId : hostElement.Id);
CategoryUtil.CreateMaterialAssociations(partElement.Document, exporterIFC, ifcPart, bodyData.MaterialIds);
transaction.Commit();
}
}
}
finally
{
if (standalonePlacementSetter != null)
standalonePlacementSetter.Dispose();
}
}
示例8: ExportInsulation
/// <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>
protected static bool ExportInsulation(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, null, null, ExporterUtil.GetBaseLevelIdForElement(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, 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 insulation = IFCInstanceExporter.CreateCovering(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag, IFCCoveringType.Insulation);
ExporterCacheManager.ElementToHandleCache.Register(element.Id, insulation);
productWrapper.AddElement(element, insulation, placementSetter.GetLevelInfo(), ecData, true);
ElementId matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, element);
CategoryUtil.CreateMaterialAssociation(exporterIFC, insulation, matId);
}
}
tr.Commit();
return true;
}
}
示例9: Export
//.........这里部分代码省略.........
typeDescription, applicableOccurence, propertySetsOpt, repMapListOpt, typeTag, typeElementType, element, type);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(styleHandle))
{
currentTypeInfo.Style = styleHandle;
ExporterCacheManager.TypeObjectsCache.Register(typeId, false, currentTypeInfo);
}
}
string instanceGUID = GUIDUtil.CreateGUID(element);
string instanceName = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
string instanceObjectType = NamingUtil.GetObjectTypeOverride(element, NamingUtil.CreateIFCObjectName(exporterIFC, element));
string instanceDescription = NamingUtil.GetDescriptionOverride(element, null);
string instanceTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
bool roomRelated = !FamilyExporterUtil.IsDistributionFlowElementSubType(exportType);
ElementId roomId = ElementId.InvalidElementId;
if (roomRelated)
{
roomId = setter.UpdateRoomRelativeCoordinates(element, out localPlacementToUse);
}
IFCAnyHandle instanceHandle = null;
if (FamilyExporterUtil.IsFurnishingElementSubType(exportType))
{
instanceHandle = IFCInstanceExporter.CreateFurnishingElement(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if (FamilyExporterUtil.IsDistributionFlowElementSubType(exportType))
{
instanceHandle = IFCInstanceExporter.CreateDistributionFlowElement(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if (FamilyExporterUtil.IsEnergyConversionDeviceSubType(exportType))
{
instanceHandle = IFCInstanceExporter.CreateEnergyConversionDevice(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if (FamilyExporterUtil.IsFlowFittingSubType(exportType))
{
instanceHandle = IFCInstanceExporter.CreateFlowFitting(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if (FamilyExporterUtil.IsFlowMovingDeviceSubType(exportType))
{
instanceHandle = IFCInstanceExporter.CreateFlowMovingDevice(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if (FamilyExporterUtil.IsFlowSegmentSubType(exportType))
{
instanceHandle = IFCInstanceExporter.CreateFlowSegment(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if (FamilyExporterUtil.IsFlowStorageDeviceSubType(exportType))
{
instanceHandle = IFCInstanceExporter.CreateFlowStorageDevice(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if (FamilyExporterUtil.IsFlowTerminalSubType(exportType))
{
instanceHandle = IFCInstanceExporter.CreateFlowTerminal(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if (FamilyExporterUtil.IsFlowTreatmentDeviceSubType(exportType))
{
instanceHandle = IFCInstanceExporter.CreateFlowTreatmentDevice(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if (FamilyExporterUtil.IsFlowControllerSubType(exportType))
{
instanceHandle = IFCInstanceExporter.CreateFlowController(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
if (IFCAnyHandleUtil.IsNullOrHasNoValue(instanceHandle))
return;
if (roomId != ElementId.InvalidElementId)
{
exporterIFC.RelateSpatialElement(roomId, instanceHandle);
productWrapper.AddElement(instanceHandle, setter, extraParams, false);
}
else
{
productWrapper.AddElement(instanceHandle, setter, extraParams, LevelUtil.AssociateElementToLevel(element));
}
OpeningUtil.CreateOpeningsIfNecessary(instanceHandle, element, extraParams, exporterIFC, localPlacementToUse, setter, productWrapper);
if (currentTypeInfo.IsValid())
ExporterCacheManager.TypeRelationsCache.Add(currentTypeInfo.Style, instanceHandle);
PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, element, productWrapper);
ExporterCacheManager.MEPCache.Register(element, instanceHandle);
tr.Commit();
}
}
}
}
示例10: 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;
IFCPlacementSetter placementSetter = null;
IFCLevelInfo levelInfo = null;
string ifcEnumType;
IFCExportType exportAs = ExporterUtil.GetExportType(exporterIFC, element, out ifcEnumType);
if (exportAs == IFCExportType.ExportSystem)
{
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 = IFCPlacementSetter.Create(exporterIFC, element, null, null, ExporterUtil.GetBaseLevelIdForElement(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.GetPlacement();
levelInfo = placementSetter.GetLevelInfo();
switch (exportAs)
{
case IFCExportType.ExportCurtainWall:
assemblyInstanceHnd = IFCInstanceExporter.CreateCurtainWall(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag);
break;
case IFCExportType.ExportRamp:
IFCRampType rampPredefinedType = RampExporter.GetIFCRampType(ifcEnumType);
assemblyInstanceHnd = IFCInstanceExporter.CreateRamp(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag,
rampPredefinedType);
break;
case IFCExportType.ExportRoof:
IFCRoofType roofPredefinedType = RoofExporter.GetIFCRoofType(ifcEnumType);
assemblyInstanceHnd = IFCInstanceExporter.CreateRoof(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag,
roofPredefinedType);
break;
case IFCExportType.ExportStair:
IFCStairType stairPredefinedType = StairsExporter.GetIFCStairType(ifcEnumType);
assemblyInstanceHnd = IFCInstanceExporter.CreateStair(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag,
stairPredefinedType);
break;
case IFCExportType.ExportWall:
assemblyInstanceHnd = IFCInstanceExporter.CreateWall(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag);
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);
ExporterCacheManager.AssemblyInstanceCache.RegisterAssemblyInstance(element.Id, assemblyInstanceHnd);
//.........这里部分代码省略.........
示例11: ExportCovering
/// <summary>
/// Exports an element as IFC covering.
/// </summary>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="element">
/// The element to be exported.
/// </param>
/// <param name="geometryElement">
/// The geometry element.
/// </param>
/// <param name="productWrapper">
/// The ProductWrapper.
/// </param>
public static void ExportCovering(ExporterIFC exporterIFC, Element element, GeometryElement geomElem, string ifcEnumType, ProductWrapper productWrapper)
{
bool exportParts = PartExporter.CanExportParts(element);
if (exportParts && !PartExporter.CanExportElementInPartExport(element, element.Level.Id, false))
return;
ElementType elemType = element.Document.GetElement(element.GetTypeId()) as ElementType;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction transaction = new IFCTransaction(file))
{
using (IFCPlacementSetter setter = IFCPlacementSetter.Create(exporterIFC, element))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
IFCAnyHandle prodRep = null;
if (!exportParts)
{
ecData.SetLocalPlacement(setter.GetPlacement());
ecData.PossibleExtrusionAxes = IFCExtrusionAxes.TryZ;
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
prodRep = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, element,
categoryId, geomElem, bodyExporterOptions, null, ecData);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(prodRep))
{
ecData.ClearOpenings();
return;
}
}
string instanceGUID = GUIDUtil.CreateGUID(element);
string instanceName = NamingUtil.GetIFCName(element);
string instanceDescription = NamingUtil.GetDescriptionOverride(element, null);
string instanceObjectType = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
string instanceElemId = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
Toolkit.IFCCoveringType coveringType = GetIFCCoveringType(element, ifcEnumType);
IFCAnyHandle covering = IFCInstanceExporter.CreateCovering(file, instanceGUID, exporterIFC.GetOwnerHistoryHandle(),
instanceName, instanceDescription, instanceObjectType, setter.GetPlacement(), prodRep, instanceElemId, coveringType);
if (exportParts)
{
PartExporter.ExportHostPart(exporterIFC, element, covering, productWrapper, setter, setter.GetPlacement(), null);
}
Boolean containInSpace = false;
IFCAnyHandle localPlacementToUse = setter.GetPlacement();
// Assign ceiling to room/IfcSpace if it is bounding a single Room for FMHandOver view only
ExportOptionsCache exportOptionsCache = ExporterCacheManager.ExportOptionsCache;
if (String.Compare(exportOptionsCache.SelectedConfigName, "FMHandOverView") == 0)
{
if (ExporterCacheManager.CeilingSpaceRelCache.ContainsKey(element.Id))
{
IList<ElementId> roomlist = ExporterCacheManager.CeilingSpaceRelCache[element.Id];
// Process Ceiling to be contained in a Space only when it is exactly bounding one Space
if (roomlist.Count == 1)
{
productWrapper.AddElement(covering, setter, null, false);
// Modify the Ceiling placement to be relative to the Space that it bounds
IFCAnyHandle roomPlacement = IFCAnyHandleUtil.GetObjectPlacement(ExporterCacheManager.SpatialElementHandleCache.Find(roomlist[0]));
Transform relTrf = ExporterIFCUtils.GetRelativeLocalPlacementOffsetTransform(roomPlacement, localPlacementToUse);
Transform inverseTrf = relTrf.Inverse;
IFCAnyHandle relLocalPlacement = ExporterUtil.CreateAxis2Placement3D(file, inverseTrf.Origin, inverseTrf.BasisZ, inverseTrf.BasisX);
IFCAnyHandleUtil.SetAttribute(localPlacementToUse, "PlacementRelTo", roomPlacement);
GeometryUtil.SetRelativePlacement(localPlacementToUse, relLocalPlacement);
exporterIFC.RelateSpatialElement(roomlist[0], covering);
containInSpace = true;
}
}
}
// if not contained in Space, assign it to default containment in Level
if (!containInSpace)
productWrapper.AddElement(covering, setter, null, LevelUtil.AssociateElementToLevel(element));
if (!exportParts)
{
Ceiling ceiling = element as Ceiling;
if (ceiling != null)
//.........这里部分代码省略.........
示例12: ExportRoofAsParts
/// <summary>
/// Export the roof to IfcRoof containing its parts.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The roof element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
public static void ExportRoofAsParts(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement, ProductWrapper productWrapper)
{
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction transaction = new IFCTransaction(file))
{
using (IFCPlacementSetter setter = IFCPlacementSetter.Create(exporterIFC, element, null, null, ExporterUtil.GetBaseLevelIdForElement(element)))
{
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
IFCAnyHandle localPlacement = setter.GetPlacement();
IFCAnyHandle prodRepHnd = null;
string elementGUID = GUIDUtil.CreateGUID(element);
string elementName = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
string elementDescription = NamingUtil.GetDescriptionOverride(element, null);
string elementObjectType = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
string elementTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
//need to convert the string to enum
string ifcEnumType = ExporterUtil.GetIFCTypeFromExportTable(exporterIFC, element);
IFCAnyHandle roofHandle = IFCInstanceExporter.CreateRoof(file, elementGUID, ownerHistory, elementName, elementDescription, elementObjectType, localPlacement, prodRepHnd, elementTag, GetIFCRoofType(ifcEnumType));
// Export the parts
PartExporter.ExportHostPart(exporterIFC, element, roofHandle, productWrapper, setter, localPlacement, null);
productWrapper.AddElement(element, roofHandle, setter, null, true);
transaction.Commit();
}
}
}
示例13: ExportGenericInstance
//.........这里部分代码省略.........
if (ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, "NominalDiameter", out nominalDiameterVal) != null)
nominalDiameter = nominalDiameterVal * scale;
if (ParameterUtil.GetDoubleValueFromElementOrSymbol(familyInstance, "NominalLength", out nominalLengthVal) != null)
nominalLength = nominalLengthVal * scale;
instanceHandle = IFCInstanceExporter.CreateMechanicalFastener(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag,
nominalDiameter, nominalLength);
break;
}
case IFCExportType.ExportRailingType:
{
string strEnumType;
IFCExportType exportAs = ExporterUtil.GetExportType(exporterIFC, familyInstance, out strEnumType);
instanceHandle = IFCInstanceExporter.CreateRailing(file, instanceGUID, ownerHistory, instanceName, instanceDescription,
instanceObjectType, localPlacementToUse, productRepresentation, instanceTag,
RailingExporter.GetIFCRailingType(familyInstance, strEnumType));
break;
}
case IFCExportType.ExportSpace:
{
string instanceLongName = NamingUtil.GetLongNameOverride(familyInstance, NamingUtil.GetLongNameOverride(familyInstance, instanceName));
IFCInternalOrExternal internalOrExternal = CategoryUtil.IsElementExternal(familyInstance) ? IFCInternalOrExternal.External : IFCInternalOrExternal.Internal;
instanceHandle = IFCInstanceExporter.CreateSpace(file, instanceGUID, ownerHistory, instanceName, instanceDescription,
instanceObjectType, localPlacementToUse, productRepresentation, instanceLongName, IFCElementComposition.Element,
internalOrExternal, null);
break;
}
default:
{
if ((type == IFCExportType.ExportFurnishingElement) || IsFurnishingElementSubType(type))
{
instanceHandle = IFCInstanceExporter.CreateFurnishingElement(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if ((type == IFCExportType.ExportEnergyConversionDevice) || IsEnergyConversionDeviceSubType(type))
{
instanceHandle = IFCInstanceExporter.CreateEnergyConversionDevice(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if ((type == IFCExportType.ExportFlowFitting) || IsFlowFittingSubType(type))
{
instanceHandle = IFCInstanceExporter.CreateFlowFitting(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if ((type == IFCExportType.ExportFlowMovingDevice) || IsFlowMovingDeviceSubType(type))
{
instanceHandle = IFCInstanceExporter.CreateFlowMovingDevice(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if ((type == IFCExportType.ExportFlowSegment) || IsFlowSegmentSubType(type))
{
instanceHandle = IFCInstanceExporter.CreateFlowSegment(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if ((type == IFCExportType.ExportFlowStorageDevice) || IsFlowStorageDeviceSubType(type))
{
instanceHandle = IFCInstanceExporter.CreateFlowStorageDevice(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if ((type == IFCExportType.ExportFlowTerminal) || IsFlowTerminalSubType(type))
{
instanceHandle = IFCInstanceExporter.CreateFlowTerminal(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if ((type == IFCExportType.ExportFlowTreatmentDevice) || IsFlowTreatmentDeviceSubType(type))
{
instanceHandle = IFCInstanceExporter.CreateFlowTreatmentDevice(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if ((type == IFCExportType.ExportFlowController) || IsFlowControllerSubType(type))
{
instanceHandle = IFCInstanceExporter.CreateFlowController(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if ((type == IFCExportType.ExportDistributionFlowElement) || IsDistributionFlowElementSubType(type))
{
instanceHandle = IFCInstanceExporter.CreateDistributionFlowElement(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag);
}
else if ((type == IFCExportType.ExportBuildingElementProxy) || (type == IFCExportType.ExportBuildingElementProxyType))
{
instanceHandle = IFCInstanceExporter.CreateBuildingElementProxy(file, instanceGUID, ownerHistory,
instanceName, instanceDescription, instanceObjectType, localPlacementToUse, productRepresentation, instanceTag, null);
}
break;
}
}
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(instanceHandle))
{
bool containedInSpace = (roomId != ElementId.InvalidElementId);
bool associateToLevel = containedInSpace ? false : !isChildInContainer;
wrapper.AddElement(familyInstance, instanceHandle, setter, extraParams, associateToLevel);
if (containedInSpace)
exporterIFC.RelateSpatialElement(roomId, instanceHandle);
}
return instanceHandle;
}
示例14: ExportRoofAsParts
/// <summary>
/// Export the roof to IfcRoof containing its parts.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The roof element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
public static void ExportRoofAsParts(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement, ProductWrapper productWrapper)
{
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction transaction = new IFCTransaction(file))
{
using (IFCPlacementSetter setter = IFCPlacementSetter.Create(exporterIFC, element))
{
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
IFCAnyHandle localPlacement = setter.GetPlacement();
using (IFCExtrusionCreationData extrusionCreationData = new IFCExtrusionCreationData())
{
extrusionCreationData.SetLocalPlacement(setter.GetPlacement());
extrusionCreationData.PossibleExtrusionAxes = IFCExtrusionAxes.TryXY;
IFCAnyHandle prodRepHnd = null;
string elementGUID = GUIDUtil.CreateGUID(element);
string elementName = NamingUtil.GetNameOverride(element, NamingUtil.GetIFCName(element));
string elementDescription = NamingUtil.GetDescriptionOverride(element, null);
string elementObjectType = NamingUtil.GetObjectTypeOverride(element, exporterIFC.GetFamilyName());
string elementTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
//need to convert the string to enum
string ifcEnumType = CategoryUtil.GetIFCEnumTypeName(exporterIFC, element);
IFCAnyHandle roofHandle = IFCInstanceExporter.CreateRoof(file, elementGUID, ownerHistory, elementName, elementDescription, elementObjectType, localPlacement, prodRepHnd, elementTag, GetIFCRoofType(ifcEnumType));
// Export the parts
PartExporter.ExportHostPart(exporterIFC, element, roofHandle, productWrapper, setter, localPlacement, null);
productWrapper.AddElement(roofHandle, setter, extrusionCreationData, LevelUtil.AssociateElementToLevel(element));
OpeningUtil.CreateOpeningsIfNecessary(roofHandle, element, extrusionCreationData, exporterIFC, extrusionCreationData.GetLocalPlacement(), setter, productWrapper);
PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, element, productWrapper);
}
transaction.Commit();
}
}
}
示例15: 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, IFCPlacementSetter setter, ProductWrapper wrapper)
{
if (IFCAnyHandleUtil.IsNullOrHasNoValue(elementHandle))
return;
int sz = info.Count;
if (sz == 0)
return;
using (IFCTransformSetter transformSetter = IFCTransformSetter.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))
ExporterIFCUtils.CreateOpeningQuantities(exporterIFC, openingElement, extraParams);
string voidGuid = GUIDUtil.CreateGUID();
IFCInstanceExporter.CreateRelVoidsElement(file, voidGuid, ownerHistory, null, null, elementHandle, openingElement);
}
}
}