Strange movements of elements during performing Elements.Rotate (modified)

Welcome everyone for the first time! :slight_smile:

I am struggling some weird movements of elements during performing modified custom node Elements.Rotate.

So, here is the general idea of Dynamo script:

1)Create pipework divided by 6m pipelength along tunnel 3D curve (works fine).
2)Insert grooved couplings between pipes and rotate them horizontaly to match pipework layout (works fine).
3)Rotate mentioned above couplings verticaly (arround their local X-axis) (does not work).

I tried many nodes to achieve that, (FamilyInstance.SetRotation, Elements.Rotate, Elements.RotateByAxisByAngle etc…) - I failed every time.

So I decided to modify Elements.Rotate to adjust that node to my need which is: rotate LIST of elements by LIST of angles by LIST of axis created by LIST of start and end points, but I am not sure if I did sth wrong. Script performs rotation of family instances but, simultaneously moves them to strange places in space. I am dealing with it for now by bringing them back on place after performed rotation, but I am aware that this is not a solution… FYI: I don’t know Python at all.

See screenshot belows:

Modified Script:

import clr

Import RevitAPI

clr.AddReference(“RevitAPI”)
import Autodesk
#from Autodesk.Revit.DB import ReferencePointArray
from Autodesk.Revit.DB import ElementTransformUtils
from Autodesk.Revit.DB import Line
from Autodesk.Revit.DB import Transaction
from Autodesk.Revit.DB import ElementId
from Autodesk.Revit.DB import XYZ
#from Autodesk.Revit import *

Import DocumentManager and TransactionManager

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

Import ToDSType(bool) extension method

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)

angle = IN[1]
axisX1 = IN[2]
axisY1 = IN[3]
axisZ1 = IN[4]
axisX2 = IN[5]
axisY2 = IN[6]
axisZ2 = IN[7]

changelist =

Unwrap

elem = UnwrapElement( IN[0] )

for item in IN[0]:
nr = IN[0].index(item)

Start Transaction

doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)

Make changes in model

#axis = NewLineBound(point (0, 0, 0), point (0, 0, 1))

#for elem_, angle_, axisX_, axisY_, axisZ_ in zip(elem, angle, axisX, axisY, axisZ):
axisX1_ = axisX1[nr]
axisY1_ = axisY1[nr]
axisZ1_ = axisZ1[nr]
axisX2_ = axisX2[nr]
axisY2_ = axisY2[nr]
axisZ2_ = axisZ2[nr]
elem_ = elem[nr]
angle_ = angle[nr]

axis = Line.CreateBound( XYZ(axisX1_, axisY1_, axisZ1_), XYZ(axisX2_, axisY2_, axisZ2_))
changelist.append(ElementTransformUtils.RotateElement(doc, elem_.Id, axis, angle_))

End Transaction

TransactionManager.Instance.TransactionTaskDone()

exit

OUT = IN[0]

Any ideas? :slight_smile:

Joachim.

I don’t have much time to dig into python at this moment (the package called Basic_Python_Template could help), but we have struggled many times with family instances rotation on the forum. I ended up using FamilyInstance.ByFace and it could worth a try. See here:

Hi Yna_Db!

I tried what you suggested, but it appears that Dynamo struggles with reading faces of auxiliary elements (see screenshot below). Did you ever get such error dialog box?

DYNAMO2

Regards, Joachim

It didn’t happen at that time but I can see that increasing the diameter of the circles to 16 minimum is now necessary, don’t ask me why today… :slight_smile:

1 Like