How to Place Annotation Texts at Specific Coordinates in a Revit View Using Dynamo Chiedi a ChatGPT

Hello,

I’m working on placing annotation texts in a Revit view using Dynamo. I have a list of texts and their corresponding X and Y coordinates, and I want to position these texts accurately in a specific view.

Could you please help me understand the best way to create and place these annotation texts at the given coordinates within the desired view?

Thank you in advance for your assistance!

import clr

clr.AddReference(‘RevitServices’)

from RevitServices.Persistence import DocumentManager f

rom RevitServices.Transactions import TransactionManager

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

doc = DocumentManager.Instance.CurrentDBDocument

texts_pilastri = IN[0]

x_pilastri = IN[1]

y_pilastri = IN[2]

texts_muri = IN[3]

x_muri = IN[4]

y_muri = IN[5]

view_input = IN[6]

if not isinstance(view_input, View): OUT = “Errore: IN[6] non è una vista valida”

else:
view = view_input
created_notes =
def create_texts(texts, xs, ys):
result =
for i in range(len(texts)):
try:
pt = XYZ(float(xs[i]), float(ys[i]), 0)
note = TextNote.Create(doc, view.Id, pt, str(texts[i]), TextNoteType.GetDefaultTextNoteTypeId(doc))
result.append(note)
except: result.append(None) return result

TransactionManager.Instance.EnsureInTransaction(doc)
created_notes += create_texts(texts_pilastri, x_pilastri, y_pilastri) created_notes += create_texts(texts_muri, x_muri, y_muri)
TransactionManager.Instance.TransactionTaskDone()
OUT = created_notes

Hi, @gabriele.potenza1

  • Format your code with the </> button
  • Add screenshots of your dynamo graph and the error
  • Read this documentation about DynamoPython and wrapping of Revit objets
1 Like

I solved by using TextNote.ByLocation. I forgot its existence. Thank you!