Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RVT24 Customized IFC Export for Rebar Grouping #701

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 33 additions & 25 deletions Source/Revit.IFC.Export/Exporter/RebarExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,13 @@ private static ISet<DelayedProductWrapper> ExportRebar(ExporterIFC exporterIFC,
return null;

ElementId materialId = ElementId.InvalidElementId;
ParameterUtil.GetElementIdValueFromElementOrSymbol(rebarElement, BuiltInParameter.MATERIAL_ID_PARAM, out materialId);
Element type = rebarElement.Document.GetElement(rebarElement.GetTypeId());
Parameter specialRebarMaterialParameter = type.LookupParameter("IfcMaterialRebar");

if (specialRebarMaterialParameter != null && specialRebarMaterialParameter.HasValue && specialRebarMaterialParameter.StorageType == StorageType.ElementId && specialRebarMaterialParameter.AsElementId() != null)
materialId = specialRebarMaterialParameter.AsElementId();
else
ParameterUtil.GetElementIdValueFromElementOrSymbol(rebarElement, BuiltInParameter.MATERIAL_ID_PARAM, out materialId);

double longitudinalBarNominalDiameter = 0.0, modelDiameter = 0.0;
GetBarDiameters(rebarItem, out longitudinalBarNominalDiameter, out modelDiameter);
Expand Down Expand Up @@ -477,6 +483,8 @@ private static ISet<DelayedProductWrapper> ExportRebar(ExporterIFC exporterIFC,

ElementId barLengthParamId = new ElementId(BuiltInParameter.REBAR_ELEM_LENGTH);
ParameterSet rebarElementParams = rebarElement.Parameters;
int indexForNamingAndGUID = itemIndex;
HashSet<IFCAnyHandle> bodyItems = new HashSet<IFCAnyHandle>();
for (int ii = 0; ii < numberOfBarPositions; ii++)
{
if (!DoesBarExistAtPosition(rebarItem, ii))
Expand Down Expand Up @@ -506,8 +514,6 @@ private static ISet<DelayedProductWrapper> ExportRebar(ExporterIFC exporterIFC,
}
}

int indexForNamingAndGUID = ii + itemIndex;

string rebarName = NamingUtil.GetNameOverride(rebarElement, rebarNameFormated + ": " + indexForNamingAndGUID);

Transform barTrf = GetBarPositionTransform(rebarItem, ii);
Expand Down Expand Up @@ -539,50 +545,52 @@ private static ISet<DelayedProductWrapper> ExportRebar(ExporterIFC exporterIFC,
Curve curve = ApplyNonConformalTransformIfPossible(baseCurve, barTrf);
if (curve == null)
throw new InvalidOperationException("Couldn't transform rebar curve.");

curves.Add(curve);
}
}

// For IFC4 and Structural Exchange Requirement export, Entity type not allowed for RV: IfcPolyline
IFCAnyHandle compositeCurve = GeometryUtil.CreateCompositeOrIndexedCurve(exporterIFC, curves, null, null);
IFCAnyHandle sweptDiskSolid = IFCInstanceExporter.CreateSweptDiskSolid(file, compositeCurve, modelDiameter / 2, null, 0, endParam);
HashSet<IFCAnyHandle> bodyItems = new HashSet<IFCAnyHandle>() { sweptDiskSolid };
bodyItems.Add(sweptDiskSolid);
RepresentationUtil.CreateStyledItemAndAssign(file, rebarElement.Document, materialId, sweptDiskSolid);

}
IFCAnyHandle contextOfItems = ExporterCacheManager.Get3DContextHandle(IFCRepresentationIdentifier.Body);
IFCAnyHandle shapeRep = RepresentationUtil.CreateAdvancedSweptSolidRep(exporterIFC,
IFCAnyHandle shapeRep = RepresentationUtil.CreateAdvancedSweptSolidRep(exporterIFC,
rebarElement, categoryId, contextOfItems, bodyItems, null);
IList<IFCAnyHandle> shapeReps = new List<IFCAnyHandle>() { shapeRep };
prodRep = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, shapeReps);

IFCAnyHandle copyLevelPlacement = (ii == 0) ? originalPlacement : ExporterUtil.CopyLocalPlacement(file, originalPlacement);

string rebarGUID = (indexForNamingAndGUID < maxBarGUIDS) ?
//IFCAnyHandle copyLevelPlacement = (ii == 0) ? originalPlacement : ExporterUtil.CopyLocalPlacement(file, originalPlacement);
IFCAnyHandle copyLevelPlacement = originalPlacement;

string rebarGUID = (indexForNamingAndGUID < maxBarGUIDS) ?
GUIDUtil.CreateSubElementGUID(rebarElement, indexForNamingAndGUID + (int)IFCReinforcingBarSubElements.BarStart - 1) :
GUIDUtil.GenerateIFCGuidFrom(
GUIDUtil.CreateGUIDString(rebarElement, indexForNamingAndGUID.ToString()));
IFCAnyHandle elemHnd = IFCInstanceExporter.CreateReinforcingBar(exporterIFC, rebarElement, rebarGUID, ExporterCacheManager.OwnerHistoryHandle,
copyLevelPlacement, prodRep, steelGrade, longitudinalBarNominalDiameter, longitudinalBarCrossSectionArea, barLength, role, null);
IFCAnyHandleUtil.OverrideNameAttribute(elemHnd, rebarName);
IFCExportInfoPair exportInfo = new IFCExportInfoPair(IFCEntityType.IfcReinforcingBar);
IFCAnyHandle elemHnd = IFCInstanceExporter.CreateReinforcingBar(exporterIFC, rebarElement, rebarGUID, ExporterCacheManager.OwnerHistoryHandle,
copyLevelPlacement, prodRep, steelGrade, longitudinalBarNominalDiameter, longitudinalBarCrossSectionArea, barLength, role, null);
IFCAnyHandleUtil.OverrideNameAttribute(elemHnd, origRebarName);
IFCExportInfoPair exportInfo = new IFCExportInfoPair(IFCEntityType.IfcReinforcingBar);

// We will not add the element to the productWrapper here, but instead in the function that calls
// ExportRebar. The reason for this is that we don't currently know if the handles such be associated
// to the level or not, depending on whether they will or won't be grouped.
createdRebars.Add(new DelayedProductWrapper(rebarElement, elemHnd, setter.LevelInfo, exportInfo));
// We will not add the element to the productWrapper here, but instead in the function that calls
// ExportRebar. The reason for this is that we don't currently know if the handles such be associated
// to the level or not, depending on whether they will or won't be grouped.
createdRebars.Add(new DelayedProductWrapper(rebarElement, elemHnd, setter.LevelInfo, exportInfo));

CacheSubelementParameterValues(rebarElement, rebarElementParams, ii, elemHnd);
//CacheSubelementParameterValues(rebarElement, rebarElementParams, ii, elemHnd);

ExporterCacheManager.HandleToElementCache.Register(elemHnd, rebarElement.Id);
CategoryUtil.CreateMaterialAssociation(exporterIFC, elemHnd, materialId);
ExporterCacheManager.HandleToElementCache.Register(elemHnd, rebarElement.Id);
CategoryUtil.CreateMaterialAssociation(exporterIFC, elemHnd, materialId);

IFCAnyHandle typeHnd = ExporterUtil.CreateGenericTypeFromElement(rebarElement,
exportInfo, file, productWrapper);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(typeHnd))
{
ExporterCacheManager.TypeRelationsCache.Add(typeHnd, elemHnd);
}
IFCAnyHandle typeHnd = ExporterUtil.CreateGenericTypeFromElement(rebarElement,
exportInfo, file, productWrapper);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(typeHnd))
{
ExporterCacheManager.TypeRelationsCache.Add(typeHnd, elemHnd);
}
}
transaction.Commit();
Expand Down