Formatting Text with New Paragraph and Bullet List

I’m still learning python, please excuse my uselessness.

I’m trying to take a piece of text and split it by using a string I’ve inserted at the starts of bullets in word. The method I’m using to get this text is not recognizing the formatting so I am going through the text I create and formatting it by looking for patterns or adding markers if needed.

I’m combining the bullets points so I can calculate how much space they require on the sheet and so Dynamo will treat it as one note block. This means bullet lists will not be split between multiple columns on our spec sheets.

We have multiple bullet lists in our spec. I have a for loop for this reason. I’m removing the first “[LIST]” string because it is not needed. After that I’m trying to use a while loop to check for additional “[LIST]” strings and add a “\r” string to start a new paragraph. I then wan to turn every paragraph into a bullet list.

It is not throwing errors, but as you can see, it is also not replacing the marker string with a new paragraph.

import clr
from Autodesk.Revit.DB import *

import Revit

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
textInput = IN[0]

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


for listGroup in textInput:
	listGroup = UnwrapElement(listGroup)
	formatText = listGroup.GetFormattedText()
	listSearch = False
	while listSearch == False:
		listRange = formatText.Find("[LIST]",0,True,True)
		if listRange.Length > 0:
			listSearch = True
	textRange = formatText.AsTextRange()


OUT = textInput


I looked at the arguments again for the Find method and I realized I misread the second Boolean. Because I just concatenated the strings the “[LIST]” string was not its own word. I changed it to false and it worked.