Scripting to convert inches to feet


jtcapa1
 Share

Recommended Posts

Chiefs default when you select a line to report the length of that line always starts with inches.

Not very helpful.

So I called CA and they tried to help me put in the right script, but it was way off.

So I turned to my paid Claude coding agent and put the question to it, and the response was very helpful.

Here is what Claude suggested:

Short version: the snippet you were given is broken Ruby, not a Chief-specific trick that's failing. .2_s isn't a method (it looks like a mangled .to_s), a method name can't start with a digit, and the space between length and the dot also breaks the call. So Chief never gets far enough to do any converting.

Here's what actually works, verified against a ChiefTalk thread from this June on exactly your question (a CAD line/spline length label). A forum regular there suggested %visible_length.to_ft.round(2)%. Chief's length values are Measurement objects, and that class carries unit-conversion methods. Options in order of simplicity: ChiefTalk

Decimal lineal feet (probably what you want for takeoffs):   %length.to_ft.round(2)%

 

Then I tweaked it for showing the length of the Fire Hose I was showing on my site plan:  

FIRE HOSE

%visible_length.to_ft.round% LF

Work perfectly.  Funny enough it quoted Rene Rabbitt for this code.  It is just harder to find Rene's gem's myself, but Claude does this in seconds!

Scary good.

 
Link to comment
Share on other sites

This is one of the reasons I don't post most of my macros.  AI will violate my copyright without my permission.  I suspect it's also capable of getting data from emails and/or text - but in any event, these forums are not safe from AI.

Edited by Joe_Carrick
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