Creating a Text Macro that Rounds a Value to the Nearest Inch or Foot


Reference Number: KB-03230
Last Modified: September 5, 2025

QUESTION

I would like to use a ceiling text macro in my room labels to display the height, but it displays fractions, which aren't desired. How can I make it so that the height is rounded, either to the nearest inch or to the nearest foot?  


ANSWER

By default, many text macros are setup to display the raw, unrounded results of the calculation they perform, but you can easily create a macro that rounds to the nearest value of your choosing using the information in this article.  

Note: If you would like custom text macros to be present in all files that you create, consider making the changes below to your template(s). For more information on templates, please see the Related Articles section below. 


To create a custom macro that is rounded to the nearest inch or foot

  1. Access the plan or template that you would like to create a new macro within.

    In this example, we have drawn a single room structure with a default ceiling height of 109 1/8", or 9'-1 1/8". But instead of displaying the height as such, we can create a macro that displays this value as either 9'-1" or just 9', which we will demonstrate below. 

    Basic single room structure measuring 20' x 25'


  2. Using the Select Objects  tool, click in the single room to select it, and with it selected, navigate to CAD> Text> Text Macro Management  from the menu.

    Although selecting a room or object isn't necessary when creating or customizing macros, it can prove to be helpful, as the Text Macro Management dialog will provide a result if the macro successfully functions with the selected room or object. 


  3. In the Text Macro Management dialog that opens, click the New button. 


  4. In the Edit Text Macro dialog that displays next:

    Edit Text Macro dialog where macros can be created

    • Provide a reasonable Name

      In this example, CeilingHeightRounded is specified. 

    • Insert the following Value

      obj = owner
      obj = referenced unless referenced.nil?

      nf = NumberFormatter.new
      nf.unit = "'-\""
      nf.use_fractions = true
      nf.denominator = 1
      nf.apply(ceiling_height)


    • Check the Evaluate box, then change the Context drop-down to Owner Object. This is a critical step for the macro to work correctly. 

    • To break it down, the value above is stating that the newly created macro will display the height of the room using the nf.apply property, the value will be in feet and fractional inches per the nf.unit and nf.use_fractions properties, but the resulting value will round fractions up to the nearest whole number per the nf.denominator property. If you wanted to round to the nearest 1/4", you can replace the number 1 with the number 4. Using the code mentioned above, our ceiling height will now display as 9'-1" when this text macro is used. 

      If we wanted the value to display 9' instead, we can simply change the nf.unit property to "'" so only feet are displayed. 

      Note: If a room is not selected prior to accessing the Text Macro Management dialog as mentioned in Step 2 above, the Original Result and New Result fields in the Edit Text Macro dialog will instead display with Evaluation Errors. This does not mean the macro will not function correctly when used, just that it can't perform the function as an applicable room was not selected. 


    • Click OK once the macro has been established to your liking, and notice that it's now displayed in the list of macros. 


  5. Click OK again to close out of the Text Macro Management dialog. 


  6. Navigate to Edit> Default Settings , expand the Floors and Rooms category, select Room Label from the list, then click Edit

    Default Settings dialog with Room Label selected


  7. On the Text panel of the Room Label Defaults dialog that opens: 

    Text panel of the Room Label Defaults dialog

    • Press Enter on the keyboard to drop to the second line in the text box.

    • Type %CeilingHeightRounded%, which is the name of the macro we just created.

    • Click OK and Done to close the dialogs and confirm the change.


  8. Next, click inside of the room using the Select Objects tool, then select the Open Object edit tool.


  9. On the General panel of the Room Specification dialog that displays, change the Room Type to Living or something else from list of room types, then click OK.

    Note: If automatic room labels have already been populated prior to creating and inserting a macro, the labels may need to be refreshed. This can be done by opening one or more rooms up to specification, making a change to the Room Type or Room Name, then clicking OK. Once the room labels have been refreshed, you can revert the change made to the Room Type or Room Name. 


    General panel of the Room Specification dialog


The room's label will now display, along with the ceiling height of the room rounded to your preference. 

Floor plan with the ceiling height displayed as part of the room label


You can now apply these same concepts to other custom macros to achieve similar results.