Request

Response

    Creating Geometry

    Overview

    The Data Exchange SDK provides three main types of geometry that you can create and associate with elements or the exchange container:

    1. File-Based Geometry - External geometry files (STEP, OBJ, IFC, etc.)
    2. Mesh Geometry - In-memory mesh data with vertices, faces, and colors
    3. Primitive Geometry - Points, curves, and surfaces defined programmatically

    This guide shows you how to create each type of geometry and associate it with elements in your exchange.

    File-Based Geometry

    File-based geometry refers to external geometry files in formats like STEP (.stp), OBJ (.obj), and IFC (.ifc).

    Important: This version of the SDK, unlike prior versions, requires explicit specification of geometry format and does not rely on file extensions. You must always provide the GeometryFormat parameter when creating file geometry. This allows you to process files with any extension or no extension at all - for example, a file without an extension can be processed as a STEP file by specifying GeometryFormat.Step.

    Basic File Geometry

    To create file geometry, you must explicitly specify the geometry format. The SDK does not rely on file extensions to determine the format:

    var geometry = ElementDataModel.CreateFileGeometry(
        filePath: "path/to/geometry.stp",
        format: GeometryFormat.Step
    );
    

    Important: As of SDK v7.6.0, the format parameter is required. The SDK will not infer the geometry type from the file extension, allowing you to process files regardless of their extension (e.g., a file with no extension can still be processed as a STEP file if you specify GeometryFormat.Step).

    Default behavior:

    • Units default to Feet for all measurements
    • No render style is applied

    File Geometry with Render Style

    To control how the geometry appears, provide a RenderStyle along with the explicit format:

    var renderStyle = new RenderStyle(
        name: "Wall Style",
        rgba: new RGBA(255, 0, 0, 255),  // Red, fully opaque
        transparency: 1.0                 // 1.0 = fully opaque, 0.0 = fully transparent
    );
    
    var geometry = ElementDataModel.CreateFileGeometry(
        filePath: "wall.stp",
        format: GeometryFormat.Step,
        renderStyle: renderStyle
    );
    
    Show More

    File Geometry with Custom Units

    If your geometry uses units other than feet, specify them explicitly along with the format:

    var units = new Units(
        lengthUnit: UnitFactory.Meter,
        displayLengthUnit: UnitFactory.Meter,
        displayAngleUnit: UnitFactory.Radian
    );
    
    var geometry = ElementDataModel.CreateFileGeometry(
        filePath: "geometry.stp",
        format: GeometryFormat.Step,
        renderStyle: null,  // Optional
        units: units
    );
    
    Show More

    Common units:

    • Length: UnitFactory.Meter, UnitFactory.Feet, UnitFactory.MilliMeter, UnitFactory.Centimeter
    • Angle: UnitFactory.Radian, UnitFactory.Degree

    File Geometry with Explicit Format

    You must always specify the format explicitly. The SDK will not infer the geometry type from file extensions:

    // Process a file without extension as OBJ
    var geometry = ElementDataModel.CreateFileGeometry(
        filePath: "mesh_data",
        format: GeometryFormat.Obj
    );
    
    // Explicitly specify STEP format
    var geometry = ElementDataModel.CreateFileGeometry(
        filePath: "geometry.stp",
        format: GeometryFormat.Step
    );
    
    Show More

    Available formats:

    • GeometryFormat.Step - STEP files (.stp, .step)
    • GeometryFormat.Obj - Wavefront OBJ (.obj)
    • GeometryFormat.Ifc - IFC files (.ifc)

    File Geometry from Memory Stream

    You can create file geometry from an in-memory MemoryStream instead of a disk file:

    // Load geometry data into memory
    MemoryStream geometryStream = LoadGeometryFromDatabase();
    
    var geometry = ElementDataModel.CreateFileGeometry(
        geometryStream: geometryStream,
        format: GeometryFormat.Step,
        renderStyle: myRenderStyle,
        units: myUnits
    );
    
    Show More

    When to use memory streams:

    • Geometry comes from a database or API
    • You’re processing geometry data in-memory
    • You want to avoid temporary files

    Note: The SDK will write the stream to a temporary file internally, so this is not the same as in-memory geometry retrieval (see Working with In-Memory Geometry).

    Complete File Geometry Example

    using Autodesk.DataExchange.DataModels;
    using Autodesk.DataExchange.SchemaObjects.Assets;
    using Autodesk.DataExchange.SchemaObjects.Units;
    
    // Create a render style for the wall
    var wallStyle = new RenderStyle(
        name: "Concrete Wall",
        rgba: new RGBA(200, 200, 200, 255),  // Gray
        transparency: 1.0
    );
    
    // Set up metric units
    var metricUnits = new Units(
        lengthUnit: UnitFactory.Meter,
        displayLengthUnit: UnitFactory.Meter,
        displayAngleUnit: UnitFactory.Radian
    );
    
    // Create geometry from STEP file with explicit format
    var wallGeometry = ElementDataModel.CreateFileGeometry(
        filePath: @"C:\Geometries\wall_segment_01.stp",
        format: GeometryFormat.Step,
        renderStyle: wallStyle,
        units: metricUnits
    );
    
    // Create element and assign geometry
    var dataModel = ElementDataModel.Create(client);
    var wallElement = dataModel.AddElement("Wall-001", "Exterior Wall");
    var wallCategory = dataModel.Classify(wallElement, ClassificationSystem.Category, "Walls");
    var wallFamily = dataModel.Classify(wallElement, ClassificationSystem.Family, "Basic Wall", parent: wallCategory);
    var wallType = dataModel.DefineType(system: "Type", name: "Concrete 200mm", parent: wallFamily);
    dataModel.SetType(wallElement, wallType);
    
    dataModel.SetElementGeometry(wallElement, new[] { wallGeometry });
    
    Show More

    Mesh Geometry

    Mesh geometry represents 3D models as collections of vertices, faces (triangles), and optional colors. This is useful for creating custom geometry programmatically or converting from other mesh formats.

    Basic Mesh Geometry

    using Autodesk.GeometryUtilities.MeshAPI;
    
    // Create a mesh
    var mesh = new Mesh
    {
        Vertices = new List<Vertex>
        {
            new Vertex { Position = new Point3d(0, 0, 0) },
            new Vertex { Position = new Point3d(1, 0, 0) },
            new Vertex { Position = new Point3d(0.5, 1, 0) }
        },
        Faces = new List<Face>
        {
            new Face { Indices = new List<int> { 0, 1, 2 } }
        }
    };
    
    // Create mesh geometry
    var meshGeometry = ElementDataModel.CreateMeshGeometry(
        mesh: mesh,
        meshName: "Triangle Mesh"
    );
    
    Show More

    Mesh Geometry with Colors

    Add per-vertex colors to your mesh:

    var coloredMesh = new Mesh
    {
        Vertices = new List<Vertex>
        {
            new Vertex 
            { 
                Position = new Point3d(0, 0, 0),
                Color = new Color { R = 255, G = 0, B = 0, A = 255 }  // Red
            },
            new Vertex 
            { 
                Position = new Point3d(1, 0, 0),
                Color = new Color { R = 0, G = 255, B = 0, A = 255 }  // Green
            },
            new Vertex 
            { 
                Position = new Point3d(0.5, 1, 0),
                Color = new Color { R = 0, G = 0, B = 255, A = 255 }  // Blue
            }
        },
        Faces = new List<Face>
        {
            new Face { Indices = new List<int> { 0, 1, 2 } }
        }
    };
    
    var meshGeometry = ElementDataModel.CreateMeshGeometry(
        mesh: coloredMesh,
        meshName: "Colored Triangle",
        units: new Units(UnitFactory.Meter, UnitFactory.Meter, UnitFactory.Radian)
    );
    
    Show More

    Complex Mesh Example

    Create a more complex mesh with multiple faces:

    // Create a pyramid
    var pyramidMesh = new Mesh
    {
        Vertices = new List<Vertex>
        {
            // Base vertices
            new Vertex { Position = new Point3d(0, 0, 0) },
            new Vertex { Position = new Point3d(1, 0, 0) },
            new Vertex { Position = new Point3d(1, 1, 0) },
            new Vertex { Position = new Point3d(0, 1, 0) },
            // Apex
            new Vertex { Position = new Point3d(0.5, 0.5, 1) }
        },
        Faces = new List<Face>
        {
            // Base
            new Face { Indices = new List<int> { 0, 1, 2 } },
            new Face { Indices = new List<int> { 0, 2, 3 } },
            // Sides
            new Face { Indices = new List<int> { 0, 1, 4 } },
            new Face { Indices = new List<int> { 1, 2, 4 } },
            new Face { Indices = new List<int> { 2, 3, 4 } },
            new Face { Indices = new List<int> { 3, 0, 4 } }
        }
    };
    
    var pyramidGeometry = ElementDataModel.CreateMeshGeometry(
        mesh: pyramidMesh,
        meshName: "Pyramid"
    );
    
    // Assign to element
    var pyramidElement = dataModel.AddElement("Pyramid-001", "Test Pyramid");
    var pyramidCategory = dataModel.Classify(pyramidElement, ClassificationSystem.Category, "Structures");
    var pyramidFamily = dataModel.Classify(pyramidElement, ClassificationSystem.Family, "Pyramid", parent: pyramidCategory);
    var pyramidType = dataModel.DefineType(system: "Type", name: "Standard", parent: pyramidFamily);
    dataModel.SetType(pyramidElement, pyramidType);
    dataModel.SetElementGeometry(pyramidElement, new[] { pyramidGeometry });
    
    Show More

    Primitive Geometry

    Primitive geometry includes points, curves, and surfaces defined programmatically. This is ideal for analytical geometry, construction lines, or simple shapes.

    Single Point

    Create a single 3D point:

    using Autodesk.GeometryPrimitives.Data;
    using Autodesk.GeometryPrimitives.Data.Design;
    
    var point = new DesignPoint(10.0, 20.0, 5.0);
    
    var pointGeometry = ElementDataModel.CreatePrimitiveGeometry(
        geometry: point,
        renderStyle: new RenderStyle("Point", new RGBA(255, 0, 0, 255), 1.0)
    );
    
    var pointElement = dataModel.AddElement("Point-001", "Reference Point");
    var pointCategory = dataModel.Classify(pointElement, ClassificationSystem.Category, "Reference");
    var pointFamily = dataModel.Classify(pointElement, ClassificationSystem.Family, "Point", parent: pointCategory);
    var pointType = dataModel.DefineType(system: "Type", name: "Standard", parent: pointFamily);
    dataModel.SetType(pointElement, pointType);
    dataModel.SetElementGeometry(pointElement, new[] { pointGeometry });
    
    Show More

    Lines and Curves

    Use GeometryContainer to group multiple curves:

    using Autodesk.GeometryPrimitives.Data;
    using Autodesk.GeometryPrimitives.Data.DX;
    
    var geometryContainer = new GeometryContainer();
    
    // Add a line
    var line = new Line
    {
        Start = new Point { Position = new Point3d(0, 0, 0) },
        End = new Point { Position = new Point3d(10, 10, 0) }
    };
    geometryContainer.Curves.Add(line);
    
    // Create geometry
    var lineGeometry = ElementDataModel.CreatePrimitiveGeometry(
        geometry: geometryContainer,
        renderStyle: new RenderStyle("Line", new RGBA(0, 0, 255, 255), 1.0)
    );
    
    Show More

    Multiple Curves in One Container

    var multiCurveContainer = new GeometryContainer();
    
    // Add multiple lines forming a rectangle
    multiCurveContainer.Curves.Add(new Line
    {
        Start = new Point { Position = new Point3d(0, 0, 0) },
        End = new Point { Position = new Point3d(10, 0, 0) }
    });
    
    multiCurveContainer.Curves.Add(new Line
    {
        Start = new Point { Position = new Point3d(10, 0, 0) },
        End = new Point { Position = new Point3d(10, 10, 0) }
    });
    
    multiCurveContainer.Curves.Add(new Line
    {
        Start = new Point { Position = new Point3d(10, 10, 0) },
        End = new Point { Position = new Point3d(0, 10, 0) }
    });
    
    multiCurveContainer.Curves.Add(new Line
    {
        Start = new Point { Position = new Point3d(0, 10, 0) },
        End = new Point { Position = new Point3d(0, 0, 0) }
    });
    
    var rectangleGeometry = ElementDataModel.CreatePrimitiveGeometry(
        geometry: multiCurveContainer,
        renderStyle: new RenderStyle("Rectangle", new RGBA(255, 0, 0, 255), 1.0)
    );
    
    var rectangleElement = dataModel.AddElement("Rectangle-001", "Floor Outline");
    var rectangleCategory = dataModel.Classify(rectangleElement, ClassificationSystem.Category, "Reference");
    var rectangleFamily = dataModel.Classify(rectangleElement, ClassificationSystem.Family, "Rectangle", parent: rectangleCategory);
    var rectangleType = dataModel.DefineType(system: "Type", name: "Standard", parent: rectangleFamily);
    dataModel.SetType(rectangleElement, rectangleType);
    dataModel.SetElementGeometry(rectangleElement, new[] { rectangleGeometry });
    
    Show More

    Circles and Arcs

    var circleContainer = new GeometryContainer();
    
    // Add a circle
    var circle = new Circle
    {
        Center = new Point { Position = new Point3d(5, 5, 0) },
        Radius = 2.5,
        Normal = new Vector3d { X = 0, Y = 0, Z = 1 }
    };
    circleContainer.Curves.Add(circle);
    
    var circleGeometry = ElementDataModel.CreatePrimitiveGeometry(
        geometry: circleContainer,
        renderStyle: new RenderStyle("Circle", new RGBA(0, 255, 0, 255), 1.0)
    );
    
    Show More

    Polylines

    var polylineContainer = new GeometryContainer();
    
    var polyline = new Polyline
    {
        Points = new List<Point>
        {
            new Point { Position = new Point3d(0, 0, 0) },
            new Point { Position = new Point3d(1, 2, 0) },
            new Point { Position = new Point3d(3, 1, 0) },
            new Point { Position = new Point3d(5, 3, 0) }
        }
    };
    polylineContainer.Curves.Add(polyline);
    
    var polylineGeometry = ElementDataModel.CreatePrimitiveGeometry(
        geometry: polylineContainer
    );
    
    Show More

    Surfaces

    var surfaceContainer = new GeometryContainer();
    
    // Add a B-Surface (NURBS surface)
    var surface = new BSurface
    {
        UDegree = 3,
        VDegree = 3,
        // ... control points and knots
    };
    surfaceContainer.Surfaces.Add(surface);
    
    var surfaceGeometry = ElementDataModel.CreatePrimitiveGeometry(
        geometry: surfaceContainer,
        renderStyle: new RenderStyle("Surface", new RGBA(100, 100, 255, 255), 0.5)
    );
    
    Show More

    Assigning Geometry to Elements

    Single Geometry

    var element = dataModel.AddElement("Element-001", "My Element");
    var elementCategory = dataModel.Classify(element, ClassificationSystem.Category, "Category");
    var elementFamily = dataModel.Classify(element, ClassificationSystem.Family, "Family", parent: elementCategory);
    var elementType = dataModel.DefineType(system: "Type", name: "Type", parent: elementFamily);
    dataModel.SetType(element, elementType);
    
    var geometry = ElementDataModel.CreateFileGeometry(
        filePath: "geometry.stp",
        format: GeometryFormat.Step
    );
    
    dataModel.SetElementGeometry(element, new[] { geometry });
    
    Show More

    Multiple Geometries per Element

    An element can have multiple geometries of different types:

    var element = dataModel.AddElement("Complex-001", "Complex Element");
    var complexCategory = dataModel.Classify(element, ClassificationSystem.Category, "Structures");
    var complexFamily = dataModel.Classify(element, ClassificationSystem.Family, "Complex", parent: complexCategory);
    var complexType = dataModel.DefineType(system: "Type", name: "Standard", parent: complexFamily);
    dataModel.SetType(element, complexType);
    
    var geometries = new List<ElementGeometry>
    {
        // File-based solid geometry
        ElementDataModel.CreateFileGeometry("main_body.stp", GeometryFormat.Step, myRenderStyle),
        
        // Mesh for detailed surface
        ElementDataModel.CreateMeshGeometry(detailMesh, "Surface Detail"),
        
        // Reference lines
        ElementDataModel.CreatePrimitiveGeometry(referenceLines, lineStyle)
    };
    
    dataModel.SetElementGeometry(element, geometries);
    
    Show More

    Choosing Category Names

    The value you pass to Classify(element, ClassificationSystem.Category, value) does more than organize your data — in Revit, certain category names are treated as reserved keywords rather than plain labels.

    Caution: When Revit loads an exchange, it intercepts any element whose Category classification matches one of the names below. Depending on the category, Revit either discards the element’s geometry and any nested elements, or replaces the element with a native Revit object and discards the associated geometry. In both cases, no error is raised — the data is simply missing.

    Category nameBehavior in Revit
    Areas The element and any nested elements are silently dropped.
    Grids The element and any nested elements are silently dropped.
    Levels Revit creates a native Level element instead of loading the exchange data; geometry is ignored. Using Revit's Import Levels option imports it as a native level but still discards the geometry.
    Rooms The element and any nested elements are silently dropped.

    This list reflects the reserved names identified so far and may not be exhaustive. Treat any category name that matches a standard Revit category as a candidate for this behavior.

    Recommendation

    Avoid these names for elements you want to load with their geometry intact. Append a suffix or otherwise rename the category:

    // Avoid: "Levels" is a reserved category name in Revit
    var element = dataModel.AddElement("Level-01", "Ground Floor");
    dataModel.Classify(element, ClassificationSystem.Category, "Levels");
    
    // Use instead: an unreserved name preserves the geometry on load
    var element = dataModel.AddElement("Level-01", "Ground Floor");
    dataModel.Classify(element, ClassificationSystem.Category, "Levels-Custom");
    

    This also applies to nested elements: don’t place geometry-bearing elements (walls, doors, floors, or other model elements) under a parent whose category is one of the reserved names. Revit discards the nested geometry along with the parent.

    Root-Level Geometry

    Geometry can also be assigned at the root/model level without being associated with specific elements:

    var rootGeometries = new List<ElementGeometry>
    {
        ElementDataModel.CreateFileGeometry("site_context.obj", GeometryFormat.Obj),
        ElementDataModel.CreatePrimitiveGeometry(gridLines)
    };
    
    dataModel.SetGeometries(rootGeometries);
    

    Use cases for root-level geometry:

    • Site context or background models
    • Construction grids
    • Reference planes
    • Annotation geometry

    Working with Units

    Creating Units

    // Imperial (feet and inches)
    var imperialUnits = new Units(
        lengthUnit: UnitFactory.Feet,
        displayLengthUnit: UnitFactory.Feet,
        displayAngleUnit: UnitFactory.Degree
    );
    
    // Metric (meters)
    var metricUnits = new Units(
        lengthUnit: UnitFactory.Meter,
        displayLengthUnit: UnitFactory.Meter,
        displayAngleUnit: UnitFactory.Radian
    );
    
    // Millimeters
    var mmUnits = new Units(
        lengthUnit: UnitFactory.MilliMeter,
        displayLengthUnit: UnitFactory.MilliMeter,
        displayAngleUnit: UnitFactory.Radian
    );
    
    // Default units (feet)
    var defaultUnits = new Units();  // Feet, Feet, Radian
    
    Show More

    Unit Parameters

    • lengthUnit - The actual measurement unit of the geometry data
    • displayLengthUnit - How lengths should be displayed in the UI
    • displayAngleUnit - How angles should be displayed (Radian or Degree)

    Note: If you don’t specify units, the SDK uses Feet for all length measurements and Radians for angles.

    Working with Render Styles

    Creating Render Styles

    var renderStyle = new RenderStyle(
        name: "Steel",
        rgba: new RGBA(
            red: 192,      // 0-255
            green: 192,    // 0-255
            blue: 192,     // 0-255
            alpha: 255     // 0-255, 255 = opaque
        ),
        transparency: 1.0   // 0.0 = fully transparent, 1.0 = fully opaque
    );
    
    Show More

    Common Colors

    // Red
    var red = new RGBA(255, 0, 0, 255);
    
    // Green
    var green = new RGBA(0, 255, 0, 255);
    
    // Blue
    var blue = new RGBA(0, 0, 255, 255);
    
    // Gray
    var gray = new RGBA(128, 128, 128, 255);
    
    // Semi-transparent white
    var translucentWhite = new RGBA(255, 255, 255, 128);
    
    Show More

    Transparency vs Alpha

    Two ways to control opacity:

    1. RGBA Alpha channel - Controls the alpha value of the color itself
    2. Transparency parameter - Additional transparency factor
    // 50% transparent using alpha
    var style1 = new RenderStyle(
        "Semi-Transparent",
        new RGBA(255, 0, 0, 128),  // Alpha = 128 (50%)
        1.0                         // Transparency = 1.0 (fully opaque)
    );
    
    // 50% transparent using transparency parameter
    var style2 = new RenderStyle(
        "Semi-Transparent",
        new RGBA(255, 0, 0, 255),  // Alpha = 255 (fully opaque)
        0.5                         // Transparency = 0.5 (50% transparent)
    );
    
    Show More

    Best practice: Use the transparency parameter for easier control.

    Best Practices

    1. Reuse Render Styles

    // Define common styles once
    var concreteStyle = new RenderStyle("Concrete", new RGBA(200, 200, 200, 255), 1.0);
    var steelStyle = new RenderStyle("Steel", new RGBA(192, 192, 192, 255), 1.0);
    
    // Reuse across multiple geometries
    var beam1Geom = ElementDataModel.CreateFileGeometry("beam1.stp", GeometryFormat.Step, steelStyle);
    var beam2Geom = ElementDataModel.CreateFileGeometry("beam2.stp", GeometryFormat.Step, steelStyle);
    var slabGeom = ElementDataModel.CreateFileGeometry("slab.stp", GeometryFormat.Step, concreteStyle);
    
    Show More

    2. Consistent Units

    // Set units once and reuse
    var projectUnits = new Units(
        UnitFactory.Meter,
        UnitFactory.Meter,
        UnitFactory.Radian
    );
    
    // Use consistently across all geometry
    var geom1 = ElementDataModel.CreateFileGeometry("part1.stp", GeometryFormat.Step, null, projectUnits);
    var geom2 = ElementDataModel.CreateFileGeometry("part2.stp", GeometryFormat.Step, null, projectUnits);
    var mesh = ElementDataModel.CreateMeshGeometry(myMesh, "Mesh", projectUnits);
    
    Show More

    3. Validate File Paths

    string filePath = "geometry.stp";
    
    if (!File.Exists(filePath))
    {
        throw new FileNotFoundException($"Geometry file not found: {filePath}");
    }
    
    var geometry = ElementDataModel.CreateFileGeometry(filePath, GeometryFormat.Step);
    
    Show More

    4. Organize Geometry by Type

    // Group similar geometry types
    var structuralGeometry = new List<ElementGeometry>
    {
        ElementDataModel.CreateFileGeometry("beam.stp", GeometryFormat.Step, steelStyle, metricUnits),
        ElementDataModel.CreateFileGeometry("column.stp", GeometryFormat.Step, steelStyle, metricUnits)
    };
    
    var architecturalGeometry = new List<ElementGeometry>
    {
        ElementDataModel.CreateFileGeometry("wall.stp", GeometryFormat.Step, concreteStyle, metricUnits),
        ElementDataModel.CreateFileGeometry("floor.stp", GeometryFormat.Step, concreteStyle, metricUnits)
    };
    
    Show More

    5. Use Meaningful Names

    // Good: Descriptive mesh names
    var floorMesh = ElementDataModel.CreateMeshGeometry(mesh1, "Floor Slab Mesh");
    var roofMesh = ElementDataModel.CreateMeshGeometry(mesh2, "Roof Surface Mesh");
    
    // Bad: Generic names
    var mesh1 = ElementDataModel.CreateMeshGeometry(mesh1, "Mesh1");
    var mesh2 = ElementDataModel.CreateMeshGeometry(mesh2, "Mesh");
    

    6. Avoid Reserved Category Names

    // Avoid: "Rooms" is a reserved category name in Revit
    category: "Rooms"
    
    // Use instead
    category: "Rooms-Custom"
    

    See Choosing Category Names for the full list of known reserved names and why this matters.

    Troubleshooting

    File Not Found

    Error: FileNotFoundException: File could not be found with filepath...

    Solution: Verify the file path exists:

    var filePath = @"C:\Geometries\model.stp";
    if (!File.Exists(filePath))
    {
        Console.WriteLine($"File not found: {filePath}");
        return;
    }
    

    Invalid Format

    Error: Format cannot be determined or geometry fails to load

    Solution: Explicitly specify the format:

    var geometry = ElementDataModel.CreateFileGeometry(
        filePath: "geometry.dat",
        format: GeometryFormat.Step,  // Explicitly set format
        renderStyle: myStyle
    );
    

    Memory Issues with Large Meshes

    Issue: OutOfMemoryException when creating large meshes

    Solution: Consider using file-based geometry instead, or split into smaller meshes:

    // Instead of one huge mesh
    var largeMesh = CreateMassiveMesh();  // OutOfMemoryException!
    
    // Split into chunks
    var meshChunk1 = CreateMeshChunk(0, 10000);
    var meshChunk2 = CreateMeshChunk(10000, 20000);
    
    var geometries = new List<ElementGeometry>
    {
        ElementDataModel.CreateMeshGeometry(meshChunk1, "Part 1"),
        ElementDataModel.CreateMeshGeometry(meshChunk2, "Part 2")
    };
    
    Show More

    Units Mismatch

    Issue: Geometry appears too large or too small

    Solution: Ensure units match your source data:

    // If your STEP file is in millimeters
    var units = new Units(
        lengthUnit: UnitFactory.MilliMeter,
        displayLengthUnit: UnitFactory.MilliMeter,
        displayAngleUnit: UnitFactory.Radian
    );
    
    var geometry = ElementDataModel.CreateFileGeometry("part.stp", GeometryFormat.Step, null, units);
    
    Show More

    Empty Geometry Container

    Issue: Primitive geometry doesn’t display

    Solution: Ensure the geometry container has actual content:

    var container = new GeometryContainer();
    
    if (container.Curves.Count == 0 && 
        container.Surfaces.Count == 0 && 
        container.Points.Count == 0)
    {
        Console.WriteLine("Warning: Geometry container is empty!");
    }
    
    // Add at least one curve, surface, or point
    container.Curves.Add(myLine);
    
    var geometry = ElementDataModel.CreatePrimitiveGeometry(container);
    
    Show More

    Elements Missing After Loading in Revit

    Issue: Elements save without errors, but their geometry doesn’t appear in Revit — or a native Revit element (for example, a Level) appears in its place instead.

    Solution: Check whether the element’s category matches a reserved name such as Areas, Grids, Levels, or Rooms. Rename the category to something that doesn’t collide with a standard Revit category:

    // If this element's geometry disappears in Revit...
    category: "Rooms"
    
    // ...rename the category to preserve it
    category: "Rooms-Custom"
    

    See Choosing Category Names for the full list of known reserved names.

    API Reference

    CreateFileGeometry Overloads

    // Explicit format (required parameter)
    FileGeometry CreateFileGeometry(
        string filePath,
        GeometryFormat format,
        RenderStyle renderStyle = null,
        Units units = null
    )
    
    // From memory stream (format required)
    FileGeometry CreateFileGeometry(
        MemoryStream geometryStream,
        GeometryFormat format,
        RenderStyle renderStyle = null,
        Units units = null
    )
    
    Show More

    Important: The format parameter is required in all overloads. The SDK does not infer geometry types from file extensions, allowing you to process files with any extension or no extension at all.

    CreateMeshGeometry

    MeshGeometry CreateMeshGeometry(
        Mesh mesh,
        string meshName,
        Units units = null
    )
    

    CreatePrimitiveGeometry

    PrimitiveGeometry CreatePrimitiveGeometry(
        Geometry geometry,  // DesignPoint or GeometryContainer
        RenderStyle renderStyle = null,
        Units units = null
    )
    

    Units Constructor

    public Units(
        Unit lengthUnit = null,           // Defaults to UnitFactory.Feet
        Unit displayLengthUnit = null,    // Defaults to UnitFactory.Feet
        Unit displayAngleUnit = null      // Defaults to UnitFactory.Radian
    )
    

    RenderStyle Constructor

    public RenderStyle(
        string name,
        RGBA rgba,
        double transparency  // 0.0 = fully transparent, 1.0 = fully opaque
    )
    

    See Also