Hi all,
While trying to rotate a line I’m not able to set the center for rotation (pt
in my case instead of XYZ(0,0,pt.Z)
). Any suggestion?
pt = UnwrapElement(IN[0]).ToRevitType()
myLine = Line.CreateBound(XYZ(0,0,pt.Z), pt)
angle = math.radians(90)
rotationTransform = Transform.CreateRotation(XYZ(0,0,1), angle)
rotatedLine = myLine.CreateTransformed(rotationTransform)
OUT = pt, myLine.ToProtoType(), rotatedLine.ToProtoType()
Hey,
See if this helps…
#thanks Konrad
#thanks Konrad
import clr
import System
from System import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
# Place your code below this line
element = UnwrapElement(IN[0])
angle = IN[1]
RotateAngle = angle*Math.PI/180;
output = []
#catch anything that doesn't work and output the error
try:
errorReport = None
#begin transaction
TransactionManager.Instance.EnsureInTransaction(doc)
locationCurve = element.Location
curve = locationCurve.Curve
point1 = curve.GetEndPoint(0)
point2 = curve.GetEndPoint(1)
#midPoint = (point1 + point2) / 2
#midHigh = midPoint.Add(XYZ.BasisZ)
midHigh = point1.Add(XYZ.BasisZ)
#axisLine = Autodesk.Revit.DB.Line.CreateBound(midPoint, midHigh)
axisLine = Autodesk.Revit.DB.Line.CreateBound(point1, midHigh)
output.append(locationCurve.Rotate(axisLine, RotateAngle))
#end transaction
TransactionManager.Instance.TransactionTaskDone()
# Assign your output to the OUT variable.
except:
import traceback
errorReport = traceback.format_exc()
if errorReport == None:
OUT = output
else:
OUT = errorReport
2 Likes