Rotation of a TextNote

#1

Hi everybody,

I’m having some problems rotating a simple TextNote.
(I’m using Revit 2016 and Dynamo 1.2)

Any ideas ?

regards,
Dennis

0 Likes

Multiple texts rotation
#2

Please see this: How to get help on the Dynamo forums

0 Likes

#3

Dennis

picture please
so we get an idea

do you want to rotate a textnote with dynamo?

nico

0 Likes

#4

Hi Nico,
That is the question!
I thought my question was so easy that it didn’t need a picture :slight_smile:
Gr. Dennis

0 Likes

#5

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 :slight_smile:

0 Likes

#6

For example, rotation of a TextNote over 30 degrees

0 Likes

#7

Hi Dennis!

I’m not sure if it’s possible. Have you tried with the 
ElementTransformUtils.RotateElement method?

0 Likes

#8

Hi einar

i can’t find that node

or is it c# or python script

nico

0 Likes

#9

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…

0 Likes

#10

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
3 Likes

#11

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

0 Likes

#12

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
6 Likes

#13

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

0 Likes

#14

You can either use a for loop in the python script, or create a new custom node that contains the python script.

0 Likes

#15

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.

0 Likes