How to find text with PropertyWizard

You can use the instr() function to find text in a PropertyWizard function. It finds the position of one piece of text inside another, and returns the character position of the first character of the found text, or -1 if the text isn’t found.

So, say we want to find all the rooms where the room’s Name contains “Bedroom”, such as “Main Bedroom”, ” Bedroom 2″, etc. The formula for that would be:

instr(Name, "Bedroom")

To turn that into a true/false value, you could use:

instr(Name, "Bedroom") != -1

This checks whether the instr result is not equal to (!=) minus 1. It will return true if the Name contains “Bedroom” and false otherwise – you can put this true/false result directly into a Yes/No parameter.

Alternatively, if you wanted to get a text value as the result:

if(instr(Name, "Bedroom") != -1 , "Bedroom", "Not A Bedroom")

Here are the three formulas in PropertyWizard. I’ve made three new project parameters as target properties:

PropertyWizard Formulas window showing three formulas using instr to find the text "Bedroom"
The three instr formulas

And here is the result in a Room schedule:

Revit Room Schedule showing the results of using the three instr formulas to find the text "Bedroom"
Room schedule showing the results of the instr formulas

Notice how instr is case-sensitive – the formula has not found room number 4, because its name is “bedroom” not “Bedroom”. I will cover case-changing formulas in a future post, when the next version of PropertyWizard is live.

You can download the formulas XML here to import into your own project – you will need to change the target properties to suit your project:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.