Sign in to follow this  
HamlinBC

X8 Macro Question

Recommended Posts

I'm sure just a simple search would help me out, but...I don't know...too lazy and time is of the essence.

 

I would like to know how to do a macro that would display my interior door sizes like this:

 

       2'-6" X 6'-8"

2'-8" X 6'-10 1/2" R.O.

 

Is this even possible, or what am I up against here?

 

I know I'll have to set my R.O.'s so that they're correct, so I'm assuming that there's a simple way to get the macro's to display this somewhat like I show.

 

I might even settle for the inch dimensions instead of the feet-inch...

Share this post


Link to post
Share on other sites

Yes, it's possible.  Subscribers to my "Macro a Month Club" can do this easily by using my custom ftin(denominator) method.

Share this post


Link to post
Share on other sites

What about one time macro fee?...

Share this post


Link to post
Share on other sites

What if I just give you a hi-five  ;)

Share this post


Link to post
Share on other sites

Try this. Written and tested quickly.

# Function to convert 1.125 to 1 1/8

# rounds to nearest 16th

def f(i)

if i == 0 then

inches=0

return "#{inches}"

else

inches = i.floor

frac = (i.remainder(inches)*16).round.quo(16)

case

when frac == 1

return "#{inches + 1}"

when frac == 0

return "#{inches}"

else

return "#{inches} #{frac}"

end

end

end

# Convert inches to feet and inches

width_array = width.divmod(12)

height_array = height.divmod(12)

# Build the Line 1 string

Line1 = "#{width_array[0]}" + "-" + "#{f(width_array[1])}" + '"' + " X " + "#{height_array[0]}" + "-" + "#{f(height_array[1])}" + '"'

Line1_len = Line1.length

# Add RO space for both sides to the width giving RO Width

row = width + rough_opening_side * 2

# Add RO space for top and bottom to height giving RO Height

roh = height + rough_opening_top + rough_opening_bottom

# Convert inches to feet and inches

width_array = row.divmod(12)

height_array = roh.divmod(12)

# Build the Line 2 string

Line2 = "#{width_array[0]}" + "-" + "#{f(width_array[1])}" + '"' + " X " + "#{height_array[0]}" + "-" + "#{f(height_array[1])}" + '"' + " R.O."

Line2_len = Line2.length

# Try to center one over the other

# x is the number of spaces to add to the beginning of Line 1 to move it to the right

# y is the number of spaces to add to the beginning of Line 2 to move it to the right

x = 0; y = 0

if Line1_len == Line2_len then

# do nothing

else

if Line2_len > Line1_len

x = ((Line2_len - Line1_len) / 2) + 1

else

y = (Line1_len - Line2_len) / 2

end

end

# Build the output string

" "*x + Line1 + "\n" + " "*y + Line2

post-1284-0-31764800-1464728301_thumb.jpg

Share this post


Link to post
Share on other sites

Jonathon,

 

$3.00 gets you my "FloatClass.rb" which allows you to simply convert any value to ft-in-fractions by simply adding .ftin(8) to the value.

 

IOW, if width = 30.5

 

owner.width.ftin(8) -> 2'-6 1/2"

Share this post


Link to post
Share on other sites

I don't know Eric...I must be too stupid.

 

I copied and pasted what you put there and it just failed...there must be something I'm missing.

Share this post


Link to post
Share on other sites

I posted exact source code for the class. It does not do metric unlike Joe's. Other than that it works 100%

Share this post


Link to post
Share on other sites

I don't know Eric...I must be too stupid.

I copied and pasted what you put there and it just failed...there must be something I'm missing.

Open Text Macro Management

Create a new macro.

Paste the code into it.

Go back to a door in the plan. Select the new macro from the list of User Macros.

Share this post


Link to post
Share on other sites

Oh...hmmm...now it works??...

 

OK that's just plain weird because I tried it yesterday and I either couldn't select the macro, or else it would paste all of that coding in for the label.

 

Thanks Eric!

post-237-0-62008800-1464790292_thumb.png

Share this post


Link to post
Share on other sites

For the record, I'd support Joe by buying his package. I spent more than $3 of my time writing this.

 

 

Updated the post above with commented code.

 

The attached file contains the same macro, and should be indented so it's easier to read.

 

hamlin.txt

 

 

Share this post


Link to post
Share on other sites

Well I certainly appreciate it!

 

I don't do a lot with macros, and I was more or less asking if what I wanted could be done.

 

I was fully ready to drop the $3...not like it's a bank breaker...

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

    27491
    Total Members
    6254
    Most Online
    alexvictory
    Newest Member
    alexvictory
    Joined