Ruby Ceiling macro question X12


BrownTiger
 Share

Recommended Posts

 

What is the correct or suggested way to create a ceiling macro in X12? (Let's say I want it displayed as x'-y")

Like this for example: 

#==================================================

height = (owner.ceiling_elevation-owner.floor_elevation).round(0).to_in

arr =height.divmod(12)

result ="#{arr[0]}'-#{arr[1].round}''" + " CLG.HT."

#===================================================

 

Or there is a better way to display 12'-5" without the use of divmod?

Define a custom NumberFormarter? etc.

 

Just looking for suggestions?

Link to comment
Share on other sites

I agree with Michael.  Note that you don't need to use .to_in  when using the NumberFormatter.  I actually have several predefined NumberFormatters saved as $Globals so that I can just specify which one I want:

  • $NF_in
  • $NF_ft
  • $NF_ft_in

They are all automatically loaded into memory when I open my Layout (macro in a text box on page 0)

  • Upvote 1
Link to comment
Share on other sites

Thank you very much.

 

#

#Macro: roomLabel

#X12 Room Macro. Defined global $FtIn

#BT  Output: 13'-0" CLG.HT.

#

referenced ? obj = referenced : obj = owner

height = (obj.ceiling_elevation-obj.floor_elevation).round(0)

if defined?($FtIn).nil? then

$FtIn = NumberFormatter.new

$FtIn.unit = "'-\""

$FtIn.use_fractions = true

$FtIn.denominator = 8

$FtIn.show_trailing_zeros = true

end

result = $FtIn.apply(height) + " CLG.HT."

 

 

LabelTest.plan

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share