Custom formatting for Detail Scale variable

Hi all,

Wondering if there’s a way to add support for more customized formatting (or more generalized python code) within a text field. Specifically, I’m trying to add a text field that:

  1. gets the detail scale from a specified object (so, DetailScale)
  2. formats the scale in the form 1" = 4'-2-1/4" (or whatever).

There are formats that are close, but none preserve the 1" on the left side. For example,

%<DetailScale("front_elevation","1=#")>% | %<DetailScale("front_elevation","#=1-0")>%
results in:
1" = 1.167' | 7/8" = 1'-0"

In this case, what I want is 1" = 1'-2"

I’ve explored python string formatting, and it seems to me that if one of the “text fields” were “arbitrary python code,” one might be able to do this. Some things I’ve noticed:

  • .format() works with numbers: SCALE = %<'{:.5f}'.format(1-.234)>% evaluates to SCALE = 0.76600
  • the equivalent f-string doesn’t work: SCALE = %<f'{1-.234:.5f}'>% evaluates to SCALE = ####
  • DetailScale isn’t returning a number, even with "Noformatting" – meaning one can’t then do math on it: %<isinstance(DetailScale("front_elevation","Noformatting"), (int, float, complex))>% evaluates to False and %<DetailScale("front_elevation","Noformatting") + 2>% evaluates to #### (%<DetailScale("front_elevation","Noformatting")>% by itself gives 0.071)
  • therefore, even .format() doesn’t work with DetailScale: %<'{:.5f}'.format(DetailScale("front_elevation","Noformatting"))>% gives ####.

Is there a way to somehow encapsulate custom code, or add new formats to the available options? It’d be awesome to be able to use arbitrary rhinopython code in text fields.

Hey @defenestrated,

Sorry this slipped thru the cracks.

We’ve never had a request for this type of scale formatting. Where will this be used? Do you have an example where you use this?

It’s currently not possible to add custom Python code in text fields. The only way forward today is to just write a script to format and add the text.

– Dale

Hi @dale,

No worries, thanks for the response!

I work at the intersection of architecture, interior, and product design; we often have to send construction drawings out for fabrication or permitting. The standard (at least among the companies we work with in the Bay Area) for length measurements is feet and inches, so even though 1" = 18" is technically the same, I was hoping for a way to achieve the desired 1" = 1’-6" (rather than 2/3" = 1’-0").

The reasoning behind this, as I understand it, is so that in the field, if you have to measure a drawing with a physical scale, it’s a lot easier to measure inches on the drawing and then multiply by the scale factor than it would be to measure multiples of 2/3", then multiply that by the scale factor.

Here’s an example from one of our CDs (you’ll note that the 04 is off-center, that’s a different problem with the PDF output…):

The scripting piece was just my technologist brain making the leap to “wouldn’t it be cool to have full arbitrary control over text variables” – not just for DetailScale, but, I dunno, page numbers, dimension text, etc. Being able to do regex and perform math on that kind of variable would open up infinite possibilities…

Running into this issue again so I’m bringing it back from the dead: I would love for there to be a way to customize the detail scale formula. If it’s too hard to open to real customization, at the very least I’d love to see a few new formats. It’d be great if these could be implemented in both decimal and fractional:
1" = #" (ex. 1" = 14") <---- this is how you set it in the detail properties, so seems like a no brainer
1" = #‘-#" (ex. 1" = 1’-4")

The closest available, I think, is 1" = #‘. This mixing of units (inches to feet) might be useful for architecture-scale projects but isn’t so helpful for furniture or product-scale work (a 1:8 scale, for instance, is 1" = 0.667’, which is crazy). At the very least, fractions of a foot should resolve to inches, right?

Hi Sam,
There is already a feature request RH-61916 for common predefined scales in a future Rhino:
Display-List-of-Common-Detail-Scales to select from.
It is not public because of customer images, but we have a pretty extensive list.
Roughly, it would look something like this:
image

Now the details properties allow of you to type in values and override the common unit suffixes like ', ", mm, cm, m.
image
See how this works in this video:

There is always room for improvement, but I think most users can do what they want with this, and are happy to know that a list control with common scales wish has been logged.

Give it a try and see if it works better for your application.
Sincerely,
Mary Ann Fugier