# Confusing result ElementTransformUtils API class

**URL:** <https://forum.dynamobim.com/t/confusing-result-elementtransformutils-api-class/95244>\
**Category:** Revit\
**Tags:** python\
**Created:** [November 6, 2023, 9:13pm UTC](https://forum.dynamobim.com/t/confusing-result-elementtransformutils-api-class/95244 "2023-11-06T21:13:27Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [November 6, 2023, 9:13pm UTC](https://forum.dynamobim.com/t/confusing-result-elementtransformutils-api-class/95244/1 "2023-11-06T21:13:27Z")

</div>

Hello,  
One of you could test if you get the same result.  
I can’t identify the cause

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/b/cbf3f75c5e18d5adb3acbd58f5184be2251227b9.png)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/a/7a03f8486d47b854428a43eae5621094c6e2ebf6.png)

I am using Revit 2023.1  
and under DynamoRevit 2.16.1.6510

I attached file + script  
[Fichier Test.rvt](https://forum.dynamobim.com/uploads/short-url/nXceJzlX7A4EEYqsNt9LS5gxHpw.rvt) (2.4 MB)  
[test\_to\_see.dyn](https://forum.dynamobim.com/uploads/short-url/ladrzO3tuH1rSrT2wVqpXbGhOWV.dyn) (23.0 KB)

> **Code Python**
>
> ```auto
> import clr
> import sys
> import math
> 
> clr.AddReference('ProtoGeometry')
> from Autodesk.DesignScript.Geometry import *
> clr.AddReference("RevitNodes")
> import Revit
> clr.ImportExtensions(Revit.Elements)
> clr.ImportExtensions(Revit.GeometryConversion)
> clr.AddReference("RevitServices")
> import RevitServices
> from RevitServices.Persistence import DocumentManager 
> from RevitServices.Transactions import TransactionManager 
> 
> clr.AddReference("RevitAPI")
> clr.AddReference("RevitAPIUI")
> 
> import Autodesk 
> from Autodesk.Revit.DB import *
> from Autodesk.Revit.UI import *
> 
> doc = DocumentManager.Instance.CurrentDBDocument
> uiapp = DocumentManager.Instance.CurrentUIApplication 
> app = uiapp.Application 
> uidoc = uiapp.ActiveUIDocument
> 
> #######OK NOW YOU CAN CODE########
> elt=UnwrapElement(IN[0])
> ang=IN[1]
> def r_cent_l(i,a):
> loc=i.Location.Point
> Line_axis=Line.CreateBound(loc,XYZ(loc.X,loc.Y,1))
> TransactionManager.Instance.EnsureInTransaction(doc)
> ElementTransformUtils.RotateElement(doc,i.Id,Line_axis,math.pi*a/180)
> TransactionManager.Instance.TransactionTaskDone()
> 
> z=[r_cent_l(e,ang) for e in elt]
> OUT = z
> 
> ```

I thank you in advance  
Sincerely  
christian.stan

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [November 6, 2023, 9:38pm UTC](https://forum.dynamobim.com/t/confusing-result-elementtransformutils-api-class/95244/2 "2023-11-06T21:38:19Z")

</div>

What is the location point of the family in question?  
Which way is ‘up’?  
Note that wrapping a transaction in a definition may create some performance issues, though I haven’t tested myself.

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [November 6, 2023, 9:48pm UTC](https://forum.dynamobim.com/t/confusing-result-elementtransformutils-api-class/95244/3 "2023-11-06T21:48:49Z")

</div>

THANKS,  
To answer you (5cm or 0.05m to the left)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/e/9e92dbe80dc3398530b387a760d33489db043c60.png)

this is the 1st element of the series which is placed in a disorderly manner  
when it is part of a process.

if the elements are already in place I have no problem

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [November 6, 2023, 10:40pm UTC](https://forum.dynamobim.com/t/confusing-result-elementtransformutils-api-class/95244/4 "2023-11-06T22:40:13Z")

</div>

Where is the drawing’s internal origin and X/Y axis? (Relative to the wall which is placing our of position)

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [November 6, 2023, 10:56pm UTC](https://forum.dynamobim.com/t/confusing-result-elementtransformutils-api-class/95244/5 "2023-11-06T22:56:31Z")

</div>

Hoping not to go off topic in the answer

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/3/e360634d546ba9af491054171f8c46ff1dab4476.png)

cordially  
christian.stan

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [November 6, 2023, 11:20pm UTC](https://forum.dynamobim.com/t/confusing-result-elementtransformutils-api-class/95244/6 "2023-11-06T23:20:20Z")

</div>

I have to add a transaction end before the Python node

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/a/5ab1070ac68619a170506834bc746f45a2a9df06.png)  
to avoid this inconvenience (from the 1st object placed in a “strange” way)  
but I get multiple routines launched in this case (weird)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/2/c211cc98abfa799cac4a2a2db7a3edd9c8dca47f.png)  
I’m taking up a little too much of your time, thank you for trying to solve it.  
cordially  
christian.stan

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [November 6, 2023, 11:21pm UTC](https://forum.dynamobim.com/t/confusing-result-elementtransformutils-api-class/95244/7 "2023-11-06T23:21:51Z")

</div>

Draw Dynamo point at the origin and display it in the Revit preview. My thought is that the family is rotating about the origin as this is kind of in one transaction…

---

<div class="post-metadata">

**Author:** ![gerhard.p](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gerhard.p/32/147675_2.png) [@gerhard.p](https://forum.dynamobim.com/u/gerhard.p)\
**Post date:** [November 6, 2023, 11:32pm UTC](https://forum.dynamobim.com/t/confusing-result-elementtransformutils-api-class/95244/8 "2023-11-06T23:32:54Z")

</div>

> [@jacob.small](#):
>
> the family is rotating about the origin

Yes

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/e/3e65ec098efdbb518e7018bfe9faab689bff14cc.png)

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [November 6, 2023, 11:35pm UTC](https://forum.dynamobim.com/t/confusing-result-elementtransformutils-api-class/95244/9 "2023-11-06T23:35:56Z")

</div>

I tried to implement your idea  
(I think I still have to work on the transactions side, I still have some gray areas)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/c/4ca05969e28e724212e2036960e664ef8f67d739.png)

THANKS  
Have a good evening  
Sincerely  
christian.stan

---

<div class="post-metadata">

**Author:** ![gerhard.p](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gerhard.p/32/147675_2.png) [@gerhard.p](https://forum.dynamobim.com/u/gerhard.p)\
**Post date:** [November 6, 2023, 11:40pm UTC](https://forum.dynamobim.com/t/confusing-result-elementtransformutils-api-class/95244/10 "2023-11-06T23:40:25Z")

</div>

Try this 🙂

```auto
doc.Regenerate()
z=[r_cent_l(e,ang) for e in elt]
OUT = z

```

Had a similar problem not a long time ago.

> [@Adaptive Family - Transform Troubles](https://forum.dynamobim.com/t/adaptive-family-transform-troubles/93980/12):
>
> So I think this is just how transforms work, you have to do a rotation and translation. Trying to put this all in one python node gave me the same problems, I had to run the code twice with commented out rotation/transaltion to make it work, but now i found the root of all evil: The key to success is doc.Regenerate() smiley All working fine now! Thanks for the help! import clr import sys sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib') import System from System import Array fro…

---

<div class="post-metadata">

**Author:** ![gerhard.p](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gerhard.p/32/147675_2.png) [@gerhard.p](https://forum.dynamobim.com/u/gerhard.p)\
**Post date:** [November 6, 2023, 11:43pm UTC](https://forum.dynamobim.com/t/confusing-result-elementtransformutils-api-class/95244/11 "2023-11-06T23:43:34Z")

</div>

Also works this way:

```auto
TransactionManager.Instance.ForceCloseTransaction()
z=[r_cent_l(e,ang) for e in elt]
OUT = z

```

I´m often having troubles with placing and rotating though, I sometimes have to place, rotate, translate back to make it work…

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [November 6, 2023, 11:48pm UTC](https://forum.dynamobim.com/t/confusing-result-elementtransformutils-api-class/95244/12 "2023-11-06T23:48:26Z")

</div>

Hi, This method no, but I will keep the doc.Regenerate()  
THANKS

sincerely  
christian.stan

---

<div class="post-metadata">

**Author:** ![gerhard.p](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gerhard.p/32/147675_2.png) [@gerhard.p](https://forum.dynamobim.com/u/gerhard.p)\
**Post date:** [November 7, 2023, 1:56am UTC](https://forum.dynamobim.com/t/confusing-result-elementtransformutils-api-class/95244/13 "2023-11-07T01:56:03Z")

</div>

Hey @christian.stan,

both methods work, because of this:

> Note that when a transaction is committed there is an automatic call to regenerate the document.

> **[Regenerate Method](https://www.revitapidocs.com/2016/22468e2c-9772-8478-0816-c9759aa43428.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018

So somehow the transaction from placing the families is still open and , as you also showed with nodes, you just have to close it.

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [November 7, 2023, 2:51am UTC](https://forum.dynamobim.com/t/confusing-result-elementtransformutils-api-class/95244/14 "2023-11-07T02:51:28Z")

</div>

I did some trials - the first placed instance of the family appears to have the Location set to 0, 0, 0 while inside the transaction when using the dynamo Family Instance node or with `doc.Create.NewFamilyInstance()` in python

If you use the Dynamo points as the location for the rotation axis it works ¯\_(ツ)\_/¯

And discovered the `Element.Location.Rotate(axis, radians)` method exists
