Hi all!
I am trying to copy a text from one sheet to multiple sheets so that it will be set with the same format.
When applying TextNot.ByLocation it copies the text but not the format.
I am trying to write a python script but I keep getting an error.
import clr
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument
points = IN[0] if isinstance(IN[0],list) else [IN[0]]
ogText = UnwrapElement(IN[1])
text = IN[2]
viewId = uidoc.ActiveView.Id
formText = ogText.GetFormattedText()
#Begin transaction
try:
TransactionManager.Instance.EnsureInTransaction(doc)
newTexts = []
for p in points:
textOpt = TextNoteOptions()
xyz = p.ToXyz(True)
newText = TextNote.Create(doc,viewId,xyz,text,textOpt)
newText.SetFormattedText(formText)
newTexts.append(newText)
#End transaction
finally:
TransactionManager.Instance.TransactionTaskDone()
OUT = newTexts
With this script I am trying get the format of existing text using the GetFormattedText(), create a text and then set the format using SetFormattedText.
I am getting the following error:
I tried inputing the formText(.GetFormattedText()) instead of TextNoteOptions in the Create method as chatgpt suggests but still am getting error…