I am trying to used the Revit Interactive Python Shell to rotate an object in Revit. I am hung up on how to designate the axis of rotation. I don't know how to create a line with the API and then designate an axis in ElementTransformUtils.RotateElement()
The third argument in RotateElement() is the axis. I am creating a line but I am not sure if I am designating its axis in the third argument of .RotateElement()
When I run this code nothing happens. This is even the case if I have a wall selected. Please let me know if anything needs clarification.
Thanks,
import clr
import math
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
def pickobject():
from Autodesk.Revit.UI.Selection import ObjectType
__window__.Hide()
picked = uidoc.Selection.PickObject(ObjectType.Element)
__window__.Show()
__window__.Topmost = True
return picked
#set the active Revit application and document
app = __revit__.Application
doc = __revit__.ActiveUIDocument.Document
#define a transaction variable and describe the transaction
t = Transaction(doc, 'This is my new transaction')
#start a transaction in the Revit database
t.Start()
#perform some action here...
el = pickobject()
p1 = XYZ(0,0,0)
p2 = XYZ(0,0,1)
myLine = Line.CreateBound(p1, p2)
ElementTransformUtils.RotateElement(doc, el.ElementId, myLine, math.pi / 2)
#commit the transaction to the Revit database
t.Commit()
#close the script window
__window__.Close()
It turns out I wasn't properly selecting an element or converting degrees to radians. After doing these things I was able to make my selected element rotate 90 degrees. The only problem I face now is choosing the origin at which the element rotates.
I think what you're doing wrong is the angle. This needs to be in radians. In your example that would be π/2. See here