### Create Complete Building Structure Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/IfcElements.md An example demonstrating the creation of a full building structure, from project setup to individual elements like walls and doors. ```csharp // Create database var database = new DatabaseIfc(ModelView.Ifc4Reference); // Setup project and context var project = database.Context as IfcProject; project.Name = "Office Building"; // Create site var site = new IfcSite(project); site.Name = "Downtown Site"; site.RefLatitude = "37.7749"; site.RefLongitude = "-122.4194"; // Create building var building = new IfcBuilding(site); building.Name = "Main Office"; // Create floor (storey) var storey = new IfcBuildingStorey(building); storey.Name = "Ground Floor"; storey.ElevationWithFlooring = 0; // Create room/space var space = new IfcSpace(storey); space.Name = "Reception"; space.PredefinedType = IfcSpaceTypeEnum.SPACE; // Create walls var wall1 = new IfcWall(space); wall1.Name = "South Wall"; wall1.PredefinedType = IfcWallTypeEnum.STANDARD; var wall2 = new IfcWall(space); wall2.Name = "East Wall"; wall2.PredefinedType = IfcWallTypeEnum.STANDARD; // Create door var door = new IfcDoor(space); door.Name = "Main Entrance"; door.PredefinedType = IfcDoorTypeEnum.DOOR; door.OverallHeight = 2100; door.OverallWidth = 1000; // Save database.WriteFile("building.ifc"); ``` -------------------------------- ### IfcPipe Instantiation Example Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/IfcElements.md Example of how to create and name an IfcPipe instance. ```csharp var pipe = new IfcPipe(host, placement, representation, system); pipe.Name = "Water Supply Pipe"; ``` -------------------------------- ### FormatIfcSerialization Usage Example Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/types.md Example demonstrating how to set the serialization format and write an IFC file. ```csharp database.Format = FormatIfcSerialization.JSON; database.WriteFile("model.json"); ``` -------------------------------- ### Example: Creating and Configuring an IfcSlab Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/IfcElements.md Demonstrates how to instantiate an IfcSlab, set its Name to 'Ground Floor', and specify its PredefinedType as IfcSlabTypeEnum.FLOOR. ```csharp var slab = new IfcSlab(database.Context); slab.Name = "Ground Floor"; slab.PredefinedType = IfcSlabTypeEnum.FLOOR; ``` -------------------------------- ### Create and Configure IfcWindow Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/IfcElements.md Example of creating an IfcWindow instance, setting its name, dimensions, and type. Ensure the database context is available. ```csharp var window = new IfcWindow(database.Context); window.Name = "Window W1"; window.OverallHeight = 1500; window.OverallWidth = 1000; window.PredefinedType = IfcWindowTypeEnum.WINDOW; ``` -------------------------------- ### Create and Configure IfcSpace Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/IfcElements.md Example of creating an IfcSpace instance and setting its properties. Requires a parent building object. ```csharp var space = new IfcSpace(building); space.Name = "Office 101"; space.PredefinedType = IfcSpaceTypeEnum.OFFICE; ``` -------------------------------- ### Example: Creating and Configuring an IfcBeam Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/IfcElements.md Illustrates the creation of an IfcBeam, setting its Name to 'Floor Beam B1', and assigning the PredefinedType as IfcBeamTypeEnum.JOIST. ```csharp var beam = new IfcBeam(database.Context); beam.Name = "Floor Beam B1"; beam.PredefinedType = IfcBeamTypeEnum.JOIST; ``` -------------------------------- ### Create and Configure IfcSite Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/IfcElements.md Example of creating an IfcSite instance and setting its properties. Requires an IfcProject context. ```csharp var site = new IfcSite(context); site.Name = "Main Campus"; site.RefLatitude = "37.7749"; site.RefLongitude = "-122.4194"; ``` -------------------------------- ### Example: Creating and Configuring an IfcWall Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/IfcElements.md Demonstrates how to instantiate an IfcWall, set its Name property to 'Exterior Wall', and assign a PredefinedType of IfcWallTypeEnum.STANDARD. ```csharp var wall = new IfcWall(database.Context); wall.Name = "Exterior Wall"; wall.PredefinedType = IfcWallTypeEnum.STANDARD; ``` -------------------------------- ### Create and Configure IfcBuilding Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/IfcElements.md Example of creating an IfcBuilding instance and setting its properties. Requires an IfcProject context. ```csharp var context = database.Context; // IfcProject context var building = new IfcBuilding(context); building.Name = "Main Building"; building.ElevationOfTerrain = "0.000"; ``` -------------------------------- ### Install GeometryGymIfc via NuGet Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/quick-start.md Use this command in the Package Manager Console to install the GeometryGymIfc library. ```powershell Install-Package GeometryGymIfc ``` -------------------------------- ### Example: Creating and Configuring an IfcColumn Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/IfcElements.md Shows how to create an IfcColumn instance, set its Name to 'Column C1', and define its PredefinedType as IfcColumnTypeEnum.COLUMN. ```csharp var column = new IfcColumn(database.Context); column.Name = "Column C1"; column.PredefinedType = IfcColumnTypeEnum.COLUMN; ``` -------------------------------- ### Install GeometryGymIfc Package Source: https://github.com/geometrygym/geometrygymifc/blob/main/GettingStarted.md Install the GeometryGymIfc package using the Nuget package manager console. Specify a version if needed. ```csharp Install-Package GeometryGymIFC ``` ```csharp Install-Package GeometryGymIFC -Version 0.1.6 ``` -------------------------------- ### VersionAddedAttribute Usage Example Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/types.md Example of applying the VersionAddedAttribute to an IfcAlignment class, specifying its introduction in IFC4X3. ```csharp [VersionAdded(ReleaseVersion.IFC4X3)] public class IfcAlignment : IfcLinearPositioningElement { } ``` -------------------------------- ### Create a Minimal IFC Model Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/quick-start.md This example shows the basic steps to create a new IFC model with a building entity and save it to a file. ```csharp // Create database with model view var database = new DatabaseIfc(ModelView.Ifc4Reference); // Create a building var building = new IfcBuilding(database.Context); building.Name = "My Building"; // Save to file database.WriteFile("output.ifc"); ``` -------------------------------- ### Example of Derived Class Constructor Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/BaseClassIfc.md Demonstrates how a derived class like IfcWall can utilize the protected constructor of BaseClassIfc to establish its own database association. ```csharp public class IfcWall : IfcBuildingElement { public IfcWall(DatabaseIfc db) : base(db) { } } ``` -------------------------------- ### Create IfcWallType Instance in C# Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/IfcElements.md Example of creating an IfcWallType instance with a name and predefined type, and setting its description. ```csharp var wallType = new IfcWallType(database, "Standard Brick Wall", IfcWallTypeEnum.STANDARD); wallType.Description = "External masonry wall with insulation"; ``` -------------------------------- ### IFC Relationship Examples Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/architecture.md Demonstrates the creation of common IFC relationships, including containment (IfcRelContainedInSpatialElement), assignment (IfcRelAssigns), and element connections (IfcRelConnectsElements). ```csharp // Containment: IfcRelContainedInSpatialElement var space = new IfcSpace(building); var wall = new IfcWall(space); // Wall contained in space // Assignment: IfcRelAssigns var propertySet = new IfcPropertySet(database); var rel = new IfcRelDefinesByProperties(database, wall, propertySet); // Connections: IfcRelConnects var rel2 = new IfcRelConnectsElements(database, wall1, wall2); ``` -------------------------------- ### Example Usage of DuplicateOptions Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/types.md Demonstrates creating and applying DuplicateOptions for entity duplication, including ignoring specific properties and enabling common geometry reuse. ```csharp var options = new DuplicateOptions(database.Tolerance) { DuplicateDownstream = true, DuplicateProperties = true, CommonGeometry = true, IgnoredPropertyNames = { "TempProperty" } }; var copy = database.Factory.Duplicate(original, options); ``` -------------------------------- ### Create New Empty IFC Database Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/DatabaseIfc.md Instantiate a new DatabaseIfc object to start a fresh IFC model with default settings. ```csharp var database = new DatabaseIfc(); ``` -------------------------------- ### Instantiate Triple with Double and IfcDirection in C# Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/types.md Example of creating Triple instances with different generic types, such as double for coordinates and IfcDirection for axes. ```csharp var translational = new Triple(1.0, 1.0, 1.0); var zDir = new Triple(factory.XAxis, factory.YAxis, factory.ZAxis); ``` -------------------------------- ### Example Usage of GenerateOptions Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/types.md Demonstrates modifying factory generation options to disable automatic OwnerHistory creation and ensure angle units are interpreted as radians. ```csharp database.Factory.Options.GenerateOwnerHistory = false; database.Factory.Options.AngleUnitsInRadians = true; ``` -------------------------------- ### Create IFC Building Structure Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/quick-start.md This example demonstrates how to create a complete building structure in IFC format, including site, building, storey, space, walls, doors, and windows. Ensure you have the necessary IFC schema definitions available. ```csharp // Create database var database = new DatabaseIfc(ModelView.Ifc4Reference); // Configure database.Factory.ApplicationDeveloper = "MyCompany"; database.Factory.ApplicationFullName = "BIM Application"; // Access project context var project = database.Context; project.Name = "Office Project"; // Create site var site = new IfcSite(project); site.Name = "Downtown Site"; site.RefLatitude = "37.7749"; // San Francisco site.RefLongitude = "-122.4194"; // Create building var building = new IfcBuilding(site); building.Name = "Main Office"; // Create building storey (floor) var storey = new IfcBuildingStorey(building); storey.Name = "Ground Floor"; storey.ElevationWithFlooring = 0; // Create space (room) var space = new IfcSpace(storey); space.Name = "Reception Lobby"; space.PredefinedType = IfcSpaceTypeEnum.SPACE; // Create walls var wall1 = new IfcWall(space); wall1.Name = "South Wall"; wall1.PredefinedType = IfcWallTypeEnum.STANDARD; var wall2 = new IfcWall(space); wall2.Name = "North Wall"; wall2.PredefinedType = IfcWallTypeEnum.STANDARD; // Create door var door = new IfcDoor(space); door.Name = "Main Entrance"; door.PredefinedType = IfcDoorTypeEnum.DOOR; door.OverallHeight = 2100; door.OverallWidth = 1000; // Create window var window = new IfcWindow(space); window.Name = "Reception Window"; window.PredefinedType = IfcWindowTypeEnum.WINDOW; window.OverallHeight = 1500; window.OverallWidth = 2000; // Save to file database.WriteFile("office-building.ifc"); ``` -------------------------------- ### VersionAddedAttribute Example Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/BaseClassIfc.md Illustrates the use of the VersionAddedAttribute to denote the release version in which an entity was introduced. This is useful for understanding schema compatibility. ```csharp [VersionAdded(ReleaseVersion.IFC4)] public class IfcAdvancedBrep : IfcManifoldSolidBrep { } [VersionAdded(ReleaseVersion.IFC4X3)] public class IfcSectionedSurface : IfcSurfaceOfLinearExtrusion { } ``` -------------------------------- ### Get Root Placement Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Provides access to the root placement, which represents the world origin of the IFC model. This is a read-only property. ```csharp public IfcLocalPlacement RootPlacement { get; } ``` -------------------------------- ### Use SetProgressBarCallback for File Writing in C# Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/types.md Example of providing a callback function to monitor and display progress during file writing operations. ```csharp database.WriteSTEPFile("output.ifc", (percent) => { Console.Write($"\rWriting: {percent}%"); }); ``` -------------------------------- ### Accessing GlobalId Property Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/BaseClassIfc.md Get the globally unique identifier for an entity derived from IfcRoot. This 22-character Base64-encoded GUID is essential for uniquely identifying IFC elements. ```csharp var building = new IfcBuilding(database.Context); string guid = building.GlobalId; // e.g., "2I5T0EQ3z0k8jNr5fFH7oI" ``` -------------------------------- ### Configure Database and Write IFC File Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/configuration.md Set up the IFC database with release version, model view, geometric tolerance, serialization format, and application information. Then, create and save IFC entities. ```csharp // Create and configure database var database = new DatabaseIfc(ModelView.Ifc4Reference); // Version and view database.Release = ReleaseVersion.IFC4X3_ADD2; database.ModelView = ModelView.Ifc4Reference; // Geometric precision database.Tolerance = 0.001; // 1mm tolerance database.ToleranceAngleRadians = Math.PI/1800; // 0.1 degree // Format database.Format = FormatIfcSerialization.STEP; // Factory/application info var factory = database.Factory; factory.ApplicationDeveloper = "MyCompany Inc."; factory.ApplicationFullName = "MyBIM Software v2.0"; factory.Options.GenerateOwnerHistory = true; factory.Options.AngleUnitsInRadians = true; // Now create entities var building = new IfcBuilding(database.Context); building.Name = "Main Building"; // Save with configured settings database.WriteFile("output.ifc"); ``` -------------------------------- ### Origin2dPlace Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Gets the 2D origin placement. ```APIDOC ## Origin2dPlace ### Description Gets the 2D origin placement. **Type:** IfcAxis2Placement2D (read-only) ``` -------------------------------- ### XYPlanePlacement Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Gets the XY plane placement at origin. ```APIDOC ## XYPlanePlacement ### Description Gets the XY plane placement at origin. **Type:** IfcAxis2Placement3D (read-only) ``` -------------------------------- ### Typical Usage of FactoryIfc Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Demonstrates the typical workflow for using FactoryIfc, including setting application details, creating geometric primitives, instantiating IFC entities like walls, and duplicating entities with custom options. ```csharp var database = new DatabaseIfc(ModelView.Ifc4Reference); var factory = database.Factory; // Configure application info factory.ApplicationDeveloper = "MyCompany"; factory.ApplicationFullName = "MyBIM Tool"; // Create geometric elements var zAxis = factory.ZAxis; var origin = new IfcCartesianPoint(database, 0, 0, 0); var placement = new IfcAxis2Placement3D(origin, zAxis); // Create entities var wall = new IfcWall(database.Context); wall.Name = "Exterior Wall"; // Duplicate with options var options = new DuplicateOptions(database.Tolerance) { DuplicateProperties = true, DuplicateDownstream = true }; var wallCopy = factory.Duplicate(wall, options); ``` -------------------------------- ### RootPlacement Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Gets the root (world origin) placement. ```APIDOC ## RootPlacement ### Description Gets the root (world origin) placement. **Type:** IfcLocalPlacement (read-only) ``` -------------------------------- ### SubContext Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Gets or creates a sub-context for a specific purpose. ```APIDOC ## SubContext ### Description Gets or creates a sub-context for a specific purpose. ### Method Signature ```csharp public IfcGeometricRepresentationSubContext SubContext( IfcGeometricRepresentationSubContext.SubContextIdentifier nature) ``` ### Parameters #### Path Parameters - **nature** (SubContextIdentifier) - Required - BODY, AXIS, FOOTPRINT, etc. ### Returns IfcGeometricRepresentationSubContext ``` -------------------------------- ### GeometricRepresentationContext Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Gets or creates a geometric representation context. ```APIDOC ## GeometricRepresentationContext ### Description Gets or creates a geometric representation context. ### Method Signature ```csharp public IfcGeometricRepresentationContext GeometricRepresentationContext( IfcGeometricRepresentationContext.GeometricContextIdentifier nature) ``` ### Parameters #### Path Parameters - **nature** (GeometricContextIdentifier) - Required - MODEL, PLAN, ELEVATION, SECTION, etc. ### Returns IfcGeometricRepresentationContext ``` -------------------------------- ### Pre-created SI Units Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Gets pre-created SI units (cached). ```APIDOC ## Pre-created SI Units ### SILength Gets pre-created SI length unit (cached). **Type:** IfcSIUnit (read-only) ### SIArea Gets pre-created SI area unit (cached). **Type:** IfcSIUnit (read-only) ### SIVolume Gets pre-created SI volume unit (cached). **Type:** IfcSIUnit (read-only) ``` -------------------------------- ### Database Property Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/BaseClassIfc.md Gets the database instance to which this entity belongs. This property is read-only. ```APIDOC ## Database Property ### Description Gets the database instance to which this entity belongs. ### Type `DatabaseIfc` (read-only) ### Returns The parent DatabaseIfc, or null if entity is unaffiliated. ### Example ```csharp var wall = new IfcWall(database.Context); var parentDb = wall.Database; // Returns the same database ``` ``` -------------------------------- ### Get 2D Origin Placement Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Retrieves the placement for the 2D origin. This is a read-only property. ```csharp public IfcAxis2Placement2D Origin2dPlace { get; } ``` -------------------------------- ### Create IFC Model Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/README.md Demonstrates how to create a new IFC database, add a building entity, and save the model to a file. ```csharp using GeometryGym.Ifc; // Create database var database = new DatabaseIfc(ModelView.Ifc4Reference); // Create entities var building = new IfcBuilding(database.Context); building.Name = "My Building"; // Save database.WriteFile("output.ifc"); ``` -------------------------------- ### Typical Workflow for DatabaseIfc Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/DatabaseIfc.md Demonstrates the common workflow for creating a new IFC model, adding entities, and saving it to a file, as well as loading an existing IFC file and accessing entities by their ID. ```csharp // Create new model var database = new DatabaseIfc(ModelView.Ifc4Reference); database.Factory.ApplicationDeveloper = "MyCompany"; database.Factory.ApplicationFullName = "MyBIM Software"; // Create entities var building = new IfcBuilding(database.Context); building.Name = "Main Building"; // Save to file database.WriteFile("output.ifc"); // Or load existing var existingDb = new DatabaseIfc("existing.ifc"); var entity = existingDb["2I5T0EQ3z0k8jNr5fFH7oI"]; ``` -------------------------------- ### Load IFC Database from File Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/DatabaseIfc.md Initialize a DatabaseIfc instance by loading and parsing an existing IFC file from a specified path. ```csharp var database = new DatabaseIfc("C:\\Models\\building.ifc"); ``` -------------------------------- ### Get XY Plane Placement Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Retrieves the placement for the XY plane located at the origin. This is a read-only property. ```csharp public IfcAxis2Placement3D XYPlanePlacement { get; } ``` -------------------------------- ### Construct IFC Product with Host, Placement, and Representation Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Constructs a generic IfcProduct entity, similar to ConstructElement but for a broader product type. Requires class name, host, placement, and representation. ```csharp public IfcProduct ConstructProduct(string className, IfcObjectDefinition host, IfcObjectPlacement placement, IfcProductDefinitionShape representation) ``` -------------------------------- ### Get Pre-created 2D Axis Directions Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Access pre-created 2D axis directions. These are read-only properties. ```csharp public IfcDirection XAxis2d { get; } ``` ```csharp public IfcDirection YAxis2d { get; } ``` ```csharp public IfcDirection XAxisNegative2d { get; } ``` ```csharp public IfcDirection YAxisNegative2d { get; } ``` -------------------------------- ### Create an IFC Model with Application Metadata Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/quick-start.md Configure application details, release version, and precision before creating entities and saving the IFC model. ```csharp var database = new DatabaseIfc(ModelView.Ifc4Reference); // Set application information var factory = database.Factory; factory.ApplicationDeveloper = "MyCompany"; factory.ApplicationFullName = "MyBIM Software v1.0"; // Configure model database.Release = ReleaseVersion.IFC4X3_ADD2; database.Tolerance = 0.001; // 1mm precision // Create entities var project = database.Context; var building = new IfcBuilding(project); building.Name = "Office Tower"; // Save database.WriteFile("building.ifc"); ``` -------------------------------- ### Create IfcAxis2Placement3D and IfcLocalPlacement Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/architecture.md Shows how to define a 3D placement using Cartesian points and axes, and then create a local placement relative to a parent. ```csharp var origin = new IfcCartesianPoint(database, 0, 0, 0); var zAxis = database.Factory.ZAxis; var xAxis = database.Factory.XAxis; var placement3D = new IfcAxis2Placement3D(origin, zAxis, xAxis); var localPlacement = new IfcLocalPlacement(parentPlacement, placement3D); wall.ObjectPlacement = localPlacement; ``` -------------------------------- ### GlobalId Property Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/BaseClassIfc.md Gets the 22-character globally unique identifier for this entity. This property is available only on IfcRoot derived classes. ```APIDOC ## GlobalId Property ### Description Gets the 22-character globally unique identifier for this entity. ### Type string ### Format 22-character Base64-encoded GUID ### Note Available only on classes derived from IfcRoot (buildings, walls, spaces, etc.). ### Example ```csharp var building = new IfcBuilding(database.Context); string guid = building.GlobalId; // e.g., "2I5T0EQ3z0k8jNr5fFH7oI" ``` ``` -------------------------------- ### Database and Entity Relationship Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/architecture.md Demonstrates how each IFC entity is associated with a single DatabaseIfc instance and how to access the database from an entity. ```csharp // Every entity holds a reference to its database var wall = new IfcWall(database.Context); DatabaseIfc parentDb = wall.Database; // Returns 'database' // Entities added automatically to database int stepId = wall.StepId; // Assigned on construction ``` -------------------------------- ### Write Database in STEP Format with Progress Callback Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/DatabaseIfc.md Writes the database in STEP P21 format and provides progress updates via a callback function. The callback receives a percentage value from 0 to 100. ```csharp public bool WriteSTEPFile(string filePath, SetProgressBarCallback setProgressBarCallback) ``` ```csharp database.WriteSTEPFile("model.ifc", (percent) => { Console.WriteLine($"Writing: {percent}%"); }); ``` -------------------------------- ### Create and Assign IfcBoundingBox Representation Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/architecture.md Demonstrates creating a simple bounding box and assigning it as the shape representation for a wall entity. ```csharp var box = new IfcBoundingBox(origin, 10, 5, 3); var rep = new IfcShapeRepresentation(context, "Body", "BoundingBox"); rep.Items.Add(box); var shape = new IfcProductDefinitionShape(null, rep); wall.Representation = shape; ``` -------------------------------- ### Create and Configure IfcDoor Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/IfcElements.md Demonstrates creating an IfcDoor object and assigning values to its properties such as name, dimensions, and type. Requires a valid database context. ```csharp var door = new IfcDoor(database.Context); door.Name = "Main Entrance Door"; door.OverallHeight = 2100; door.OverallWidth = 1000; door.PredefinedType = IfcDoorTypeEnum.DOOR; ``` -------------------------------- ### Get Pre-created Negative Unit Axis Directions Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Access pre-created negative unit axis directions. These are read-only properties. ```csharp public IfcDirection XAxisNegative { get; } ``` ```csharp public IfcDirection YAxisNegative { get; } ``` ```csharp public IfcDirection ZAxisNegative { get; } ``` -------------------------------- ### Utilize Factory for Common Entity Creation Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/architecture.md Illustrates using the factory pattern to create commonly needed objects like origins, axes, and owner history entries with sensible defaults. ```csharp var factory = database.Factory; var context = database.Context; var origin = factory.Origin; var xAxis = factory.XAxis; var ownerHistory = factory.OwnerHistory( IfcChangeActionEnum.ADDED, owner, application, DateTime.Now ); var wall1 = new IfcWall(database.Context); var wall2 = factory.Duplicate(wall1); ``` -------------------------------- ### Configuration Options Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/INDEX.md Information on how to configure the behavior of the GeometryGym IFC library, including options for database interaction, entity generation, serialization, and duplication. ```APIDOC ## Configuration Customize the library's behavior using the following configuration options: - **DatabaseIfc Configuration**: Options related to database management and access. - **FactoryIfc Configuration**: Settings for entity creation and metadata. - **Generation & Serialization**: `GenerateOptions` and `SerializationOptions` to control output format and content. - **Duplication**: `DuplicateOptions` with detailed explanations of all available flags. - **Version & Format**: Select specific IFC versions and formats. - **Precision**: Settings for tolerance and precision in geometric operations. ``` -------------------------------- ### Create IFC Database with Specific Release Version Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/DatabaseIfc.md Initialize a DatabaseIfc instance targeting a specific IFC schema release version. ```csharp var database = new DatabaseIfc(ReleaseVersion.IFC4X3_ADD2); ``` -------------------------------- ### Configuration Properties Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Configure application details and generation options for IFC file creation. ```APIDOC ## ApplicationDeveloper ### Description Sets the name of the company/developer who created the IFC file. ### Type string ### Example ```csharp database.Factory.ApplicationDeveloper = "Geometry Gym"; ``` --- ## ApplicationFullName ### Description Sets the name of the application that created the IFC file. ### Type string ### Example ```csharp database.Factory.ApplicationFullName = "GeometryGymIfc Toolkit"; ``` --- ## Options ### Description Gets the generation options for controlling automatic behavior. ### Type FactoryIfc.GenerateOptions ### Properties - `GenerateOwnerHistory` (bool): Whether to automatically create OwnerHistory entries (default: true) - `AngleUnitsInRadians` (bool): Whether angles are in radians (default: true) ### Example ```csharp database.Factory.Options.GenerateOwnerHistory = false; ``` ``` -------------------------------- ### Get Geometric Representation Context Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Retrieves or creates a geometric representation context for the model. Specify the nature of the context, such as MODEL, PLAN, or ELEVATION. ```csharp public IfcGeometricRepresentationContext GeometricRepresentationContext( IfcGeometricRepresentationContext.GeometricContextIdentifier nature) ``` -------------------------------- ### WriteSTEPFile with Progress Callback Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/DatabaseIfc.md Writes the database in STEP P21 format with progress callback. ```APIDOC ## WriteSTEPFile(string filePath, SetProgressBarCallback setProgressBarCallback) ### Description Writes the database in STEP P21 format with progress callback. ### Method ```csharp public bool WriteSTEPFile(string filePath, SetProgressBarCallback setProgressBarCallback) ``` ### Parameters #### Path Parameters - **filePath** (string) - Required - Output file path - **setProgressBarCallback** (SetProgressBarCallback) - Required - Callback for progress updates (0-100) ### Response #### Success Response (true) Returns true if successful. ### Request Example ```csharp database.WriteSTEPFile("model.ifc", (percent) => { Console.WriteLine($"Writing: {percent}%"); }); ``` ``` -------------------------------- ### Get Pre-created Unit Axis Directions Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Access cached, pre-created unit axis directions for common use cases. These are read-only properties. ```csharp public IfcDirection XAxis { get; } ``` ```csharp public IfcDirection YAxis { get; } ``` ```csharp public IfcDirection ZAxis { get; } ``` ```csharp var placement = new IfcAxis2Placement3D(origin, database.Factory.ZAxis, database.Factory.XAxis); ``` -------------------------------- ### Create New IFC Database Copying Configuration Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/DatabaseIfc.md Generate a new, empty DatabaseIfc instance that inherits the configuration settings from an existing DatabaseIfc object. ```csharp var sourceDb = new DatabaseIfc("existing.ifc"); var newDb = new DatabaseIfc(sourceDb); ``` -------------------------------- ### Write Database as Compressed STEP File Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/DatabaseIfc.md Compresses the database into a ZIP archive containing the STEP file. A progress callback is provided for monitoring the operation. ```csharp public bool WriteSTEPZipFile(string filePath, SetProgressBarCallback setProgressBarCallback) ``` -------------------------------- ### Configure IFC Serialization Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/README.md Illustrates how to set various configuration options for IFC serialization, including release version, model view, tolerance, and format. ```csharp database.Release = ReleaseVersion.IFC4X3_ADD2; database.ModelView = ModelView.Ifc4Reference; database.Tolerance = 0.001; // 1mm database.Format = FormatIfcSerialization.STEP; database.Factory.ApplicationDeveloper = "MyCompany"; database.Factory.ApplicationFullName = "MyBIM Software"; ``` -------------------------------- ### Get Sub-Context Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Retrieves or creates a sub-context for a specific purpose within a geometric representation. Use for defining contexts like BODY, AXIS, or FOOTPRINT. ```csharp public IfcGeometricRepresentationSubContext SubContext( IfcGeometricRepresentationSubContext.SubContextIdentifier nature) ``` -------------------------------- ### Create a Multi-Story Building Structure Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/quick-start.md This pattern shows how to programmatically create a building with multiple stories and rooms using the IfcBuilding, IfcBuildingStorey, and IfcSpace classes. It sets the name and elevation for each storey. ```csharp var database = new DatabaseIfc(ModelView.Ifc4Reference); database.Factory.ApplicationFullName = "MyBIM"; var project = database.Context; var building = new IfcBuilding(project); building.Name = "Multi-Story Building"; // Create multiple floors for (int floor = 0; floor < 5; floor++) { var storey = new IfcBuildingStorey(building); storey.Name = $"Floor {floor + 1}"; storey.ElevationWithFlooring = floor * 3000; // 3m per floor // Create rooms on each floor for (int room = 0; room < 4; room++) { var space = new IfcSpace(storey); space.Name = $"Room {floor + 1}{room + 1:D2}"; } } database.WriteFile("multi-story.ifc"); ``` -------------------------------- ### Get Pre-created SI Units Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/FactoryIfc.md Retrieves cached SI units for length, area, and volume. These are read-only properties for commonly used SI units. ```csharp public IfcSIUnit SILength { get; } ``` ```csharp public IfcSIUnit SIArea { get; } ``` ```csharp public IfcSIUnit SIVolume { get; } ``` -------------------------------- ### Check Entity Existence in DatabaseIfc Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/quick-start.md Use this to verify if an entity with a specific GUID exists in the database before attempting to access it. Returns null if the entity is not found. ```csharp // Check if entity exists var entity = database["unknown-guid"]; if (entity == null) { Console.WriteLine("Entity not found"); } ``` -------------------------------- ### Create IFC Models with Different Schema Versions Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/quick-start.md Demonstrates how to create IFC models compatible with different schema versions, including IFC2x3, IFC4, and IFC4.3, by specifying the desired version during initialization or by setting the Release property. ```csharp // Create IFC2x3 model var db2x3 = new DatabaseIfc(ReleaseVersion.IFC2x3); db2x3.WriteFile("model-2x3.ifc"); // Create IFC4 model var db4 = new DatabaseIfc(ReleaseVersion.IFC4A2); db4.WriteFile("model-4.ifc"); // Create IFC4.3 model var db43 = new DatabaseIfc(ModelView.IFC4X3Reference); db43.Release = ReleaseVersion.IFC4X3_ADD2; db43.WriteFile("model-4x3.ifc"); ``` -------------------------------- ### Traverse IFC Hierarchy Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/quick-start.md Navigate the hierarchical structure of an IFC model, starting from the project context and drilling down into buildings, storeys, and spaces. This allows for structured data retrieval. ```csharp var database = new DatabaseIfc("model.ifc"); // Get project var project = database.Context; Console.WriteLine($"Project: {project.Name}"); // Get buildings var buildings = project.Extract(); foreach (var building in buildings) { Console.WriteLine($" Building: {building.Name}"); // Get storeys var storeys = building.Extract(); foreach (var storey in storeys) { Console.WriteLine($" Storey: {storey.Name}"); // Get spaces var spaces = storey.Extract(); foreach (var space in spaces) { Console.WriteLine($" Space: {space.Name}"); } } } ``` -------------------------------- ### Load IFC File with Exception Handling Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/BaseClassIfc.md Demonstrates how to load an IFC file using DatabaseIfc and catch potential exceptions during deserialization. Wrap file loading operations in a try-catch block to handle errors gracefully. ```csharp try { var database = new DatabaseIfc("model.ifc"); } catch (Exception ex) { Console.WriteLine($"Failed to load IFC file: {ex.Message}"); } ``` -------------------------------- ### Inverse Relationship Maintenance Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/architecture.md Shows how inverse relationships are automatically maintained, ensuring consistency between related entities. For example, adding a wall to a space automatically updates the space's Contains collection. ```csharp var wall = new IfcWall(space); // Space.Contains automatically updated space.Contains.Contains(wall); // true ``` -------------------------------- ### Duplicate Entities with Custom Options Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/architecture.md Demonstrates copying entities between databases using a factory, with options to control the duplication process, such as including related entities or reusing common geometry. ```csharp var sourceDb = new DatabaseIfc("source.ifc"); var targetDb = new DatabaseIfc(); var sourceWall = sourceDb.Extract().First(); var options = new DuplicateOptions(targetDb.Tolerance) { DuplicateDownstream = true, CommonGeometry = true, DuplicateProperties = true }; var copiedWall = targetDb.Factory.Duplicate(sourceWall, options); ``` -------------------------------- ### Add Custom Property Set in C# Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/architecture.md Extend IFC entities by adding custom properties using `IfcPropertySet`. This example shows how to create a property set named 'Pset_Custom' and add a single value property. ```csharp var pset = new IfcPropertySet(database, "Pset_Custom"); pset.AddProperty(new IfcPropertySingleValue("CustomData", new IfcLabel("my value"))); ``` -------------------------------- ### Property Set Creation and Assignment Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/architecture.md Illustrates how to create a property set (IfcPropertySet), add individual properties (IfcPropertySingleValue), and associate it with an IFC entity using IfcRelDefinesByProperties. ```csharp var pset = new IfcPropertySet(database, "Pset_WallCommon"); pset.AddProperty(new IfcPropertySingleValue("Thickness", new IfcLengthMeasure(0.2))); pset.AddProperty(new IfcPropertySingleValue("FireRating", new IfcLabel("2HR"))); var rel = new IfcRelDefinesByProperties(database, wall, pset); ``` -------------------------------- ### DatabaseIfc() Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/DatabaseIfc.md Creates a new empty IFC database with default settings. This constructor initializes an IFC database instance without loading any existing model data. ```APIDOC ## DatabaseIfc() ### Description Creates a new empty IFC database with default settings. It returns a new `DatabaseIfc` instance configured for the STEP format and IFC2x3 release. ### Method `DatabaseIfc()` ### Returns A new `DatabaseIfc` instance. ### Example ```csharp var database = new DatabaseIfc(); ``` ``` -------------------------------- ### Initialize DuplicateOptions Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/configuration.md Create DuplicateOptions instances for controlling entity duplication. Options can be initialized with a tolerance or by copying from an existing set of options. ```csharp // Basic with tolerance var options = new DuplicateOptions(database.Tolerance); // Copy from existing var options2 = new DuplicateOptions(existingOptions); ``` -------------------------------- ### DatabaseIfc(DatabaseIfc db) Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/DatabaseIfc.md Creates a new database copying configuration from an existing database, but with no entities. This constructor is useful for creating a new, empty database that inherits settings from a pre-existing one. ```APIDOC ## DatabaseIfc(DatabaseIfc db) ### Description Creates a new database copying configuration from an existing database, but with no entities. This constructor duplicates the settings of a source database into a new, empty database. ### Method `DatabaseIfc(DatabaseIfc db)` ### Parameters #### Path Parameters - **db** (DatabaseIfc) - Required - Source database to copy settings from. ### Returns New empty `DatabaseIfc` with copied configuration. ### Example ```csharp var sourceDb = new DatabaseIfc("existing.ifc"); var newDb = new DatabaseIfc(sourceDb); ``` ``` -------------------------------- ### Create IFC Wall with Geometry Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/quick-start.md Demonstrates creating an IfcWall element with a name, placement, and a bounding box representation. Ensure the correct IFC schema version is used for the database context. ```csharp var database = new DatabaseIfc(ModelView.Ifc4Reference); var context = database.Context; // Create a wall element var wall = new IfcWall(context); wall.Name = "Exterior Wall"; // Create placement at specific location var origin = new IfcCartesianPoint(database, 0, 0, 0); var zAxis = database.Factory.ZAxis; var xAxis = database.Factory.XAxis; var placement3D = new IfcAxis2Placement3D(origin, zAxis, xAxis); var localPlacement = new IfcLocalPlacement(database.Factory.RootPlacement, placement3D); wall.ObjectPlacement = localPlacement; // Create a simple bounding box representation var boundingBox = new IfcBoundingBox(origin, 10000, 300, 3000); // 10m x 0.3m x 3m var representation = new IfcShapeRepresentation( database.Factory.GeometricRepresentationContext(IfcGeometricRepresentationContext.GeometricContextIdentifier.MODEL), "Body", "BoundingBox" ); representation.Items.Add(boundingBox); var shape = new IfcProductDefinitionShape(null, representation); wall.Representation = shape; database.WriteFile("wall-with-geometry.ifc"); ``` -------------------------------- ### Open Existing Ifc Model Source: https://github.com/geometrygym/geometrygymifc/blob/main/GettingStarted.md Open an existing Ifc model by providing the file path to the constructor. ```csharp string path = ""; var database = new DatabaseIfc(path); ``` -------------------------------- ### Write IFC File with Progress Reporting Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/quick-start.md Use this method to write an IFC file while providing a callback function to monitor the progress. The callback receives the percentage of completion. ```csharp var database = new DatabaseIfc("large-model.ifc"); // Write with progress callback database.WriteSTEPFile("output.ifc", (percentDone) => { Console.Write($"\rProgress: {percentDone}%"); }); Console.WriteLine(" - Done!"); ``` -------------------------------- ### Sequential vs. Concurrent Database Access Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/errors.md Demonstrates safe sequential access to DatabaseIfc and highlights the dangers of unsafe concurrent entity creation. Use locking mechanisms or separate database instances for thread safety. ```csharp object dbLock = new object(); Parallel.ForEach(wallNames, (name) => { lock (dbLock) { var wall = new IfcWall(database.Context); wall.Name = name; } }); ``` -------------------------------- ### Load IFC Model Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/README.md Shows how to load an existing IFC file into a database and extract specific entity types. ```csharp var database = new DatabaseIfc("model.ifc"); // Extract entities var buildings = database.Extract(); var walls = database.Extract(); ``` -------------------------------- ### WriteSTEPZipFile Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/DatabaseIfc.md Writes the database as a compressed ZIP archive containing the STEP file. ```APIDOC ## WriteSTEPZipFile(string filePath, SetProgressBarCallback setProgressBarCallback) ### Description Writes the database as a compressed ZIP archive containing the STEP file. ### Method ```csharp public bool WriteSTEPZipFile(string filePath, SetProgressBarCallback setProgressBarCallback) ``` ### Parameters #### Path Parameters - **filePath** (string) - Required - Output .zip file path - **setProgressBarCallback** (SetProgressBarCallback) - Required - Progress callback ### Response #### Success Response (true) Returns true if successful. ``` -------------------------------- ### Create IFC Element Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/IfcElements.md Demonstrates the common pattern for creating an IFC element, including setting properties and optional geometry. ```csharp // 1. Ensure context/host exists var context = database.Context; var building = new IfcBuilding(context); // 2. Create element var wall = new IfcWall(context); // 3. Set properties wall.Name = "Exterior Wall 1"; wall.Description = "North elevation"; wall.ObjectType = "Custom Wall"; wall.Tag = "W001"; // 4. Set geometry (optional) // wall.Representation = createRepresentation(); // 5. Set type-specific properties wall.PredefinedType = IfcWallTypeEnum.STANDARD; // 6. Create relationships // wall.AddPropertySet(propertySet); ``` -------------------------------- ### Add Property Set to IFC Wall Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/quick-start.md Shows how to create an IfcPropertySet and assign properties like Thickness, FireRating, and Acoustical to an IfcWall element. The default IFC schema is used if not specified. ```csharp var database = new DatabaseIfc(); var wall = new IfcWall(database.Context); wall.Name = "Test Wall"; // Create property set var pset = new IfcPropertySet(database, "Pset_WallCommon"); // Add properties pset.AddProperty(new IfcPropertySingleValue("Thickness", new IfcLengthMeasure(200))); // 200mm pset.AddProperty(new IfcPropertySingleValue("FireRating", new IfcLabel("2HR"))); pset.AddProperty(new IfcPropertySingleValue("Acoustical", new IfcLabel("Sound Absorbing"))); // Assign property set to wall var rel = new IfcRelDefinesByProperties(database, wall, pset); database.WriteFile("wall-with-properties.ifc"); ``` -------------------------------- ### DatabaseIfc(string filePath) Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/DatabaseIfc.md Opens and parses an existing IFC file from the specified path. This constructor loads and processes an IFC model from a given file location. ```APIDOC ## DatabaseIfc(string filePath) ### Description Opens and parses an existing IFC file from the specified path. This constructor loads an IFC model from a file, populating the database with its entities. ### Method `DatabaseIfc(string filePath)` ### Parameters #### Path Parameters - **filePath** (string) - Required - Path to the IFC file to load. ### Returns `DatabaseIfc` instance populated with entities from the file. ### Throws Exceptions from file I/O and parsing operations. ### Example ```csharp var database = new DatabaseIfc("C:\\Models\\building.ifc"); ``` ``` -------------------------------- ### Entity Duplication Strategies Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/configuration.md Illustrates two methods for duplicating entities: a full copy that merges downstream elements and a lightweight copy suitable for templates. Both options utilize the database tolerance. ```csharp // Copy everything (merge scenario) var fullCopy = database.Factory.Duplicate(entity, new DuplicateOptions(db.Tolerance) { DuplicateDownstream = true, CommonGeometry = false }); // Lightweight copy (template scenario) var lightCopy = database.Factory.Duplicate(entity, new DuplicateOptions(db.Tolerance) { DuplicateDownstream = false, CommonGeometry = true }); ``` -------------------------------- ### Global Identifier Usage Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/architecture.md Shows how to create an IfcRoot entity, access its GlobalId, and retrieve an entity from the database using its GlobalId. ```csharp var building = new IfcBuilding(database.Context); string globalId = building.GlobalId; // "2I5T0EQ3z0k8jNr5fFH7oI" // Retrieve by GlobalId var retrieved = database[globalId]; ``` -------------------------------- ### IfcWall Constructors Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/IfcElements.md Provides constructors for creating IfcWall instances. One constructor takes spatial context (host, placement, representation), while a minimal constructor requires only a DatabaseIfc context. ```csharp // With spatial context public IfcWall(IfcObjectDefinition host, IfcObjectPlacement placement, IfcProductDefinitionShape representation) : base(host, placement, representation) // Minimal public IfcWall(DatabaseIfc db) : base(db) ``` -------------------------------- ### Load IFC Database from TextReader Stream Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/DatabaseIfc.md Create a DatabaseIfc instance by reading IFC data from a TextReader stream. Ensure the stream is properly managed (e.g., using a 'using' statement). ```csharp using (var reader = new StreamReader("model.ifc")) { var database = new DatabaseIfc(reader); } ``` -------------------------------- ### Set Source File Path Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/configuration.md Specifies the path to the original source file if the database was loaded from disk. ```csharp public string SourceFilePath { get; set; } ``` ```csharp var database = new DatabaseIfc("C:\\Models\\building.ifc"); // database.SourceFilePath == "C:\\Models\\building.ifc" ``` -------------------------------- ### DuplicateOptions Copy Constructor Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/types.md Initializes DuplicateOptions by copying settings from an existing DuplicateOptions object. ```csharp public DuplicateOptions(DuplicateOptions options) // Copy constructor ``` -------------------------------- ### WriteSTEPFile with BackgroundWorker Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/api-reference/DatabaseIfc.md Writes the database in STEP format with background worker support. ```APIDOC ## WriteSTEPFile(string filePath, BackgroundWorker worker, DoWorkEventArgs e) ### Description Writes the database in STEP format with background worker support. ### Method ```csharp public bool WriteSTEPFile(string filePath, BackgroundWorker worker, DoWorkEventArgs e) ``` ### Parameters #### Path Parameters - **filePath** (string) - Required - Output file path - **worker** (BackgroundWorker) - Required - Background worker for async operations - **e** (DoWorkEventArgs) - Required - Event args for cancellation support ### Response #### Success Response (true) Returns true if successful. ``` -------------------------------- ### Setting Geometric Tolerance for Different Model Types Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/configuration.md Demonstrates how to set the database tolerance based on the precision requirements of different model types: architectural (cm), structural (mm), and manufacturing/MEP (sub-mm). ```csharp // Architectural models (cm precision) database.Tolerance = 0.01; // Structural models (mm precision) database.Tolerance = 0.001; // Manufacturing/MEP (sub-mm precision) database.Tolerance = 0.0001; ``` -------------------------------- ### Batch Operations vs. Individual Operations in C# Source: https://github.com/geometrygym/geometrygymifc/blob/main/_autodocs/architecture.md Demonstrates the performance benefit of batching operations like adding entities to a database. Adding entities one by one in a loop is less efficient than collecting them and adding them in a batch. ```csharp // Batch operations // Bad: foreach (var entity in entities) { database.Add(entity); } // Better: entitiesToAdd.AddRange(newEntities); ```