ShapeImporter Class


A utility class that supports conversion of geometry stored in an external format into a Revit geometry objects.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 24.0.0.0 (24.0.0.0)
Since:  2017

Syntax

C#
public class ShapeImporter : IDisposable
Visual Basic
Public Class ShapeImporter _
	Implements IDisposable
Visual C++
public ref class ShapeImporter : IDisposable

Remarks

See ShapeImporterSourceFormat for the list of supported formats.

Examples

CopyC#
public void ReadSATFile(Document revitDoc)
{
    // Allow the user to select a SAT file.
    OpenFileDialog ofd = new OpenFileDialog();
    ofd.Filter = "SAT Files (*.sat)|*.sat";

    if (DialogResult.OK == ofd.ShowDialog())
    {
        ShapeImporter shapeImporter = new ShapeImporter();
        shapeImporter.InputFormat = ShapeImporterSourceFormat.SAT; 
        IList<GeometryObject> shapes = shapeImporter.Convert(revitDoc, ofd.FileName);

        if (shapes.Count != 0)
        {
            using (Transaction tr = new Transaction(revitDoc, "Create a DirectShape"))
            {
                tr.Start();

                DirectShape dsImportedSat = DirectShape.CreateElement(revitDoc, new ElementId(BuiltInCategory.OST_Walls));
                dsImportedSat.SetShape(shapes);

                tr.Commit();
            }
        }
    }
}
CopyVB.NET
Public Sub ReadSATFile(revitDoc As Document)
    ' Allow the user to select a SAT file.
    Dim ofd As New OpenFileDialog()
    ofd.Filter = "SAT Files (*.sat)|*.sat"

    If DialogResult.OK = ofd.ShowDialog() Then
        Dim shapeImporter As New ShapeImporter()
        shapeImporter.InputFormat = ShapeImporterSourceFormat.SAT
        Dim shapes As IList(Of GeometryObject) = shapeImporter.Convert(revitDoc, ofd.FileName)

        If shapes.Count <> 0 Then
            Using tr As New Transaction(revitDoc, "Create a DirectShape")
                tr.Start()

                Dim dsImportedSat As DirectShape = DirectShape.CreateElement(revitDoc, New ElementId(BuiltInCategory.OST_Walls))
                dsImportedSat.SetShape(shapes)

                tr.Commit()
            End Using
        End If
    End If
End Sub

Inheritance Hierarchy

SystemObject
  Autodesk.Revit.DBShapeImporter

See Also

ArchiLabs

Stop fighting Revit automation.

Build repeatable BIM design and documentation workflows with scripts, data, and AI in one place, without wrestling brittle one-off automations.

Try ArchiLabs →