Assembly modify origin


#1

Hi,

I have a problem with the origin orientation of assemblies created. This orientation is affecting all the assemblies views created because the elevations and plan views will not align with the elements main face(normal). Is there a way in dynamo to get the origin and alight the orientation with the wall orientation that is part of the assembly?

autodesk is saying as below but it would be a pain to edit all assemblies and do it manually…

When i do it manually, the elevations and the plan view orientation is looking ok.

Thank you.
J.


Assembly: modify origin (Part 2)
#2

Hi John,

This is a very interesting topic.

I really hope this can be done by Dynamo (a little Python magic maybe).
If the rotation of the elements could be added as input to the assembly (steam)nodes of @Julien_Benoit1, would be the best option if you’d ask me.
Hope someone crack’s this one.

Kind regards,
Mark


#3

Hi @john1/@MJB-online,

Sure is possible, here is a python script I quickly threw together that allows you specify the rotation (in degrees)…

import clr
import math
clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc =  DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitAPI")
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(r), trans.Origin)
	try:
		TransactionManager.Instance.EnsureInTransaction(doc)
		e.SetTransform(transRot)
		TransactionManager.Instance.TransactionTaskDone()
		outList.append(e)
	except Exception, e:
		outList.append(e.message)
		
OUT = outList

ChangeAssemblyTransform.dyn (6.0 KB)

Cheers,
Dan


#4

Hi Daniel,

Wow… this is great, thank you very much.
An Assembly is a great tool for manufacturers who create their shopdrawings this way.
And that’s why i really don’t understand the family/element rotation isn’t done by Revit on default.
But this is a great way to change it afterwards.

Does the script only work for one element, or does it allow input of a list aswell.
Thanks again.

Kind regards,
Mark


#5

You’re welcome @MJB-online,

The script handles multiple assemblies, but list lengths for each input have to be the same, you can use the list.cycle node if you have a common input value (say the rotation axis will in most cases be the Z azis).

This doesn’t automate the rotation angle, I have left that to be done with your own logic outside of the node as it give you more freedom to choose which direction you want it.

You could couple this up with any create assembly node that returns the assembly just created in Dynamo and rotate the transform in one hit.

Hope you find it useful.

Cheers,
Dan


#6

Thank you!


#7

All,

For completeness (as I really didnt fully answer the Question as I was pushed for time) I have added a few additional nodes in this script to help modifying the Assemblies Transform. These include the following Post Assembly Creation Utils:-

  • RotateOriginAboutAxis (as above)
    ** Rotates the Assemblies Transform about the specified Axis by the specified Rotation in degrees.
  • OrientToFace
    ** Orient/Relocates the Assemblies Transform to the Location of a Point on the Given Surface.
  • OrientToPlane
    ** Orient/Relocates the Assemblies Transform to the Location of a Point on the Given Plane.
  • MatchTransform
    ** Matches the Assemblies Transform to the Transform of another Element. @john1, this will probably be more suitable for your case.

AssemblyUtils.dyn (28.1 KB)

Hope these come in handy. :slight_smile:

Cheers,
Dan


Can't modify multiple assembly origins via python, only one at a time
Select Revit Element by Face
First attempt Editing a Python script
#8

Hi Dan,

That’s even more than we wished for.
Thanks a lot.
I think the first is the best for me, but i certainly gone play whith the others as well.

Kind regards,
Mark


#9

Cool. Glad to help. Let me know how they go :blush:


#10

Hi all,

If you don’t succeed to use the above scripts on a list of elements, you could try replacing “TransactionTaskDone” by “ForceCloseTransaction”.
Or check the below topic.
https://forum.dynamobim.com/t/first-attempt-editing-a-python-script/19156?u=mjb-online

Kind regards,
Mark


Assembly.SetTransform rotation