# Moving multiple elements in XYZ

**URL:** <https://forum.dynamobim.com/t/moving-multiple-elements-in-xyz/75731>\
**Category:** Revit\
**Tags:** revit, python, dynamo\
**Created:** [April 22, 2022, 9:44am UTC](https://forum.dynamobim.com/t/moving-multiple-elements-in-xyz/75731 "2022-04-22T09:44:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![status\_diamond](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@status\_diamond](https://forum.dynamobim.com/u/status_diamond)\
**Post date:** [April 22, 2022, 9:44am UTC](https://forum.dynamobim.com/t/moving-multiple-elements-in-xyz/75731/1 "2022-04-22T09:44:20Z")

</div>

Good afternoon

I found a python script on the Internet.

```auto
import clr

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#The inputs to this node will be stored as a list in the IN variable.
doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application

dataEnteringNode = IN
elementId = IN[0].Id

TransactionManager.Instance.EnsureInTransaction(doc)
ElementTransformUtils.MoveElement(doc,ElementId(elementId),XYZ(IN[1],IN[2],IN[3]))
TransactionManager.Instance.TransactionTaskDone()

# Assign your output to the OUT variable.
OUT = 0

```

This script works wonderfully if IN[0] is given one element.

How to make it work when multiple elements are fed into the input?

 ![Снимок](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/6/764bd2b94af8d7b7832b99d07f35fb71f440fd3c.jpeg)

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [April 22, 2022, 9:55am UTC](https://forum.dynamobim.com/t/moving-multiple-elements-in-xyz/75731/2 "2022-04-22T09:55:16Z")

</div>

Hi @status_diamond ,

The easiest way to solve this is by wrapping the Python script into a Custom Node.  
Then you just have to set the Custom Node input to @L2.

---

<div class="post-metadata">

**Author:** ![status\_diamond](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@status\_diamond](https://forum.dynamobim.com/u/status_diamond)\
**Post date:** [April 22, 2022, 10:44am UTC](https://forum.dynamobim.com/t/moving-multiple-elements-in-xyz/75731/3 "2022-04-22T10:44:54Z")

</div>

Do you know Custom Node for moving elements along XYZ? I can’t find. Thanks.

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [April 22, 2022, 11:01am UTC](https://forum.dynamobim.com/t/moving-multiple-elements-in-xyz/75731/4 "2022-04-22T11:01:39Z")

</div>

I meant that you’ll have to do that yourself.

However, for just moving elements you don’t need a custom Python script, just the Element.Location / Element.SetLocation nodes. Just make sure the new location is the old location + your translation.

---

<div class="post-metadata">

**Author:** ![status\_diamond](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@status\_diamond](https://forum.dynamobim.com/u/status_diamond)\
**Post date:** [April 22, 2022, 11:55am UTC](https://forum.dynamobim.com/t/moving-multiple-elements-in-xyz/75731/5 "2022-04-22T11:55:35Z")

</div>

I have already tried to move elements by changing their coordinates. But each element has its own parameter responsible for its position.  
Plus, with simple nodes like this Element.Location / Element.SetLocation problem is not solvable.

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [April 22, 2022, 12:06pm UTC](https://forum.dynamobim.com/t/moving-multiple-elements-in-xyz/75731/6 "2022-04-22T12:06:05Z")

</div>

I see,

Check out this guide on how to create a Custom Node:  
[https://primer.dynamobim.org/10\_Custom-Nodes/10\_Custom-Nodes.html](https://primer.dynamobim.org/10_Custom-Nodes/10_Custom-Nodes.html)

---

<div class="post-metadata">

**Author:** ![stewart.skyler](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@stewart.skyler](https://forum.dynamobim.com/u/stewart.skyler)\
**Post date:** [April 23, 2022, 7:08am UTC](https://forum.dynamobim.com/t/moving-multiple-elements-in-xyz/75731/7 "2022-04-23T07:08:39Z")

</div>

Try this

```auto
import clr

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#The inputs to this node will be stored as a list in the IN variable.
doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application

dataEnteringNode = IN

def tolist(obj):
	if hasattr(obj, " __iter__"):
		return obj
	else:
		return [obj]

elems = tolist(IN[0])
elems = [UnwrapElement(x) for x in elems]

TransactionManager.Instance.EnsureInTransaction(doc)
[ElementTransformUtils.MoveElement(doc,e.Id,XYZ(IN[1],IN[2],IN[3])) for e in elems]
TransactionManager.Instance.TransactionTaskDone()

# Assign your output to the OUT variable.
OUT = 0

```

---

<div class="post-metadata">

**Author:** ![status\_diamond](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@status\_diamond](https://forum.dynamobim.com/u/status_diamond)\
**Post date:** [April 25, 2022, 12:44pm UTC](https://forum.dynamobim.com/t/moving-multiple-elements-in-xyz/75731/8 "2022-04-25T12:44:38Z")

</div>

Thanks! It works!

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [April 25, 2022, 6:40pm UTC](https://forum.dynamobim.com/t/moving-multiple-elements-in-xyz/75731/9 "2022-04-25T18:40:55Z")

</div>

> [@stewart.skyler](#):
>
> `[ElementTransformUtils.MoveElement(doc,e.Id,XYZ(IN[1],IN[2],IN[3])) for e in elems]`

we can use directly this method for a list of element

- ElementTransformUtils.MoveElement **s**

> **[MoveElements Method](https://www.revitapidocs.com/2015/3cf8c9dc-f4d1-12f0-d7a9-e126331cd858.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018

---

<div class="post-metadata">

**Author:** ![stewart.skyler](https://avatars.discourse-cdn.com/v4/letter/s/ccd318/32.png) [@stewart.skyler](https://forum.dynamobim.com/u/stewart.skyler)\
**Post date:** [April 25, 2022, 11:45pm UTC](https://forum.dynamobim.com/t/moving-multiple-elements-in-xyz/75731/10 "2022-04-25T23:45:16Z")

</div>

Ah, yeah, fair enough!
