RotateElement Method


Rotates an element about the given axis and angle.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)
Since: 2012

Syntax

C#
public static void RotateElement(
	Document document,
	ElementId elementToRotate,
	Line axis,
	double angle
)
Visual Basic
Public Shared Sub RotateElement ( _
	document As Document, _
	elementToRotate As ElementId, _
	axis As Line, _
	angle As Double _
)
Visual C++
public:
static void RotateElement(
	Document^ document, 
	ElementId^ elementToRotate, 
	Line^ axis, 
	double angle
)

Parameters

document
Type: Autodesk.Revit.DB Document
The document that owns the elements.
elementToRotate
Type: Autodesk.Revit.DB ElementId
The element to rotate.
axis
Type: Autodesk.Revit.DB Line
The axis of rotation.
angle
Type: System Double
The angle of rotation in radians.

Examples

Copy C#
public void RotateColumn(Autodesk.Revit.DB.Document document, Autodesk.Revit.DB.Element element)
{
    XYZ point1 = new XYZ(10, 20, 0);
    XYZ point2 = new XYZ(10, 20, 30);
    Line axis = Line.CreateBound(point1, point2);
    ElementTransformUtils.RotateElement(document, element.Id, axis, Math.PI / 3.0);
}
Copy VB.NET
Public Sub RotateColumn(document As Autodesk.Revit.DB.Document, element As Autodesk.Revit.DB.Element)
    Dim point1 As New XYZ(10, 20, 0)
    Dim point2 As New XYZ(10, 20, 30)
    Dim axis As Line = Line.CreateBound(point1, point2)
    ElementTransformUtils.RotateElement(document, element.Id, axis, Math.PI / 3.0)
End Sub

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException The element elementToRotate does not exist in the document
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was NULL

See Also