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 clr.AddReference('RevitAPI') from Autodesk.Revit.DB 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 doc = DocumentManager.Instance.CurrentDBDocument textInput = IN if not isinstance(textInput, list): textInput = [textInput] TransactionManager.Instance.EnsureInTransaction(doc) for listGroup in textInput: listGroup = UnwrapElement(listGroup) formatText = listGroup.GetFormattedText() formatText.SetPlainText(TextRange(0,6),"") listSearch = False while listSearch == False: listRange = formatText.Find("[LIST]",0,True,True) if listRange.Length > 0: formatText.SetPlainText(listRange,"\r") else: listSearch = True textRange = formatText.AsTextRange() formatText.SetListType(textRange,ListType.Bullet) listGroup.SetFormattedText(formatText) TransactionManager.Instance.TransactionTaskDone() OUT = textInput