lisa-marie mueller

lisa-marie mueller

bullet pont

format selector - text properties link

September 18, 2020

colored pencils writing title on paper and clock - in red Happy Friday! This week we will look at some of the other properties we can save and change through the API and start working on a little tool to save and then re-assign text formatting from one TextNote to another.

select text with ISelectionFilter

First, I will briefly go over the ISelectionFilter I used to select text boxes. ISelectionFilters can be used to limit the type of element a user can select in the Revit model. Since we want to limit this to TextNote elements, we can create a new public class and call it TextNoteSelectionFilter. It extends ISelectionFilter and allows elements with the category name Text Notes. Then we can use this as an input when we use the PickObject method so users can only select the type of element we want.

In our SelectText method, like the one we used last week, we can then use this filter and users will only be able to select TextNote elements.

text properties to save

Since we have the TextNote input, we now want to save all the formatting parameters from that TextNote. For the format painter we are working on, we will want get the text Type property and also see if the string is all uppercase, bold, italic, or underlined. To get the type, we can just get the TypeId as an integer and this is the value we will then save. I was having issues when using the GetAllCapsStatus method, so I did my own check. I check all the characters of the plain text string against a string of lower case values. If there are any lowercase values in the string, we set isUpper to false. This lets us save a boolean value which represents if the text note is all caps. The reason we check against a lower case string instead of an upper case string is that we do not want the all caps value to be set to false if there are special characters. All we care about is if there are any lower case characters present and it is simpler to complete that check rather than have to also ignore special characters. The bold, italic, and underlined status are easy to find with their respective get methods. We save these values to variables so that we can later save these values to an external file.

summary

That wraps up how to get the status of all the formatting from our text box. Next week we will take a look at how to save this information in a separate file so we can read it later.

resources

If you want to learn to code and don’t know where to start check out my posts about Steps to Learn to Code [for architects and designers] Part 1 and Part 2.

Revit API Docs

bullet pont

recommended next