Assembly.SetTransform rotation


I am currently trying to amend the code with in the assembly python script.

at the moment i can select an assembly and chose its rotation. But i am trying to do this for every assembly within a project. I be leave it is the script at the very end that is the problem.

any help would be grateful.

Code within the python script:

import clr
import math
from Autodesk.DesignScript.Geometry import *

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application

import Revit

from Autodesk.Revit.DB import *

def tolist(obj1):
if hasattr(obj1,“iter”): return obj1
else: return [obj1]

elems = tolist(UnwrapElement(IN[0]))
axis = tolist(IN[1])
rot = tolist(IN[2])

outList =

for e, a, r in zip(elems, axis, rot):
trans = e.GetTransform()
transRot = trans.CreateRotationAtPoint(a.ToXyz(),math.radians®, trans.Origin)
except Exception, e:

OUT = outList

ChangeAssemblyTransform.dyn (6.0 KB)


A simple solution to your problem is to create a custom node with lacing on longest.
You can drop the custom node in you folder C:\Users\XXXi\AppData\Roaming\Dynamo\Dynamo Revit\VERSION\definitions

Assembly.SetTransform.dyf (4.4 KB)
ChangeAssemblyTransform V2.dyn (4.3 KB)

1 Like

Hi Alban,

Thank you for this. Sorry i am still very new to dynamo the one you have attached is listing all the assemblies at the end which is a good sign but i dont understand why the last assembly is the only one to change now when they are all listed after the assembly of the last node when you add a watch node to it.

thank you again for your time.

Hi Matthew,

Can you add a sample Revit file with you assemblies inside ?
I will search if I can find a solution.

Hi Alban,

Thank you. I have just created a blank project to test it out with just 4 straight lengths of pipe.

ChangeAssemblyTransform V2.dyn (4.3 KB)

Project1.rvt (332 KB)

Hi @Matthew.Latham,

You forgot to mention, but i asume you are using the Python code of @Daniel_Woodcock1 from the topic below.
Have you also seen the bottom comment ?

Changing that line of code made it work for me (on multiple elements).

Kind regards,

Hi Mark,

I believe it is i have got it to ok i believe it was that part of the code i changed.

Attached is a dynamo script i made with a windows for for use with dynamo player so people dont need to see the actual nodes.

Assembly.SetTransform.dyf (4.4 KB)
Set Assemblies Transform.dyn (17.5 KB)