tubbsinc

Editing upper label with macro

Recommended Posts

I have had this issue with other software and I'm hoping there's a simple CA remedy for it.

My standard upper is 13" D.  When changed in preferences the depth is always displayed on uppers,  ex. W243613 with the auto label.
I want to change the upper labels to display standard as W %width%%height%     ex. W2436 (without depth).
I can do this with the basic label change.  But if I change the depth up or down it would be beneficial for it to display the auto generated label %automatic_label%.

 

I know there is no way my syntax is right but the basic idea is--

case
when depth == 13
   result = W %width%%height%     
else
  result = %automatic_label%

 

Any pointers are greatly appreciated.

 

 

Share this post


Link to post
Share on other sites

Basic and not complete, but it should get you started.

 

if depth==13.0

    "W" + width.to_s + height.to_s

else

    automatic_label

end

 

Share this post


Link to post
Share on other sites
7 hours ago, tubbsinc said:

I have had this issue with other software and I'm hoping there's a simple CA remedy for it.

My standard upper is 13" D.  When changed in preferences the depth is always displayed on uppers,  ex. W243613 with the auto label.
I want to change the upper labels to display standard as W %width%%height%     ex. W2436 (without depth).
I can do this with the basic label change.  But if I change the depth up or down it would be beneficial for it to display the auto generated label %automatic_label%.

 

I know there is no way my syntax is right but the basic idea is--

case
when depth == 13
   result = W %width%%height%     
else
  result = %automatic_label% 

 

Any pointers are greatly appreciated.

 

 

 

There are a million ways this could be written in Ruby, but on a very basic level, you're really not that far off.  Your code just needs a few minor tweaks.  Here are a handful of options that would work (all based on your code)...

 

case

when depth.to_f == 13

result = "W" + "%width%%height%"

else

result = "%automatic_label%"

end

 

or

 

case

when depth == 13.in

result = "W" + "%width%%height%"

else

result = "%automatic_label%"

end

 

or

 

case

when depth == 13.in

result = "W" + width.to_in.round.to_s+ height.to_in.round.to_s

else

result = automatic_label

end

 

or

 

case

when depth == 13.in

result = "W" + width.to_f.round.to_s+ height.to_f.round.to_s

else

result = automatic_label

end

 

or

 

case

when depth == 13.in

result = "W#{width.to_f.round.to_s}#{height.to_f.round.to_s}"

else

result = automatic_label

end

 

I personally usually skip the case statements though and use if statements.  I think its computationally faster in most cases.  Something like this...

 

if depth == 13.in

result = "W#{width.to_f.round.to_s}#{height.to_f.round.to_s}"

else

result = automatic_label

end

 

If you want to learn more though and make some more meaningful progress a lot quicker, I do offer consultation and various support services to help with that.  If you want to discuss further, just send me over an email to alaskansons@gmail.com

 

Either way, hopefully the information above helps get you started.

  • Like 1

Share this post


Link to post
Share on other sites
16 hours ago, tubbsinc said:

Any pointers are greatly appreciated. 

Here's a plan with a couple of macros in it-GerryT helped me with this some years ago so passing this along freely (whatever doesn't work is my fault, what works couldn't have been done without him) . The increase depth/reduce depth was added today. Note that this will also do what you want on base cabinets at the same time. Likely needs change to suit your or others needs but worthwhile starting point. I'm hardly much of an expert with Ruby so often am opening macros that work to sort things out by using snippets from them. This has a lot of snippets. It would also be worthwhile to test each of Alaskan_Sons options-will give you some idea of what the new Measurement class does and does not do among other things.

 

Backstory:This was originally for a brand of cabinets that I was able to order with an online system and that had very annoying nomenclature. When working this was used in conjunction with replace from library and worked well. I'd offered to show the mfg how it works and give it to them free but they couldn't be bothered (?) Anyway I no longer deal with them and tabled this a few years ago.

Recently I realized that I could use the new style pallet feature to change just a cabinets face. That is far more efficient than using replace from library for a majority of cabinets BUT the feature doesn't include the option to include the Label. I decided it was time to dust this off and alter it to my current, limited, needs until they add in the ability to include labels in style palette (please, please). So it's on the long list of things to work on that would be nice to have but don't really need right away :unsure:

Cabinet label N.plan

  • Like 1

Share this post


Link to post
Share on other sites
9 hours ago, Alaskan_Son said:

 

if depth == 13.in

result = "W#{width.to_f.round.to_s}#{height.to_f.round.to_s}"

else

result = automatic_label

end

I was able to modify this slightly to get it to work.  My novice Ruby brain has me in the Text>Text macro management console which led me to have to define the depth,width, height variables first.  Not sure what #{width.to_f.round.to_s}  does exactly.  I'm just as comfortable with the IF statements I just wasn't connecting with the syntax.  Thanks for the clarification.  As I work through my transition to CA I may need a crash course in some areas that I will need to be proficient.

 

1 hour ago, MarkMc said:

Backstory:This was originally for a brand of cabinets that I was able to order with an online system and that had very annoying nomenclature

This is my problem too, I like to have a clean representation especially for shop drawings.  Having been doing this for some years certain nomenclature in built in to my brain and makes me more efficient in ordering, building, etc.  I appreciate the example, seeing something that works helps me identify how some of the variables,etc. work in CA.  I've probably spent more time working on this than intended but I think understanding it will be important in the long run.

 

 

Share this post


Link to post
Share on other sites
1 hour ago, tubbsinc said:

Not sure what #{width.to_f.round.to_s}  does exactly

It's called interpolation.  Its a way to insert code into otherwise "dumb text". 

Share this post


Link to post
Share on other sites
7 minutes ago, Alaskan_Son said:

Its a way to insert code into otherwise "dumb text". 

 

How about -- inserts the contents of a variable into a string.

 

a = "123"

 

b = "ABC#{a}DEF"

 

b would contain ABC123DEF

Share this post


Link to post
Share on other sites
1 hour ago, solver said:

 

How about -- inserts the contents of a variable into a string.

 

a = "123"

 

b = "ABC#{a}DEF"

 

b would contain ABC123DEF

 

That's an oversimplification.  It actually does a lot more than handle variables.  It does indeed insert and execute code in general.  Quick example...

 

"8+2=#{8+2}" ----> 8+2=10

 

I guess a more precise and proper definition might be -- a method of inserting an expression into a string

  • Upvote 1

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

    27861
    Total Members
    6254
    Most Online
    mmebsc
    Newest Member
    mmebsc
    Joined