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:
Modified Script:
import clrImport 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 TransactionManagerImport 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?
Joachim.