本文整理汇总了C#中ExporterIFC.GetFamilyName方法的典型用法代码示例。如果您正苦于以下问题:C# ExporterIFC.GetFamilyName方法的具体用法?C# ExporterIFC.GetFamilyName怎么用?C# ExporterIFC.GetFamilyName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExporterIFC
的用法示例。
在下文中一共展示了ExporterIFC.GetFamilyName方法的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 = exporterIFC.GetOwnerHistoryHandle();
string revitObjectType = exporterIFC.GetFamilyName();
string name = NamingUtil.GetNameOverride(element, revitObjectType);
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, revitObjectType);
IFCAnyHandle fabricArea = IFCInstanceExporter.CreateGroup(file, guid,
ownerHistory, name, description, objectType);
productWrapper.AddElement(element, fabricArea);
IFCInstanceExporter.CreateRelAssignsToGroup(file, GUIDUtil.CreateGUID(), ownerHistory,
null, null, fabricSheetHandles, null, fabricArea);
tr.Commit();
return true;
}
}
示例2: ExportAssemblyInstanceElement
/// <summary>
/// Exports an element as an IFC assembly.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The IFCProductWrapper.</param>
/// <returns>True if exported successfully, false otherwise.</returns>
public static bool ExportAssemblyInstanceElement(ExporterIFC exporterIFC, AssemblyInstance element,
IFCProductWrapper productWrapper)
{
if (element == null)
return false;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (IFCPlacementSetter placementSetter = IFCPlacementSetter.Create(exporterIFC, element))
{
string guid = ExporterIFCUtils.CreateGUID(element);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string name = exporterIFC.GetName();
string objectType = exporterIFC.GetFamilyName();
IFCAnyHandle localPlacement = placementSetter.GetPlacement();
IFCAnyHandle representation = null;
string elementTag = NamingUtil.CreateIFCElementId(element);
IFCElementAssemblyType predefinedType = GetPredefinedTypeFromObjectType(objectType);
IFCAnyHandle assemblyInstanceHnd = IFCInstanceExporter.CreateElementAssembly(file, guid,
ownerHistory, name, null, objectType, localPlacement, representation, elementTag,
IFCAssemblyPlace.NotDefined, predefinedType);
productWrapper.AddElement(assemblyInstanceHnd, placementSetter.GetLevelInfo(), null, true);
PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, element, productWrapper);
ExporterCacheManager.AssemblyInstanceCache.RegisterAssemblyInstance(element.Id, assemblyInstanceHnd);
}
tr.Commit();
return true;
}
}
示例3: 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();
}
}
}
示例4: ExportDuctLining
/// <summary>
/// Exports an element as a covering of type insulation.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
/// <returns>True if exported successfully, false otherwise.</returns>
public static bool ExportDuctLining(ExporterIFC exporterIFC, Element element,
GeometryElement geometryElement, ProductWrapper productWrapper)
{
if (element == null || geometryElement == null)
return false;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (PlacementSetter placementSetter = PlacementSetter.Create(exporterIFC, element))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.SetLocalPlacement(placementSetter.LocalPlacement);
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
IFCAnyHandle representation = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, element,
categoryId, geometryElement, bodyExporterOptions, null, ecData, true);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(representation))
{
ecData.ClearOpenings();
return false;
}
string guid = GUIDUtil.CreateGUID(element);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string revitObjectType = exporterIFC.GetFamilyName();
string name = NamingUtil.GetNameOverride(element, revitObjectType);
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, revitObjectType);
IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
string elementTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
IFCAnyHandle ductLining = IFCInstanceExporter.CreateCovering(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag, "Wrapping");
ExporterCacheManager.ElementToHandleCache.Register(element.Id, ductLining);
productWrapper.AddElement(element, ductLining, placementSetter.LevelInfo, ecData, true);
ElementId matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, element);
CategoryUtil.CreateMaterialAssociation(exporterIFC, ductLining, matId);
}
}
tr.Commit();
return true;
}
}
示例5: CreateIFCObjectName
/// <summary>
/// Creates an IFC object name from export state.
/// </summary>
/// <remarks>
/// It is combined with family name and element type id.
/// </remarks>
/// <param name="exporterIFC">
/// The ExporterIFC object.
/// </param>
/// <param name="element">
/// The element.
/// </param>
/// <returns>
/// The string contains the name string value.
/// </returns>
public static string CreateIFCObjectName(ExporterIFC exporterIFC, Element element)
{
ElementId typeId = element != null ? element.GetTypeId() : ElementId.InvalidElementId;
string objectName = exporterIFC.GetFamilyName();
if (typeId != ElementId.InvalidElementId)
{
if (objectName == "")
return typeId.ToString();
else
return (objectName + ":" + typeId.ToString());
}
return "";
}
示例6: 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;
}
}
示例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: 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 IFCProductWrapper.</param>
/// <returns>True if exported successfully, false otherwise.</returns>
public static bool ExportBuildingElementProxy(ExporterIFC exporterIFC, Element element,
GeometryElement geometryElement, IFCProductWrapper 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.CreateBRepProductDefinitionShape(element.Document.Application, exporterIFC, element,
categoryId, geometryElement, bodyExporterOptions, null, ecData);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(representation))
{
ecData.ClearOpenings();
return false;
}
string guid = ExporterIFCUtils.CreateGUID(element);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string objectType = exporterIFC.GetFamilyName();
IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
string elementTag = NamingUtil.CreateIFCElementId(element);
IFCAnyHandle buildingElementProxy = IFCInstanceExporter.CreateBuildingElementProxy(file, guid,
ownerHistory, objectType, null, objectType, localPlacement, representation, elementTag, Toolkit.IFCElementComposition.Element);
productWrapper.AddElement(buildingElementProxy, placementSetter.GetLevelInfo(), ecData, LevelUtil.AssociateElementToLevel(element));
}
tr.Commit();
return true;
}
}
}
示例9: 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;
}
}
示例10: 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;
}
}
示例11: 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;
}
}
示例12: 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.LevelId, false))
return;
ElementType elemType = element.Document.GetElement(element.GetTypeId()) as ElementType;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction transaction = new IFCTransaction(file))
{
using (PlacementSetter setter = PlacementSetter.Create(exporterIFC, element))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
IFCAnyHandle prodRep = null;
if (!exportParts)
{
ecData.SetLocalPlacement(setter.LocalPlacement);
ecData.PossibleExtrusionAxes = IFCExtrusionAxes.TryZ;
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
prodRep = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, element,
categoryId, geomElem, bodyExporterOptions, null, ecData, true);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(prodRep))
{
ecData.ClearOpenings();
return;
}
}
// We will use the category of the element to set a default value for the covering.
string defaultCoveringEnumType = null;
if (categoryId == new ElementId(BuiltInCategory.OST_Ceilings))
defaultCoveringEnumType = "CEILING";
else if (categoryId == new ElementId(BuiltInCategory.OST_Floors))
defaultCoveringEnumType = "FLOORING";
else if (categoryId == new ElementId(BuiltInCategory.OST_Roofs))
defaultCoveringEnumType = "ROOFING";
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 coveringType = IFCValidateEntry.GetValidIFCType(element, ifcEnumType, defaultCoveringEnumType);
IFCAnyHandle covering = IFCInstanceExporter.CreateCovering(file, instanceGUID, ExporterCacheManager.OwnerHistoryHandle,
instanceName, instanceDescription, instanceObjectType, setter.LocalPlacement, prodRep, instanceTag, coveringType);
if (exportParts)
{
PartExporter.ExportHostPart(exporterIFC, element, covering, productWrapper, setter, setter.LocalPlacement, null);
}
bool containInSpace = false;
IFCAnyHandle localPlacementToUse = setter.LocalPlacement;
// Ceiling containment in Space is generally required and not specific to any view
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(element, covering, setter, null, false);
// Modify the Ceiling placement to be relative to the Space that it bounds
IFCAnyHandle roomPlacement = IFCAnyHandleUtil.GetObjectPlacement(ExporterCacheManager.SpaceInfoCache.FindSpaceHandle(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);
ExporterCacheManager.SpaceInfoCache.RelateToSpace(roomlist[0], covering);
containInSpace = true;
}
}
// if not contained in Space, assign it to default containment in Level
if (!containInSpace)
productWrapper.AddElement(element, covering, setter, null, true);
if (!exportParts)
{
Ceiling ceiling = element as Ceiling;
if (ceiling != null)
{
//.........这里部分代码省略.........
示例13: ExportFabricSheet
/// <summary>
/// Exports an element as an IfcReinforcingMesh.
/// </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 ExportFabricSheet(ExporterIFC exporterIFC, FabricSheet sheet,
GeometryElement geometryElement, ProductWrapper productWrapper)
{
if (sheet == null || geometryElement == null)
return false;
Document doc = sheet.Document;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (IFCPlacementSetter placementSetter = IFCPlacementSetter.Create(exporterIFC, sheet, null, null, ExporterUtil.GetBaseLevelIdForElement(sheet)))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.SetLocalPlacement(placementSetter.GetPlacement());
ElementId categoryId = CategoryUtil.GetSafeCategoryId(sheet);
ElementId materialId = ElementId.InvalidElementId;
ParameterUtil.GetElementIdValueFromElementOrSymbol(sheet, BuiltInParameter.MATERIAL_ID_PARAM, out materialId);
double scale = exporterIFC.LinearScale;
string guid = GUIDUtil.CreateGUID(sheet);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string revitObjectType = exporterIFC.GetFamilyName();
string name = NamingUtil.GetNameOverride(sheet, revitObjectType);
string description = NamingUtil.GetDescriptionOverride(sheet, null);
string objectType = NamingUtil.GetObjectTypeOverride(sheet, revitObjectType);
IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
string elementTag = NamingUtil.CreateIFCElementId(sheet);
string steelGrade = NamingUtil.GetOverrideStringValue(sheet, "SteelGrade", null);
double? meshLength = sheet.CutOverallLength;
double? meshWidth = sheet.CutOverallWidth;
Element fabricSheetTypeElem = doc.GetElement(sheet.GetTypeId());
FabricSheetType fabricSheetType = (fabricSheetTypeElem == null) ? null : (fabricSheetTypeElem as FabricSheetType);
double longitudinalBarNominalDiameter = 0.0;
double transverseBarNominalDiameter = 0.0;
double longitudinalBarCrossSectionArea = 0.0;
double transverseBarCrossSectionArea = 0.0;
double longitudinalBarSpacing = 0.0;
double transverseBarSpacing = 0.0;
if (fabricSheetType != null)
{
Element majorFabricWireTypeElem = doc.GetElement(fabricSheetType.MajorDirectionWireType);
FabricWireType majorFabricWireType = (majorFabricWireTypeElem == null) ? null : (majorFabricWireTypeElem as FabricWireType);
if (majorFabricWireType != null)
{
longitudinalBarNominalDiameter = majorFabricWireType.WireDiameter * scale;
double localRadius = longitudinalBarNominalDiameter / 2.0;
longitudinalBarCrossSectionArea = localRadius * localRadius * Math.PI;
}
Element minorFabricWireTypeElem = doc.GetElement(fabricSheetType.MinorDirectionWireType);
FabricWireType minorFabricWireType = (minorFabricWireTypeElem == null) ? null : (minorFabricWireTypeElem as FabricWireType);
if (minorFabricWireType != null)
{
transverseBarNominalDiameter = minorFabricWireType.WireDiameter * scale;
double localRadius = transverseBarNominalDiameter / 2.0;
transverseBarCrossSectionArea = localRadius * localRadius * Math.PI;
}
longitudinalBarSpacing = fabricSheetType.MajorSpacing * scale;
transverseBarSpacing = fabricSheetType.MinorSpacing * scale;
}
IList<IFCAnyHandle> bodyItems = new List<IFCAnyHandle>();
IList<Curve> wireCenterlines = sheet.GetWireCenterlines(WireDistributionDirection.Major);
foreach (Curve wireCenterline in wireCenterlines)
{
IFCAnyHandle bodyItem = CreateSweptDiskSolid(exporterIFC, file, wireCenterline, longitudinalBarNominalDiameter);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(bodyItem))
bodyItems.Add(bodyItem);
}
wireCenterlines = sheet.GetWireCenterlines(WireDistributionDirection.Minor);
foreach (Curve wireCenterline in wireCenterlines)
{
IFCAnyHandle bodyItem = CreateSweptDiskSolid(exporterIFC, file, wireCenterline, transverseBarNominalDiameter);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(bodyItem))
bodyItems.Add(bodyItem);
}
IFCAnyHandle shapeRep = (bodyItems.Count > 0) ?
RepresentationUtil.CreateAdvancedSweptSolidRep(exporterIFC, sheet, categoryId, exporterIFC.Get3DContextHandle("Body"), bodyItems, null) :
null;
IList<IFCAnyHandle> shapeReps = null;
//.........这里部分代码省略.........
示例14: 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);
//.........这里部分代码省略.........
示例15: ExportRailing
//.........这里部分代码省略.........
GeometryElement subElementGeom = GeometryUtil.GetOneLevelGeometryElement(subElement.get_Geometry(geomOptions));
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;
IFCAnyHandle boundingBoxRep = BoundingBoxExporter.ExportBoundingBox(exporterIFC, geomObjects, boundingBoxTrf);
if (boundingBoxRep != null)
representations.Add(boundingBoxRep);
IFCAnyHandle prodRep = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, representations);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
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));
Toolkit.IFCRailingType railingType = GetIFCRailingType(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();
}
}
}