DirectShape Class

This class is used to store externally created geometric shapes. Primary intended use is for importing shapes from other data formats such as IFC or STEP. A DirectShape object may be assigned a category. That will affect how that object is displayed in Revit.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: (17.0.1090.0)
Since: 2015


public class DirectShape : Element
Visual Basic
Public Class DirectShape _
	Inherits Element
Visual C++
public ref class DirectShape : public Element


DirectShape is not a replacement for "real" Wall, Roof, Window, etc. It would typically be used where there is not enough information to create, e.g., a Wall, or full functionality of a Wall object is not needed. Some category-specific functionality may be available. If you need to modify a shape held by a DirectShape object, use Revit Geometry API, and then store the modified shape back to the DirectShape object.


Copy C#
// Create a DirectShape Sphere
public void CreateSphereDirectShape(Document doc)
    List<Curve> profile = new List<Curve>();

    // first create sphere with 2' radius
    XYZ center = XYZ.Zero;
    double radius = 2.0;    
    XYZ profile00 = center;
    XYZ profilePlus = center + new XYZ(0, radius, 0);
    XYZ profileMinus = center - new XYZ(0, radius, 0);

    profile.Add(Line.CreateBound(profilePlus, profileMinus));
    profile.Add(Arc.Create(profileMinus, profilePlus, center + new XYZ(radius, 0, 0)));

    CurveLoop curveLoop = CurveLoop.Create(profile);
    SolidOptions options = new SolidOptions(ElementId.InvalidElementId, ElementId.InvalidElementId);

    Frame frame = new Frame(center, XYZ.BasisX, -XYZ.BasisZ, XYZ.BasisY);
    if (Frame.CanDefineRevitGeometry(frame) == true)
        Solid sphere = GeometryCreationUtilities.CreateRevolvedGeometry(frame, new CurveLoop[] { curveLoop }, 0, 2 * Math.PI, options);
        using (Transaction t = new Transaction(doc, "Create sphere direct shape"))
            // create direct shape and assign the sphere shape
            DirectShape ds = DirectShape.CreateElement(doc, new ElementId(BuiltInCategory.OST_GenericModel));

            ds.ApplicationId = "Application id";
            ds.ApplicationDataId = "Geometry object id";
            ds.SetShape(new GeometryObject[] { sphere });
' Create a DirectShape Sphere
Public Sub CreateSphereDirectShape(doc As Document)
    Dim profile As New List(Of Curve)()

    ' first create sphere with 2' radius
    Dim center As XYZ = XYZ.Zero
    Dim radius As Double = 2.0
    Dim profile00 As XYZ = center
    Dim profilePlus As XYZ = center + New XYZ(0, radius, 0)
    Dim profileMinus As XYZ = center - New XYZ(0, radius, 0)

    profile.Add(Line.CreateBound(profilePlus, profileMinus))
    profile.Add(Arc.Create(profileMinus, profilePlus, center + New XYZ(radius, 0, 0)))

    Dim curveLoop__1 As CurveLoop = CurveLoop.Create(profile)
    Dim options As New SolidOptions(ElementId.InvalidElementId, ElementId.InvalidElementId)

    Dim frame__2 As New Frame(center, XYZ.BasisX, -XYZ.BasisZ, XYZ.BasisY)
    If Frame.CanDefineRevitGeometry(frame__2) = True Then
        Dim sphere As Solid = GeometryCreationUtilities.CreateRevolvedGeometry(frame__2, New CurveLoop() {curveLoop__1}, 0, 2 * Math.PI, options)
        Using t As New Transaction(doc, "Create sphere direct shape")
            ' create direct shape and assign the sphere shape
            Dim ds As DirectShape = DirectShape.CreateElement(doc, New ElementId(BuiltInCategory.OST_GenericModel))

            ds.ApplicationId = "Application id"
            ds.ApplicationDataId = "Geometry object id"
            ds.SetShape(New GeometryObject() {sphere})
        End Using
    End If
End Sub

Inheritance Hierarchy

System Object
Autodesk.Revit.DB Element
Autodesk.Revit.DB DirectShape

See Also