Welcome everyone for the first time!
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:
#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
from RevitServices import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
Import ToDSType(bool) extension method
angle = IN
axisX1 = IN
axisY1 = IN
axisZ1 = IN
axisX2 = IN
axisY2 = IN
axisZ2 = IN
elem = UnwrapElement( IN )
for item in IN:
nr = IN.index(item)
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_))
OUT = IN