Editing upper label with macro


tubbsinc
 Share

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.

 

 

Link to comment
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
Link to comment
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.

 

 

Link to comment
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
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