Add List: Numbers to Text Note

I’m looking to place a text note on a sheet so that it has indented numbers before each paragraph of text. Like below:
image

This is what I currently have and what it produces.

image

image

Does anyone know of a node or something in the api that can set a text note to have numbers? Thanks.

Hi @nathaniel.g.macdonal

“String.Insert” node will get you started.

It’s doable via API. FormattedText Class

I didn’t get around to putting this in python and proving it could be run through the API due to lack of time on this project but if I do in my spare time I’ll post back on this thread. In the mean time, I think @jacob.small answered the question.

Has anyone looked into this further? Just a little help needed.

If i can just the correct way to extract the Text.Range from an input string I think we will be away…

Note I have used and int to expose the node error for clarity…


image

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

from System.Collections.Generic import *

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

#unwrap all elements to use with API
elements = []
for i in IN[0]:
	elements.append(UnwrapElement(i))

# "Start" the transaction
TransactionManager.Instance.EnsureInTransaction(doc)

#apply color override to elements in an input list
for i in elements:
	o1 = i.GetFormattedText()
	o2 = 0
	o3 = o1.SetListType(o2,"ArabicNumbers")
	
# "End" the transaction
TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable
OUT = o1,o3

Sorry, haven’t worked on it any more. Hopefully someone else is more helpful.

@Ewan_Opie Your o2 needs to be a TextRange, which in the code below I retrieve from the text note’s FormattedText with the AsTextRange() method but you can construct your own with TextRange(int,int). The only other part you were missing is to get the ListType with System.Enum.Parse (below I left it as an input but you could as well get rid of IN[1] and just have a line that says listType = System.Enum.Parse(Autodesk.Revit.DB.ListType, "ArabicNumbers")

set%20textnote%20list

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

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

from System.Collections.Generic import *

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

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

dataEnteringNode = IN

textNotes = IN[0]
listType = System.Enum.Parse(Autodesk.Revit.DB.ListType, IN[1])

if not isinstance(textNotes, list):
	textNotes = [textNotes]


TransactionManager.Instance.EnsureInTransaction(doc)

for textNote in textNotes:

	textNote = UnwrapElement(textNote)
	formatText = textNote.GetFormattedText()
	textRange = formatText.AsTextRange()
	formatText.SetListType(textRange,listType)
	textNote.SetFormattedText(formatText)
	
TransactionManager.Instance.TransactionTaskDone()

OUT = textNotes
3 Likes

As usual, works like a charm.:+1:
About time someone put all their great work into a package :wink:

2 Likes

Types:

Member name Description
Mixed This value may be returned by FormattedText.GetListType() when there are multiple list types in the selected range.
None The paragraph is not a part of a list.
Bullet The paragraph is a part of a bulleted list.
ArabicNumbers The paragraph is a part of an ordered list with Arabic number headings.
LowerCaseLetters The paragraph is a part of an ordered list with lower-case letter headings.
UpperCaseLetters The paragraph is a part of an ordered list with upper-case letter headings.