Assembly modify origin

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.

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

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

7 Likes

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

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

3 Likes

Thank you!

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

12 Likes

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

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

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

1 Like

Hey Daniel,

The scripts all look good, but I cant get the last one to work or maybe I don’t quite understand what it does yet. I did get the rotate around axis one to work

Does the last script look at the element and give the assembly the same rotation as the element ? If so , if your element-input is a random element (cycled by 4 in this case) and the assembly input 4 different assemblies (with different rotations in the project) is the outcome that all 4 assemblies should have the same rotation ?

This would be awesome. homeA.dyn (25.0 KB)

1 Like

Hi Daniel,

I’ve used your node (RotateOriginAboutAxis) and it helps a lot, but know I stumbled across a problem where it looks like the set rotation isnt rotating along the assemblies location point. So the assembly-origin is rotated but is not in the same place, which means the section A and section B view of assembly dont create the views.

Can u help me or am I doing something wrong ?

For future queries, please start a new thread as this has been solved. Also, use the search engine, it will return some nice results:

1 Like

Cheers Daniel for this. I know this is an old post but the code is a massive help for a project I’m working on.

If anyone is interested I have created the script below within a form so you can create views at the same time.

3 Likes