Hi everybody,
I’m having some problems rotating a simple TextNote.
(I’m using Revit 2016 and Dynamo 1.2)
Any ideas ?
regards,
Dennis
Hi everybody,
I’m having some problems rotating a simple TextNote.
(I’m using Revit 2016 and Dynamo 1.2)
Any ideas ?
regards,
Dennis
Please see this: How to get help on the Dynamo forums
Dennis
picture please
so we get an idea
do you want to rotate a textnote with dynamo?
nico
Hi Nico,
That is the question!
I thought my question was so easy that it didn’t need a picture
Gr. Dennis
It could be a simple question, but since you’re having some problems in doing it and ask for ideas, please send some screenshots for further understanding. Thanks
For example, rotation of a TextNote over 30 degrees
Hi Dennis!
I’m not sure if it’s possible. Have you tried with the
ElementTransformUtils.RotateElement method?
Hi einar
i can’t find that node
or is it c# or python script
nico
There is a possibility of a rotation in textnotes creation nodes, but I didn’t find it anywhere else. So Python could be a good idea here…
Yes, you can use python or C#. Here is a simple example with python (I’m sure this script already is in someones package.) Warning: It will probably keep rotating the element for ever if it’s run in automatic mode.
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
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]
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
ElementTransformUtils.RotateElement(doc, element.Id, axis, angle)
TransactionManager.Instance.TransactionTaskDone()
OUT = 0
Thanks Einar !
I was struggeling with a similar node from the archilab (and clockwork) package (Rotate Family) and couldn’t get them to work. Your Python script works perfectly !
Thank again,
Dennis
Glad you liked it, here is a sligthly improved version where the rotation axis is calculated from the base point of the text. I also did a rad to deg conversion:
import clr
import math
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
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
#Preparing input from dynamo to revit
element = UnwrapElement(IN[0])
angle = IN[1]*math.pi/180
#calculte rotation axis:
baseVector = element.BaseDirection
upVector = element.UpDirection
normalVector = baseVector.CrossProduct(upVector)
axis = Line.CreateUnbound(element.Coord, normalVector)
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
ElementTransformUtils.RotateElement(doc, element.Id, axis, angle)
TransactionManager.Instance.TransactionTaskDone()
OUT = 0
Hi Einar, is there anyway to format the python script to accept lists? My goal is to essentially rotate numerous pieces of text all at once and I cant figure out how to change the script to accept the list. My goal is to create text along a curve but the text by location node doesn’t work within the family I’m editing for some reason so I have to use textnote.byviewpointandtype and it doesn’t have a rotation option so I tried to use some of the other rotate nodes and none of them work and I stumbled across this post which was very helpful but I was unable to use a list of text notes with a list of degrees to set.
Thanks,
Felix
You can either use a for loop in the python script, or create a new custom node that contains the python script.
I put the python script into a node but it still wasn’t able to use a list and I tried it with both versions posted. I’m still pretty new with the python so I’m not sure how I’m supposed to get it to loop through a list.
I know that this is an old post but I’m interested it trying to get the for loop to work. I’m confused as to where it needs to go to get lists to work. I’ve tried this with null results.
import clr
import math
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
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
#Preparing input from dynamo to revit
element = UnwrapElement(IN[0])
angle = IN[1]*math.pi/180
#calculte rotation axis:
#for angle in angle:
# baseVector = element.BaseDirection
# upVector = element.UpDirection
# normalVector = baseVector.CrossProduct(upVector)
# axis = Line.CreateUnbound(element.Coord, normalVector)
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
for element,angle in (element,angle):
baseVector = element.BaseDirection
upVector = element.UpDirection
normalVector = baseVector.CrossProduct(upVector)
axis = Line.CreateUnbound(element.Coord, normalVector)
ElementTransformUtils.RotateElement(doc, element.Id, axis, angle)
TransactionManager.Instance.TransactionTaskDone()
OUT = 0
I’ve also tried this: Still nothing, but I think I’m closer. From this thread using Kulkul’s example it seems like a need to used the for loop to create a list for the rotate command to use. In this case I would need three: element, axis, and angle.
https://forum.dynamobim.com/t/move-text-notes-by-cordinates/17113/13
import clr
import math
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
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
#Preparing input from dynamo to revit
element = UnwrapElement(IN[0])
angle = IN[1]
#element list
ids = list()
for element in element:
ids.append(item.Id)
elementlist = List[ElementId](ids)
#angle list
anglelist = list()
for angle in angle:
anglelist.append(angle*math.pi/180)
#calculte rotation axis:
axis = list()
for axis in angle:
baseVector = element.BaseDirection
upVector = element.UpDirection
normalVector = baseVector.CrossProduct(upVector)
axis.append(Line.CreateUnbound(element.Coord, normalVector))
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
ElementTransformUtils.RotateElement(doc, elementlist, axis, anglelist)
TransactionManager.Instance.TransactionTaskDone()
OUT = 0
Here is what the custom node looks like:
Hi Cody,
If you want to loop two lists simultaneously you need to use zip() function like this:
for element,angle in zip(elements, angles):
are the two list of equal length?
Yes they are the same length. I’ve actually found a node that will take rotation as an input when creating note but I’d still like to know so I could understand python a bit better. I later found the zip code but still couldn’t get it to work. maybe it was something with my input. I’m thinking that the rotation needs to be a double instead of var?
Hi Einar,
Thank you for the script. How can I use it with multipe elements selected? The python nod shows the following error message:
IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 26, in
AttributeError: ‘List[object]’ object has no attribute ‘BaseDirection’
Since people were asking about the python code for multiple text rotations, I modified this python code to accept lists:
import clr
import math
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
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
#Preparing input from dynamo to revit
element = []
for i in UnwrapElement(IN[0]):
element.append(i)
angle = IN[1]*math.pi/180
#calculte rotation axis:
baseVector = []
upVector = []
for i in element :
baseVector.append(i.BaseDirection)
upVector.append(i.UpDirection)
normalVector = []
for i,j in zip(baseVector,upVector):
normalVector.append(i.CrossProduct(j))
axis = []
for i,j in zip(element,normalVector) :
axis.append(Line.CreateUnbound(i.Coord,j))
#Do some action in a Transaction
for i,j in zip(element, axis) :
TransactionManager.Instance.EnsureInTransaction(doc)
ElementTransformUtils.RotateElement(doc, i.Id, j, angle)
TransactionManager.Instance.TransactionTaskDone()
OUT = element