Stair Macro Imperial Units

Recommended Posts

Can anyone tell me how to show a stair macro with imperial units instead of the default decimals? I'm fairly new to macro's. I've searched the older posts on this subject but am confused with exactly how to use the long ruby formulas.


If anyone has any useful macro's already setup for stairs or other items, I'm open to purchasing them.

Share this post

Link to post
Share on other sites

This uses a ruby routine located in a separate file in the Scripts folder.


You pass in the divisor and number to convert.


Returns an array containing the 3 values so they may be formatted as needed.


Everything in blue is Ruby code


Put the following in a file named ConvertToFeetInches.rb in the Scripts folder.






def ConvertToFeetInches (d, number)
    divisor = 1/d.to_f
    a = ((number/divisor).round*divisor).divmod(12)
    # r[0] = feet
    # r[1] = inches
    # r[2] = fraction
    r = Array.new(3, "0")
    r[0] = a[0].to_s
    r[1] = a[1].floor.to_s
    if a[1].modulo(1) == 0
        r[2] = ""
        r[2] = "#{a[1].modulo(1).rationalize}"

    return r





The following shows how it's used




require "ConvertToFeetInches.rb"


r = ConvertToFeetInches(16,length)


# this line formats the output and will probably need to be changed.


# given a divisor of 16 and a value to convert of 123.456, this will return 10' 3-7/16"


r[0] + "' " +  r[1] + "-" + r[2] + '"'

Share this post

Link to post
Share on other sites

That is way above what I know how to handle at the moment, but thanks. I don't know exactly where to write the script. I think I'd rather buy macro's already made to save my time.


I'm really surprised Chief doesn't have macro's available with the SSA library. The stairs should show you the relevant information for permit drawings without the user having to be a scripting whiz.

Share this post

Link to post
Share on other sites
2 hours ago, nVisionTEKBIM said:

I don't know exactly where to write the script.


This is just an edit of what I have as a standard macro for a dimension to sixteenths and the newer object properties macro (which I think is installed by default? but just in case).

The object prop macro tells you what any available value is called in Ruby.

Macro code is just

inches = tread_depth.floor
frac = (tread_depth.remainder(inches)*16).round.quo(16)
when frac == 1
  result = "#{inches + 1}"
when frac == 0
  result = "#{inches}"
  result = "#{inches} #{frac}"


Macros attached for tread depth-took me a couple of minutes-(took longer to type this:) all I did was change the value from height.floor to tread_depth.floor


height.remainder to tread_depth.remainder


What you need to do is just import it and use it. Best to select the stair, then open the "Text Macro Management", select import

Check to see if you already have the object properties macro-if you do don't import it.

If you want to use the one at sixteenths it needs to be evaluated as referenced. See below (edit)


You can get other values by selecting the object, opening the Text Macro Management panel and looking at the right pane. If you want another value-copy that value to the clipboard, then copy this macro (or if you have the original -formattedHeightSixteenths- which is either built in or was posted on the forum once thought with capiral "F")

Change the name of the macro, then replace tread_depth.floor  with the value you copied (value_name.floor) Do the same for the next line replacing "tread_depth" with the value_name.

Leave it as evaluated. Should come up correctly. (Note at the last minute I realized you could not be using this as a label so I added a referenced macro set to 8ths-to change the macor set to 16ths in TMM select it, edit, change evaluation to referenced and save.

To change from sixteenths to eights, replace both instances of the number 16 on the second line with 8.

To change it to use in a text callout with arrow it needs to be evaluated as referenced (which will at first show up as an error in the TMM I added in a referenced macro set to 8ths at the last minute not sure how you want to use it.

There is a way to make a macro do both-I have it somewhere but not on the plan I was working on and don't remember the code. You can find that posted, by Joe C and Gerry T some years ago

Image show both in use as referenced macros

tread depth.json

object properties.json

tred depth 8ths referenced.json

tread depth.png

Edited by MarkMc

Share this post

Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now

  • Member Statistics

    Total Members
    Most Online
    Newest Member