How do you rotate around a specified center of rotation?

Hi everyone,

Does anyone know of any nodes or methods to rotate Revit elements and change their center of rotation?

I currently am trying to do some model positioning coordination that utilizes origin to origin placement on the survey point coordinate system and I’ve got it to work with the exclusion of correctly orienting projects with modified project north values.

I simply need to rotate the whole link instance around the project position point given the known “angle from project north” value.

Additionally, I am really opposed to the idea of turning my linked models into family instances because that’s more work than just doing this process manually.

For those of you wondering, I am not using a shared coordinate system because our models have to utilize more than one survey point due to the size of our site.

-Thanks

It looks like setting the center of rotation isn’t accessible in the API :confused:.
Does any one have any other ideas?

Hi @L.Cunningham

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

from System.Collections.Generic import *
import math

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#Preparing input from dynamo to revit
element = UnwrapElement(IN[0])
axis = IN[1].ToRevitType(True)
angle = (IN[2]*math.pi)/180
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
ElementTransformUtils.RotateElement(doc, element.Id, axis, angle)
TransactionManager.Instance.TransactionTaskDone()
OUT = element
4 Likes

Thanks @Kulkul that worked out great.

EDIT: For those of you who may want the full graph, here it is, the Python script is obviously the one from the previous reply with no changes made :slight_smile:

-Thanks

Hi @Kulkul I am getting this error.

Can you please help me out for this ?

I have the same issue.

import clr

clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *

from System.Collections.Generic import *
import math

clr.AddReference(‘RevitNodes’)
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference(‘RevitServices’)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

Preparing input from dynamo to revit

element = UnwrapElement(IN[0])
axis = IN[1].ToRevitType(True) if IN[1] is not None else None
angle = (IN[2] * math.pi) / 180 if IN[2] is not None else None

Debugging: Print input values

print("Element: ", element)
print("Axis: ", axis)
print("Angle: ", angle)

if element is None:
raise ValueError(“Input element is None”)
if axis is None:
raise ValueError(“Input axis is None”)
if angle is None:
raise ValueError(“Input angle is None”)

Do some action in a Transaction

TransactionManager.Instance.EnsureInTransaction(doc)
ElementTransformUtils.RotateElement(doc, element.Id, axis, angle)
TransactionManager.Instance.TransactionTaskDone()

OUT = element

Use follow python code it might help you out