本文整理汇总了C#中IFCTransaction类的典型用法代码示例。如果您正苦于以下问题:C# IFCTransaction类的具体用法?C# IFCTransaction怎么用?C# IFCTransaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IFCTransaction类属于命名空间,在下文中一共展示了IFCTransaction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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;
}
}
开发者ID:whztt07,项目名称:BIM-IFC,代码行数:43,代码来源:AssemblyInstanceExporter.cs
示例2: 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;
}
}
开发者ID:whztt07,项目名称:RevitIFC,代码行数:42,代码来源:FabricSheetExporter.cs
示例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();
}
}
}
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:63,代码来源:RebarExporter.cs
示例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;
}
}
开发者ID:whztt07,项目名称:RevitIFC,代码行数:60,代码来源:DuctLiningExporter.cs
示例5: 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;
}
}
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:58,代码来源:DuctLiningExporter.cs
示例6: 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;
}
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:61,代码来源:ProxyElementExporter.cs
示例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 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;
}
}
}
开发者ID:whztt07,项目名称:BIM-IFC,代码行数:56,代码来源:ProxyElementExporter.cs
示例8: 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;
}
}
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:49,代码来源:ZoneExporter.cs
示例9: Export
/// <summary>
/// Exports an element as building element proxy.
/// </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 Export(ExporterIFC exporterIFC, Element element,
GeometryElement geometryElement, ProductWrapper productWrapper)
{
bool exported = false;
if (element == null || geometryElement == null)
return exported;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
exported = ExportBuildingElementProxy(exporterIFC, element, geometryElement, productWrapper);
if (exported)
{
PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, element, productWrapper);
tr.Commit();
}
}
return exported;
}
开发者ID:stiter,项目名称:ifcexporter,代码行数:29,代码来源:ProxyElementExporter.cs
示例10: Export
/// <summary>
/// Exports a staircase to IfcStair.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The stairs element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
public static void Export(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement, ProductWrapper productWrapper)
{
string ifcEnumType = CategoryUtil.GetIFCEnumTypeName(exporterIFC, element);
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
if (element is Stairs)
{
Stairs stair = element as Stairs;
int numFlights = stair.NumberOfStories;
if (numFlights > 0)
{
ExportStairsAsContainer(exporterIFC, ifcEnumType, stair, geometryElement, numFlights, productWrapper);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(productWrapper.GetAnElement()))
ExportStairAsSingleGeometry(exporterIFC, ifcEnumType, element, geometryElement, numFlights, productWrapper);
}
}
else if (IsLegacyStairs(element))
{
ExportLegacyStairOrRampAsContainer(exporterIFC, ifcEnumType, element, geometryElement, true, productWrapper);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(productWrapper.GetAnElement()))
{
double defaultHeight = GetDefaultHeightForLegacyStair(exporterIFC.LinearScale);
int numFlights = GetNumFlightsForLegacyStair(exporterIFC, element, defaultHeight);
if (numFlights > 0)
ExportStairAsSingleGeometry(exporterIFC, ifcEnumType, element, geometryElement, numFlights, productWrapper);
}
}
else
{
ExportStairAsSingleGeometry(exporterIFC, ifcEnumType, element, geometryElement, 1, productWrapper);
}
PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, element, productWrapper);
tr.Commit();
}
}
开发者ID:stiter,项目名称:ifcexporter,代码行数:45,代码来源:StairsExporter.cs
示例11: 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;
}
}
开发者ID:whztt07,项目名称:RevitIFC,代码行数:43,代码来源:AreaSchemeExporter.cs
示例12: 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;
}
}
开发者ID:whztt07,项目名称:RevitIFC,代码行数:43,代码来源:GroupExporter.cs
示例13: ExportElementClassifications
private static void ExportElementClassifications(ExporterIFC exporterIFC, Element element, ProductWrapper productWrapper)
{
if (productWrapper.IsEmpty())
return;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction transaction = new IFCTransaction(file))
{
ICollection<IFCAnyHandle> productSet = productWrapper.GetAllObjects();
foreach (IFCAnyHandle prodHnd in productSet)
{
// No need to check the subtype since Classification can be assigned to IfcRoot
// if (IFCAnyHandleUtil.IsSubTypeOf(prodHnd, IFCEntityType.IfcElement))
ClassificationUtil.CreateClassification(exporterIFC, file, element, prodHnd);
}
transaction.Commit();
}
}
开发者ID:whztt07,项目名称:RevitIFC,代码行数:18,代码来源:ExporterUtil.cs
示例14: ExportElementQuantities
/// <summary>
/// Exports the IFC element quantities.
/// </summary>
/// <param name="exporterIFC">The IFC exporter object.</param>
/// <param name="element ">The element whose quantities are exported.</param>
/// <param name="productWrapper">The ProductWrapper object.</param>
private static void ExportElementQuantities(ExporterIFC exporterIFC, Element element, ProductWrapper productWrapper)
{
if (productWrapper.IsEmpty())
return;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction transaction = new IFCTransaction(file))
{
Document doc = element.Document;
ElementType elemType = doc.GetElement(element.GetTypeId()) as ElementType;
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
ICollection<IFCAnyHandle> productSet = productWrapper.GetAllObjects();
IList<IList<QuantityDescription>> quantitiesToCreate = ExporterCacheManager.ParameterCache.Quantities;
foreach (IList<QuantityDescription> currStandard in quantitiesToCreate)
{
foreach (QuantityDescription currDesc in currStandard)
{
foreach (IFCAnyHandle prodHnd in productSet)
{
if (currDesc.IsAppropriateType(prodHnd))
{
IFCExtrusionCreationData ifcParams = productWrapper.FindExtrusionCreationParameters(prodHnd);
HashSet<IFCAnyHandle> quantities = currDesc.ProcessEntries(file, exporterIFC, ifcParams, element, elemType);
if (quantities.Count > 0)
{
string paramSetName = currDesc.Name;
string methodName = currDesc.MethodOfMeasurement;
IFCAnyHandle propertySet = IFCInstanceExporter.CreateElementQuantity(file, GUIDUtil.CreateGUID(), ownerHistory, paramSetName, methodName, null, quantities);
IFCAnyHandle prodHndToUse = prodHnd;
DescriptionCalculator ifcRDC = currDesc.DescriptionCalculator;
if (ifcRDC != null)
{
IFCAnyHandle overrideHnd = ifcRDC.RedirectDescription(exporterIFC, element);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(overrideHnd))
prodHndToUse = overrideHnd;
}
HashSet<IFCAnyHandle> relatedObjects = new HashSet<IFCAnyHandle>();
relatedObjects.Add(prodHndToUse);
IFCInstanceExporter.CreateRelDefinesByProperties(file, GUIDUtil.CreateGUID(), ownerHistory, null, null, relatedObjects, propertySet);
}
}
}
}
}
transaction.Commit();
}
}
开发者ID:whztt07,项目名称:RevitIFC,代码行数:60,代码来源:ExporterUtil.cs
示例15: ExportElementProperties
/// <summary>
/// Exports the element properties.
/// </summary>
/// <param name="exporterIFC">The IFC exporter object.</param>
/// <param name="element">The element whose properties are exported.</param>
/// <param name="productWrapper">The ProductWrapper object.</param>
private static void ExportElementProperties(ExporterIFC exporterIFC, Element element, ProductWrapper productWrapper)
{
if (productWrapper.IsEmpty())
return;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction transaction = new IFCTransaction(file))
{
Document doc = element.Document;
ElementType elemType = doc.GetElement(element.GetTypeId()) as ElementType;
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
ICollection<IFCAnyHandle> productSet = productWrapper.GetAllObjects();
IList<IList<PropertySetDescription>> psetsToCreate = ExporterCacheManager.ParameterCache.PropertySets;
// In some cases, like multi-story stairs and ramps, we may have the same Pset used for multiple levels.
// If ifcParams is null, re-use the property set.
ISet<string> locallyUsedGUIDs = new HashSet<string>();
IDictionary<Tuple<Element, Element, string>, IFCAnyHandle> createdPropertySets =
new Dictionary<Tuple<Element, Element, string>, IFCAnyHandle>();
IDictionary<IFCAnyHandle, HashSet<IFCAnyHandle>> relDefinesByPropertiesMap =
new Dictionary<IFCAnyHandle, HashSet<IFCAnyHandle>>();
foreach (IFCAnyHandle prodHnd in productSet)
{
IList<PropertySetDescription> currPsetsToCreate = GetCurrPSetsToCreate(prodHnd, psetsToCreate);
if (currPsetsToCreate.Count == 0)
continue;
ElementId overrideElementId = ExporterCacheManager.HandleToElementCache.Find(prodHnd);
Element elementToUse = (overrideElementId == ElementId.InvalidElementId) ? element : doc.GetElement(overrideElementId);
ElementType elemTypeToUse = (overrideElementId == ElementId.InvalidElementId) ? elemType : doc.GetElement(elementToUse.GetTypeId()) as ElementType;
if (elemTypeToUse == null)
elemTypeToUse = elemType;
IFCExtrusionCreationData ifcParams = productWrapper.FindExtrusionCreationParameters(prodHnd);
foreach (PropertySetDescription currDesc in currPsetsToCreate)
{
// Last conditional check: if the property set comes from a ViewSchedule, check if the element is in the schedule.
if (currDesc.ViewScheduleId != ElementId.InvalidElementId)
if (!ExporterCacheManager.ViewScheduleElementCache[currDesc.ViewScheduleId].Contains(elementToUse.Id))
continue;
Tuple<Element, Element, string> propertySetKey = new Tuple<Element, Element, string>(elementToUse, elemTypeToUse, currDesc.Name);
IFCAnyHandle propertySet = null;
if ((ifcParams != null) || (!createdPropertySets.TryGetValue(propertySetKey, out propertySet)))
{
HashSet<IFCAnyHandle> props = currDesc.ProcessEntries(file, exporterIFC, ifcParams, elementToUse, elemTypeToUse);
if (props.Count > 0)
{
int subElementIndex = CheckElementTypeValidityForSubIndex(currDesc, prodHnd, element);
string guid = GUIDUtil.CreateSubElementGUID(elementToUse, subElementIndex);
if (locallyUsedGUIDs.Contains(guid))
guid = GUIDUtil.CreateGUID();
else
locallyUsedGUIDs.Add(guid);
string paramSetName = currDesc.Name;
propertySet = IFCInstanceExporter.CreatePropertySet(file, guid, ownerHistory, paramSetName, null, props);
if (ifcParams == null)
createdPropertySets[propertySetKey] = propertySet;
}
}
if (propertySet != null)
{
IFCAnyHandle prodHndToUse = prodHnd;
DescriptionCalculator ifcRDC = currDesc.DescriptionCalculator;
if (ifcRDC != null)
{
IFCAnyHandle overrideHnd = ifcRDC.RedirectDescription(exporterIFC, elementToUse);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(overrideHnd))
prodHndToUse = overrideHnd;
}
HashSet<IFCAnyHandle> relatedObjects = null;
if (!relDefinesByPropertiesMap.TryGetValue(propertySet, out relatedObjects))
{
relatedObjects = new HashSet<IFCAnyHandle>();
relDefinesByPropertiesMap[propertySet] = relatedObjects;
}
relatedObjects.Add(prodHndToUse);
}
}
}
foreach (KeyValuePair<IFCAnyHandle, HashSet<IFCAnyHandle>> relDefinesByProperties in relDefinesByPropertiesMap)
{
IFCInstanceExporter.CreateRelDefinesByProperties(file, GUIDUtil.CreateGUID(), ownerHistory, null, null,
relDefinesByProperties.Value, relDefinesByProperties.Key);
//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:RevitIFC,代码行数:101,代码来源:ExporterUtil.cs
示例16: ExportPsetDraughtingFor2x2
/// <summary>
/// Exports Pset_Draughting for IFC 2x2 standard.
/// </summary>
/// <param name="exporterIFC">The IFC exporter object.</param>
/// <param name="element ">The element whose properties are exported.</param>
/// <param name="productWrapper">The ProductWrapper object.</param>
private static void ExportPsetDraughtingFor2x2(ExporterIFC exporterIFC, El
|
请发表评论