Location Class


Provides location functionality for all elements.

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

Syntax

C#
public class Location : APIObject
Visual Basic
Public Class Location _
	Inherits APIObject
Visual C++
public ref class Location : public APIObject

Remarks

The location object provides the ability to translate and rotate elements. More detailed location information and control can be found by using the derivatives of this object, such as LocationPoint or LocationCurve.

Examples

Copy C#
void ShowLocationUsage(Autodesk.Revit.ApplicationServices.Application application, Wall wall)
{
    // Get the location instance.
    Autodesk.Revit.DB.Location position = wall.Location;

    // Check whether the wall is pinned.
    if (wall.Pinned)
    {
        throw new Exception("The wall has been pinned.");
    }

    // Move the wall location, it provides same function as Move method of Document class.
    XYZ direction = new XYZ(10, 0, 0);
    bool result = position.Move(direction);
    if (!result)
    {
        throw new Exception("Move wall location failed.");
    }

    // Rotate the wall location, it provides same function as Rotate method of Document class.
    XYZ axisStart = new XYZ(0, 0, 0);
    XYZ axisEnd = new XYZ(0, 0, 1);
    Line axis = Line.CreateUnbound(axisStart, axisEnd);
    result = position.Rotate(axis, 30);
    if (!result)
    {
        throw new Exception("Rotate wall location failed.");
    }
}
Copy VB.NET
Private Sub ShowLocationUsage(application As Autodesk.Revit.ApplicationServices.Application, wall As Wall)
    ' Get the location instance.
    Dim position As Autodesk.Revit.DB.Location = wall.Location

    ' Check whether the wall is pinned.
    If wall.Pinned Then
        Throw New Exception("The wall has been pinned.")
    End If

    ' Move the wall location, it provides same function as Move method of Document class.
    Dim direction As New XYZ(10, 0, 0)
    Dim result As Boolean = position.Move(direction)
    If Not result Then
        Throw New Exception("Move wall location failed.")
    End If

    ' Rotate the wall location, it provides same function as Rotate method of Document class.
    Dim axisStart As New XYZ(0, 0, 0)
    Dim axisEnd As New XYZ(0, 0, 1)
    Dim axis As Line = Line.CreateUnbound(axisStart, axisEnd)
    result = position.Rotate(axis, 30)
    If Not result Then
        Throw New Exception("Rotate wall location failed.")
    End If
End Sub

Inheritance Hierarchy

See Also