Elements moved to wrong location

Hi, I need help using the ElementTransformUtils.MoveElement method. For some reason the XYZ coordinates doubled once they go through that one line of code? Does anyone know why?

import clr
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
import Revit
# Import geometry conversion extension methods
# Import DocumentManager and TransactionManager
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument 
text = UnwrapElement(IN[0])


newheight = []
newtext = []
ids = []
for t in text:
	itemlist = List[ElementId](ids)

c = newtext[0].Y
p = []
for r in range(0,len(newheight)):
	if newheight [r-1] < 0.015:
		c -= 0.020
	if newheight [r-1] > 0.015:
		c -= 0.030
xyz = []
for h in p:
	xyz.append(XYZ(newtext[0].X, h, newtext[0].Z))

u = []
for d,s in zip(itemlist,xyz):
	ElementTransformUtils.MoveElement(doc, d, s)

out = []
for o in text:


OUT = xyz, out


What is your input unit? Revit API works in feet, so the XYZ in ElementTransformUtils must be in feet.

My input unit is millimetre but does that matter? The coordinates (labelled as ‘xyz’) being fed into the MoveElement line are in XYZ which is what is expected.

My bad, jumped the gun too early haha.

ElementTransformUtils returns void, also it shouldn’t change anything from your input besides the elements to move. I have run a quick test and it works well:

If it is not confidential, can you strip the Revit file and upload it with the script you are working on?

1 Like

Attached is the Revit file and dynamo script. The testing view is on sheet S00.001.

Essentially I wanted to move a bunch of text in the same position down in Y-direction accordingly.

Project1.rvt (2.3 MB)

Ok, nothing to do with units, sorry you added that bunch of converters thanks to my comment :cold_sweat:

The problem with the coordinates doubling is because you are using the modified text position in the end. Let me explain it:

  1. First you retrieve the current coordinates of the texts and store them in newtext
  2. You move the text
  3. Now you retrieve the coordinates of the moved texts (which keep the same Ids even you may think they are different elements), stored in out, and compare them to newtext

See the problem? Those two lists have to be different as you compared texts in different positions

Important to show the context of the script, we may have deducted the problem if we have seen the Select Model Elements node:

1 Like


According to the API doc ElementTransformUtils.MoveElement takes as argument a translation vector and not a position.

To set directly the location, it must be possible to do it from the Coord property (setter)

1 Like

@architectcoding @c.poupin

Ahh yes I have found the problem. I provided the coordinates of where I want them to be rather than how much I want them to move/translate by. The script is now working as it should - thank you for your help!

1 Like