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

Initial code update for IFC Extension 24.2 #687

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Initial code update for IFC Extension 24.2
  • Loading branch information
o-babii committed Sep 28, 2023
commit a35745ee3b4c05992e4f5b7e977320a5e8c052d8
87 changes: 84 additions & 3 deletions Source/IFCExporterUIOverride/Properties/Resources.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@
<value>Neue Export Einstellungen</value>
</data>
<data name="DeleteSelectedSetup" xml:space="preserve">
<value>Löschen</value>
<value>Ausgewählte Einstellung löschen.</value>
</data>
<data name="Next" xml:space="preserve">
<value>Weiter…</value>
Expand Down Expand Up @@ -640,7 +640,7 @@
<value>IFC4 Reference View</value>
</data>
<data name="Help" xml:space="preserve">
<value>Wie gebe ich eine Export Einstellungen an</value>
<value>Wie gebe ich eine Export Einstellungen an?</value>
</data>
<data name="ExportSpecificSchedules" xml:space="preserve">
<value>Nur Bauteillisten mit IFC, Pset oder Allgemein im Titel exportieren</value>
Expand Down Expand Up @@ -730,7 +730,7 @@
<value>Anforderung für Austausch</value>
</data>
<data name="ExportSelectedSetup" xml:space="preserve">
<value>Aktuelle Einstellungen speichern</value>
<value>Aktuelle Einstellungen speichern ...</value>
</data>
<data name="InternalCoordinates" xml:space="preserve">
<value>Interne Koordinaten</value>
Expand Down Expand Up @@ -795,4 +795,85 @@
<data name="ER_StructuralShort" xml:space="preserve">
<value>Structural</value>
</data>
<data name="GeoReference" xml:space="preserve">
<value>Geografische Referenz</value>
</data>
<data name="HelpAssignIfcEntity" xml:space="preserve">
<value>Wie kann ich die IFC-Klasse und den vordefinierten Typ zuordnen?</value>
</data>
<data name="ExpandAll" xml:space="preserve">
<value>Alle ausklappen</value>
</data>
<data name="ExcludeEntitySelection" xml:space="preserve">
<value>Zu exportierende IFC-Klassen ...</value>
</data>
<data name="Elevation" xml:space="preserve">
<value>Höhe</value>
</data>
<data name="Eastings" xml:space="preserve">
<value>Rechtswert</value>
</data>
<data name="Northings" xml:space="preserve">
<value>Hochwert</value>
</data>
<data name="AngleTrueNorth" xml:space="preserve">
<value>Winkel vom geografischen Norden</value>
</data>
<data name="CollapseAll" xml:space="preserve">
<value>Alle zusammenklappen</value>
</data>
<data name="DeleteOldConfiguration" xml:space="preserve">
<value>Alte Konfiguration löschen</value>
</data>
<data name="GeodeticDatum" xml:space="preserve">
<value>Geodätisches Datum</value>
</data>
<data name="HelpSelectEntityForExport" xml:space="preserve">
<value>Wie wirken sich die Auswahl der zu exportierenden IFC-Klassen auf den Export?</value>
</data>
<data name="IFCSchemaVersion" xml:space="preserve">
<value>IFC Schema Version</value>
</data>
<data name="InternalCoordinatesInTN" xml:space="preserve">
<value>Interne Koordinaten an den geografischen Norden orientiert</value>
</data>
<data name="MultipleAssignments" xml:space="preserve">
<value>Mehrfache Zuweisung wurde bei den ausgewählten Objekten gefunden !</value>
</data>
<data name="NoPredefinedType" xml:space="preserve">
<value>IFC-Klasse besitzt keinen vordefinierten Typ</value>
</data>
<data name="Override" xml:space="preserve">
<value>Überschreiben</value>
</data>
<data name="PredefinedTypeSelection" xml:space="preserve">
<value>Auswahl des vordefinierten Typs</value>
</data>
<data name="ProjectedCRSDesc" xml:space="preserve">
<value>Beschreibung</value>
</data>
<data name="ProjectInTN" xml:space="preserve">
<value>Projektbasispunkt an den geografischen Norden orientiert</value>
</data>
<data name="ProjectSite" xml:space="preserve">
<value>Vermessungspunkt</value>
</data>
<data name="UseTypeNameOnlyForIfcType" xml:space="preserve">
<value>Den Typnamen nur für IFC-Typnamen verwenden</value>
</data>
<data name="UseVisibleRevitNameAsEntityName" xml:space="preserve">
<value>Sichtbaren Namen in Revit als IFC-Entitätsname verwenden</value>
</data>
<data name="Search" xml:space="preserve">
<value>Suchen</value>
</data>
<data name="SaveConfigurationChanges" xml:space="preserve">
<value>Änderungen in die IFC-Exporteinrichtung speichern</value>
</data>
<data name="SaveChanges" xml:space="preserve">
<value>Änderungen speichern</value>
</data>
<data name="ResetToOriginals" xml:space="preserve">
<value>Zurücksetzen</value>
</data>
</root>
81 changes: 81 additions & 0 deletions Source/IFCExporterUIOverride/Properties/Resources.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -799,4 +799,85 @@
<data name="ER_StructuralShort" xml:space="preserve">
<value>Structural</value>
</data>
<data name="AngleTrueNorth" xml:space="preserve">
<value>Angle depuis le nord géographique</value>
</data>
<data name="CollapseAll" xml:space="preserve">
<value>Tout refermer</value>
</data>
<data name="DeleteOldConfiguration" xml:space="preserve">
<value>Supprimer l'ancienne configuration</value>
</data>
<data name="Eastings" xml:space="preserve">
<value>Coordonnées Est</value>
</data>
<data name="Elevation" xml:space="preserve">
<value>Façade</value>
</data>
<data name="ExcludeEntitySelection" xml:space="preserve">
<value>Entités à exporter...</value>
</data>
<data name="ExpandAll" xml:space="preserve">
<value>Tout déployer</value>
</data>
<data name="GeodeticDatum" xml:space="preserve">
<value>Données géodésiques</value>
</data>
<data name="GeoReference" xml:space="preserve">
<value>Référence géographique</value>
</data>
<data name="HelpAssignIfcEntity" xml:space="preserve">
<value>Comment attribuer une entité IFC et un type prédéfini ?</value>
</data>
<data name="HelpSelectEntityForExport" xml:space="preserve">
<value>Comment les sélections d’entités IFC affectent-elles l’export ?</value>
</data>
<data name="IFCSchemaVersion" xml:space="preserve">
<value>Version du schéma IFC</value>
</data>
<data name="InternalCoordinatesInTN" xml:space="preserve">
<value>Origine interne orientée vers le nord géographique</value>
</data>
<data name="MultipleAssignments" xml:space="preserve">
<value>Affectations multiples trouvées dans les objets sélectionnés.</value>
</data>
<data name="NoPredefinedType" xml:space="preserve">
<value>L'entité n'a pas de type prédéfini</value>
</data>
<data name="Northings" xml:space="preserve">
<value>Coordonnées Nord</value>
</data>
<data name="Override" xml:space="preserve">
<value>Ecraser</value>
</data>
<data name="PredefinedTypeSelection" xml:space="preserve">
<value>Sélection du type prédéfini</value>
</data>
<data name="ProjectedCRSDesc" xml:space="preserve">
<value>Description</value>
</data>
<data name="ProjectInTN" xml:space="preserve">
<value>Point de base du projet orienté vers le nord géographique</value>
</data>
<data name="ProjectSite" xml:space="preserve">
<value>Site du projet</value>
</data>
<data name="ResetToOriginals" xml:space="preserve">
<value>Réinitialiser</value>
</data>
<data name="SaveChanges" xml:space="preserve">
<value>Sauvegarder les modifications</value>
</data>
<data name="SaveConfigurationChanges" xml:space="preserve">
<value>Enregistrer les modifications apportées à la configuration de l'export IFC</value>
</data>
<data name="Search" xml:space="preserve">
<value>Recherche</value>
</data>
<data name="UseTypeNameOnlyForIfcType" xml:space="preserve">
<value>Utiliser le nom du type uniquement pour le nom du type IFC</value>
</data>
<data name="UseVisibleRevitNameAsEntityName" xml:space="preserve">
<value>Utiliser le nom Revit visible comme nom de l'IFCEntity</value>
</data>
</root>
11 changes: 7 additions & 4 deletions Source/Revit.IFC.Export/Exporter/BodyData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public BodyData(BodyData bodyData)
ShapeRepresentationType = bodyData.ShapeRepresentationType;
OffsetTransform = bodyData.OffsetTransform;
MaterialIds = bodyData.MaterialIds;
RepresentationItemInfo = bodyData.RepresentationItemInfo;
}

/// <summary>
Expand Down Expand Up @@ -185,14 +186,16 @@ public MaterialAndProfile materialAndProfile
}

/// <summary>
/// Static function to create a new copy of BodyData but resetting the MaterialIds
/// Static function to create a new copy of BodyData
/// </summary>
/// <param name="bodyDataIn">the input BodyData</param>
/// <returns>the new copy of BodyData with cleared MaterialIds</returns>
public static BodyData Create(BodyData bodyDataIn)
/// <param name="resetMaterials">indicates whether we want to clear the MaterialIds </param>
/// <returns>the new copy of BodyData</returns>
public static BodyData Create(BodyData bodyDataIn, bool resetMaterials)
{
BodyData retBodyData = new BodyData(bodyDataIn); // create a new copy of bodyDataIn
retBodyData.MaterialIds.Clear(); // Clear the MaterialIdsList
if (resetMaterials)
retBodyData.MaterialIds.Clear();
return retBodyData;
}
}
Expand Down
45 changes: 24 additions & 21 deletions Source/Revit.IFC.Export/Exporter/BodyExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
using System.Linq;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.IFC;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.DB.Plumbing;
using Revit.IFC.Export.Properties;
using Revit.IFC.Export.Toolkit;
using Revit.IFC.Export.Utility;
Expand Down Expand Up @@ -675,7 +673,7 @@ public static bool CanCreateClosedShell(ICollection<IFCAnyHandle> faceSet)
// This is a simplified routine for solids that are composed of planar faces with polygonal edges. This
// allows us to use the edges as the boundaries of the faces.
private static bool ExportPlanarBodyIfPossible(ExporterIFC exporterIFC, Solid solid,
IList<HashSet<IFCAnyHandle>> currentFaceHashSetList)
IList<HashSet<IFCAnyHandle>> currentFaceHashSetList, Transform lcs)
{
IFCFile file = exporterIFC.GetFile();

Expand Down Expand Up @@ -717,7 +715,7 @@ private static bool ExportPlanarBodyIfPossible(ExporterIFC exporterIFC, Solid so
{
if (!vertexCache.TryGetValue(curvePoints[idx], out IFCAnyHandle pointHandle))
{
XYZ pointScaled = ExporterIFCUtils.TransformAndScalePoint(exporterIFC, curvePoints[idx]);
XYZ pointScaled = TransformAndScalePoint(exporterIFC, curvePoints[idx], lcs);
pointHandle = ExporterUtil.CreateCartesianPoint(file, pointScaled);
vertexCache[curvePoints[idx]] = pointHandle;
}
Expand Down Expand Up @@ -2553,15 +2551,15 @@ private static bool AreTessellationControlsEqual(SolidOrShellTessellationControl
}

private static bool ExportBodyAsSolid(ExporterIFC exporterIFC, Element element, BodyExporterOptions options,
IList<HashSet<IFCAnyHandle>> currentFaceHashSetList, GeometryObject geomObject)
IList<HashSet<IFCAnyHandle>> currentFaceHashSetList, GeometryObject geomObject, Transform lcs)
{
IFCFile file = exporterIFC.GetFile();
Document document = element.Document;
if (!(geomObject is Solid))
return false;

Solid solid = geomObject as Solid;
if (ExportPlanarBodyIfPossible(exporterIFC, solid, currentFaceHashSetList))
if (ExportPlanarBodyIfPossible(exporterIFC, solid, currentFaceHashSetList, lcs))
return true;

SolidOrShellTessellationControls tessellationControlsOriginal = options.TessellationControls;
Expand Down Expand Up @@ -2643,7 +2641,7 @@ private static bool ExportBodyAsSolid(ExporterIFC exporterIFC, Element element,
for (int ii = 0; ii < numberOfVertices; ii++)
{
XYZ vertex = component.GetVertex(ii);
XYZ vertexScaled = ExporterIFCUtils.TransformAndScalePoint(exporterIFC, vertex);
XYZ vertexScaled = TransformAndScalePoint(exporterIFC, vertex, lcs);
coordList.Add(new List<double>(3) { vertexScaled.X, vertexScaled.Y, vertexScaled.Z });
}
}
Expand All @@ -2653,7 +2651,7 @@ private static bool ExportBodyAsSolid(ExporterIFC exporterIFC, Element element,
for (int ii = 0; ii < numberOfVertices; ii++)
{
XYZ vertex = component.GetVertex(ii);
XYZ vertexScaled = ExporterIFCUtils.TransformAndScalePoint(exporterIFC, vertex);
XYZ vertexScaled = TransformAndScalePoint(exporterIFC, vertex, lcs);
IFCAnyHandle vertexHandle = ExporterUtil.CreateCartesianPoint(file, vertexScaled);
vertexHandles.Add(vertexHandle);
}
Expand All @@ -2677,6 +2675,11 @@ private static bool ExportBodyAsSolid(ExporterIFC exporterIFC, Element element,
}
}
currentFaceHashSetList.Add(currentFaceSet);

// Call GC.KeepAlive(solidFacetation) at this point to maintain a reference to solidFacetation
// and prevent the object deletion by the garbage collector after try-catch block.
GC.KeepAlive(solidFacetation);

return true;
}

Expand All @@ -2692,16 +2695,15 @@ private static BodyData ExportBodyAsBRep(ExporterIFC exporterIFC, IList<Geometry
IFCFile file = exporterIFC.GetFile();
Document document = element.Document;

// Can't use the optimization functions below if we already have partially populated our body items with extrusions.
// Can't resetMaterials if we already have partially populated our body items with extrusions (canExportSolidModelRep)
int numExtrusions = bodyItems.Count;

bool resetMaterials = (numExtrusions == 0);
IList<HashSet<IFCAnyHandle>> currentFaceHashSetList = new List<HashSet<IFCAnyHandle>>();
IList<int> startIndexForObject = new List<int>();

BodyData bodyData = BodyData.Create(bodyDataIn);
BodyData bodyData = BodyData.Create(bodyDataIn, resetMaterials);

IList<ElementId> materialIds = new List<ElementId>();
bodyData.MaterialIds = materialIds;

bool isCoarse = (options.TessellationLevel == BodyExporterOptions.BodyTessellationLevel.Coarse);

Expand All @@ -2718,7 +2720,7 @@ private static BodyData ExportBodyAsBRep(ExporterIFC exporterIFC, IList<Geometry
int brepIndex = selectiveBRepExport ? exportAsBRep[index].Key : index;
SimpleSweptSolidAnalyzer currAnalyzer = selectiveBRepExport ? exportAsBRep[index].Value : null;

GeometryObject geomObject = selectiveBRepExport ? splitGeometryList[brepIndex] : splitGeometryList[index];
GeometryObject geomObject = splitGeometryList[brepIndex];

// A simple test to see if the geometry is a valid solid. This will save a lot of time in CanCreateClosedShell later.
if (exportAsBReps && (geomObject is Solid))
Expand All @@ -2743,6 +2745,7 @@ private static BodyData ExportBodyAsBRep(ExporterIFC exporterIFC, IList<Geometry

ElementId materialId = SetBestMaterialIdInExporter(geomObject, element, overrideMaterialId, exporterIFC);
materialIds.Add(materialId);
bodyData.AddMaterial(materialId);

bool alreadyExported = false;

Expand Down Expand Up @@ -2775,18 +2778,18 @@ private static BodyData ExportBodyAsBRep(ExporterIFC exporterIFC, IList<Geometry
}
}

// When geometry from symbol is used and the object is part of the Assembly, the transform needs to be Identity matrix
Transform trfToUse = null;
if (instanceGeometry)
trfToUse = GeometryUtil.GetScaledTransform(exporterIFC);
else if (!instanceGeometry && element.AssemblyInstanceId != ElementId.InvalidElementId)
trfToUse = Transform.Identity;

// If we are using the Reference View, try a triangulated face set.
// In theory, we could export a tessellated face set for geometry in the Design Transfer View that failed above.
// However, FacetedBReps do hold more information (and aren't only triangles).
if (!alreadyExported && canExportAsTessellatedFaceSet)
{
// When geometry from symbol is used and the object is part of the Assembly, the transform needs to be Identity matrix
Transform trfToUse = null;
if (instanceGeometry)
trfToUse = GeometryUtil.GetScaledTransform(exporterIFC);
else if (!instanceGeometry && element.AssemblyInstanceId != ElementId.InvalidElementId)
trfToUse = Transform.Identity;

IList<IFCAnyHandle> triangulatedBodyItems = ExportBodyAsTessellatedFaceSet(exporterIFC, element, options, geomObject, trfToUse);
if (triangulatedBodyItems != null && triangulatedBodyItems.Count > 0)
{
Expand All @@ -2808,7 +2811,7 @@ private static BodyData ExportBodyAsBRep(ExporterIFC exporterIFC, IList<Geometry
// If the above options do not generate any body, do the traditional step for Brep
if (!alreadyExported && (exportAsBReps || isCoarse))
{
alreadyExported = ExportBodyAsSolid(exporterIFC, element, options, currentFaceHashSetList, geomObject);
alreadyExported = ExportBodyAsSolid(exporterIFC, element, options, currentFaceHashSetList, geomObject, trfToUse);
}

// If all else fails, use the internal routine to go through the faces. This will likely create a surface model.
Expand Down
3 changes: 1 addition & 2 deletions Source/Revit.IFC.Export/Exporter/Exporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1831,9 +1831,8 @@ private void EndDocumentExportCommon(ExporterIFC exporterIFC, Document document,
if ((materialSetLayerUsage.Value?.Count ?? 0) == 0)
continue;

string hash = ExporterCacheManager.MaterialSetUsageCache.GetHash(materialSetLayerUsage.Key);
string guid = GUIDUtil.GenerateIFCGuidFrom(
GUIDUtil.CreateGUIDString(IFCEntityType.IfcRelAssociatesMaterial, hash));
GUIDUtil.CreateGUIDString(IFCEntityType.IfcRelAssociatesMaterial, ExporterUtil.GetGlobalId(materialSetLayerUsage.Value.First())));
IFCInstanceExporter.CreateRelAssociatesMaterial(file, guid, ownerHistory,
null, null, materialSetLayerUsage.Value,
materialSetLayerUsage.Key);
Expand Down
Loading