ElementTransformUtils.MoveElement
Description:
Moves one element by a given transformation.
Moves one element by a given transformation.
-
documentThe document that owns the elements.
-
elementToMoveThe id of the element to move.
-
translationThe translation vector for the elements.
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;
TaskDialog.Show("Revit",info);
}
-
The element elementToMove does not exist in the document
-
A non-optional argument was null
-
If we are not able to move the element (for example, if it is pinned). -or- Move operation failed.