Formatting A Referenced Macro


jbaehmer
 Share

Recommended Posts

Hopefully I can explain this well enough - I created a macro to get the header size of the window so when I change the header size in the framing tab of the window dialogue box the header label automatically changes. However it shows a decimal instead of fractions.  I tried some variations of other macros I had, but nothing worked.  Any ideas?

Header Label.plan

Link to comment
Share on other sites

Jared,

Maybe this will help:

arr = thickness.divmod(12)
inch_frac = ((arr[1]-arr[1].floor)*16).round.quo(16)

result = case
when inch_frac == 1.0
"#{arr[0]}'-#{arr[1].ceil}"+'"'
when inch_frac == 0.0
"#{arr[0]}'- #{arr[1].floor}"+'"'
else
"#{arr[0].floor}'-#{arr[1].floor} #{inch_frac}"+'"'
end
result

 

It returns the closest 1/16".  You can change that to whatever accuracy you want by just changing all instances of 16 to 8, 4, or 2 to get 1/8", 1/4" or 1/2" rounding.

Link to comment
Share on other sites

I tried it, but I can only get it to work if I have a value manually enter it.  With trying to get it to read off of the ruby setting for the window header framing...but I think that is where my lack of expertise on macros come into play.

Link to comment
Share on other sites

This is such a great  topic.  Maybe with X7 it will be auto.  Great topic Jared,  you  might want to send it into the SUGGESTIONS.  I assume they are working on X7 now,  and the more users who ask for this,  the greater the possibility it will happen in X7.

Link to comment
Share on other sites

Jared,

There are 3 Ruby attributes that would need to be considered for the Door or Window Header:

header_thickness
header_depth
header_count

The macro I gave you was just an example for a Ruby attribute named "thickness". To get something like (2) 2x8's or 3-1/2"x7-1/2" it would require a bit more work.

 

Let me know exactly what you want and I'll see what I can do.

Link to comment
Share on other sites

The macro I gave you was just an example for a Ruby attribute named "thickness". To get something like (2) 2x8's or 3-1/2"x7-1/2" it would require a bit more work.

 

Let me know exactly what you want and I'll see what I can do.

 

I am looking for it to say 3-1/2" x 7-1/2".  I put it in the suggestions forum, so hopefully CA will see it and add it to X7, whenever it comes out.  Typically, I use just a single 4x or 6x, so for me, the count isn't as critical.

Link to comment
Share on other sites

I don't want to put it in the window label.  I wanted to use a separate text box with an arrow pointing the the window taking the header info and putting it into the text box.  It would be the same setup as I have in the plan file I attached.  I do greatly appreciate you looking into this in your spare time.

Link to comment
Share on other sites

Jared,
Here are the 2 macros.

 

HeaderThicknessFractions

 

arr = header_thickness.divmod(12)
inch_frac = ((arr[1]-arr[1].floor)*16).round.quo(16)
result = case
when inch_frac == 1.0
"#{arr[0]}'-#{arr[1].ceil}"+'"'
when inch_frac == 0.0
"#{arr[0]}'- #{arr[1].floor}"+'"'
else
"#{arr[0].floor}'-#{arr[1].floor} #{inch_frac}"+'"'
end
result

 

HeaderDepthFractions

 

arr = header_depth.divmod(12)
inch_frac = ((arr[1]-arr[1].floor)*16).round.quo(16)
result = case
when inch_frac == 1.0
"#{arr[0]}'-#{arr[1].ceil}"+'"'
when inch_frac == 0.0
"#{arr[0]}'- #{arr[1].floor}"+'"'
else
"#{arr[0].floor}'-#{arr[1].floor} #{inch_frac}"+'"'
end
result

Link to comment
Share on other sites

Here's my approach:

h_depth = referenced.header_depth
h_depth = h_depth.to_r
h_depth #=> (1/12)
whole_num = h_depth.numerator / h_depth.denominator
fraction = ((h_depth.numerator % h_depth.denominator) / h_depth.denominator.to_f).to_r
whole_num = whole_num.to_s
fraction = fraction.to_s
if fraction == "0/1"
whole_num = whole_num << '"'
result = whole_num
else
whole_num = whole_num << ' '
fraction = fraction << '"'
result = whole_num + fraction
end
result

Replace h_depth with any variable name you want for the header thickness and obviously replace referenced.header_depth with referenced.header_thickness or any other attribute you want to find.

 

You could also change referenced to owner to evaluate the owner object if needed.

Link to comment
Share on other sites

To make it easier to reuse maybe just use a generic variable name in place of h_depth.

 

Here's a more generic example of the same script:

 

value = owner.width
value = value.to_r
value #=> (1/12)
whole_num = value.numerator / value.denominator
fraction = ((value.numerator % value.denominator) / value.denominator.to_f).to_r
whole_num = whole_num.to_s
fraction = fraction.to_s
if fraction == "0/1"
whole_num = whole_num << '"'
result = whole_num
else
whole_num = whole_num << ' '
fraction = fraction << '"'
result = whole_num + fraction
end
result
Link to comment
Share on other sites

Kirk, is this kind of thing coming to X7 soon? Just a hint will do.

Last year Joe did all this hard work on layout sheet index's and it came out in X6.

I don't think so. I've not encountered this until now so Jared's request in the suggestions forum may be the first request made so far.

Link to comment
Share on other sites

........  this until now so Jared's request in the suggestions forum may be the first request made so far.

If you think this is the first time this has been requested,  then somebody at headquarters has not been reading the suggestions vigilantly.

Link to comment
Share on other sites

And Kirk just so you are aware,  auto labels for headers,  posts and beams is not a luxury for us  power users.  This kind of stuff is part of every set of plans.  We call out this info on every set of  plans.  This is as important to us as being able to draw a wall.

 

I know that you guys will eventually get to this stuff,  I am just hoping you get to it sooner or later.  Just because you do not get a lot of requests for it does not mean it is not important.  

Link to comment
Share on other sites

Scott's correct, we have been talking about this since Ruby was added to Chief. Many , many posts

I am telling you Kirk,  you get us auto labels for beams, headers,  posts,  filled posts and cross blocks in posts,  you will have some very happy campers here on the west coast.

Link to comment
Share on other sites

FYI

 

I've made doz & doz suggestions in this area and I know others have as well -- not including all the threads in the forum's suggestion area.

 

With my last inquiry, i was told by TS not to submit any more suggestions or to inquiry about extending RUBY as the the program was not designed to be extended into this area. Still scratching my head as to what a suggestion line is for?

 

Bottom Line: if any one at Chief is interested -- you might check your circular archives.

Link to comment
Share on other sites

You know P.  I have been in this business as long as you,  40 years,  and I remember back in 1979 when my Dad who had his own design firm bought a HUGE,  I mean HUGE computer to do some CAD plans.  And I remember wondering at the time if it would be possible to write a computer program that would draw a house in 3D.

 

I thought about all of the variables and I did not think it possible.  Seriously,  I did not think it was possible.  But here we are,  35 years later,  and CA has done just that.  With the multitudes of variables that comes with modeling a house,  CA has done a pretty darn good job.  In fact I almost take it for granted now.

 

The point being.......

 

Hey  CA,  if you can do what you have done so far,  it could not be too tough to give us the auto labeling for framing members ......  thank you,  thank you very much.

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