Sign in to follow this  
uhlerandcompany

Framing Dimension Format

Recommended Posts

Does anyone know how to make the object specific framing joist macro labels in ft and inches ('0-0") instead of inches?

Share this post


Link to post
Share on other sites

Something like this?

 

ct1.png.b5caad910bdb65f0d361693dd2dff880.png

Share this post


Link to post
Share on other sites

Yes, that would be ideal. I'm using the macro to auto generate the length but cant figure out how to do it in feet instead of inches.

Share this post


Link to post
Share on other sites

This is what I use. It gives you some formatting options.

 

I define a function ConvertToFeetInches, and the very last line calls the function.

 

If you wanted to convert the length, it would look like this.

 

ConvertToFeetInches(length,16, " ", "-", true)

 

 

 

 

def ConvertToFeetInches (number, denominator, s1, s2, show_zero)

 

#    number - the input to be converted from decimal inches to feet and fractional inches
#    denominator (8 for 1/8, 16 for 1/16 etc)
#    s1 - user defined string placed between feet and inches
#    s2 - user defined string placed between inches and any fraction
#    show_zero - (true/false) adds 0" if there are no inches (number=12 and s1="-" would format as 1'-0")


#    core code adapted from https://chieftalk.chiefarchitect.com/topic/11982-tip-for-correcting-ft-in-macros/#comment-133636 

 

 

  case denominator
      when 1..64
      else return "[Convert Error - Denominator out of range. Must be from 1 to 64]"
  end
      
  divisor = 1/denominator.to_f
   
  a = ((number/divisor).round*divisor).divmod(12)
   
  if a[0] != 0
      feet = a[0].to_s + "'"
  else
      feet=""
  end
  
  if a[1] == 0 # check for inches, if none, return feet
      if show_zero
          return feet + s1 + "0\""
      else
          return feet
      end
  else
      i = a[1].floor # get inches
      f = a[1].modulo(1).rationalize # get fraction
      
      if i != 0 and f != 0 # both inches and fractions
          return feet + s1 + i.to_s + s2 + f.to_s + '"'
      end
      
      if i != 0 # inches but no fractions
          return feet + s1 + i.to_s + '"'
      end
      
      if f != 0 # fractions but no inches
          return feet + s1 + f.to_s + '"'
      end
  end
 
end

 

 

ConvertToFeetInches(length,16, " ", "-", true)

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
Sign in to follow this  

  • Member Statistics

    27640
    Total Members
    6254
    Most Online
    PeggySue
    Newest Member
    PeggySue
    Joined