MoveElement Method

Moves one element by a given transformation.

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


public static void MoveElement(
	Document document,
	ElementId elementToMove,
	XYZ translation
Visual Basic
Public Shared Sub MoveElement ( _
	document As Document, _
	elementToMove As ElementId, _
	translation As XYZ _
Visual C++
static void MoveElement(
	Document^ document, 
	ElementId^ elementToMove, 
	XYZ^ translation


Type: Autodesk.Revit.DB Document
The document that owns the elements.
Type: Autodesk.Revit.DB ElementId
The id of the element to move.
Type: Autodesk.Revit.DB XYZ
The translation vector for the elements.


Copy C#
public void MoveColumn(Autodesk.Revit.DB.Document document, FamilyInstance column)
    // get the column current location
    LocationPoint columnLocation = column.Location as LocationPoint;

    XYZ oldPlace = columnLocation.Point;

    // Move the column to new location.
    XYZ newPlace = new XYZ(10, 20, 30);
    ElementTransformUtils.MoveElement(document, column.Id, newPlace);

    // now get the column's new location
    columnLocation = column.Location as LocationPoint;
    XYZ newActual = columnLocation.Point;

    string info = "Original Z location: " + oldPlace.Z +
                  "\nNew Z location: " + newActual.Z;

Public Sub MoveColumn(document As Autodesk.Revit.DB.Document, column As FamilyInstance)
    ' get the column current location
    Dim columnLocation As LocationPoint = TryCast(column.Location, LocationPoint)

    Dim oldPlace As XYZ = columnLocation.Point

    ' Move the column to new location.
    Dim newPlace As New XYZ(10, 20, 30)
    ElementTransformUtils.MoveElement(document, column.Id, newPlace)

    ' now get the column's new location
    columnLocation = TryCast(column.Location, LocationPoint)
    Dim newActual As XYZ = columnLocation.Point

    Dim info As String = ("Original Z location: " + oldPlace.Z & vbLf & "New Z location: ") + newActual.Z

    TaskDialog.Show("Revit", info)
End Sub


Exception Condition
Autodesk.Revit.Exceptions ArgumentException The element elementToMove does not exist in the document
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was NULL
Autodesk.Revit.Exceptions InvalidOperationException If we are not able to move the element (for example, if it is pinned). -or- Move operation failed.

See Also