Area dimension: better handling/formatting

Hello,

I’ve troubles with area dimension regarding its style.

It’s a bit annoying that Rhino doesn’t remember the last setting and is always starting with “Style=Leader”.

But the worse part I couldn’t get around is, how to get the calculated area being better formatted. Having an rectangle for e.g. 500 cm x 876 cm the area dimension displays 438000.
a)
I do not check out, where to globally set the font (style, size, …) that will be used for the text.

b)
Instead of 438000 cm² I tried to force Rhino to display 43,80 m² instead. The Area operation has no option to do that.
Using mathematical operations doesn’t seem to work either in Textfields :frowning:
Any ideas how to get around it

c)
I’m also missing the option to select multiple closed curves at once and Rhino will display the calculated area for each region.

Bye, MillingGuy

Hello- you can help with the first problem by making the button or alias

! _DimArea _Pause _Style=_Text

Since it is text and not a real dimension, it uses whatever is your current text setting (Text command).

Formatting units is on the pile to tune up for V6.

I’ll add the wish for multiples- how would you expect the text/leader placement to work?

thanks,

-Pascal

Hello Pascal,

:blush: => V6

As I always have a lot of closed curves to area dimension, I just wrote a script (still not 100% perfect, but do the job I need)…

MultipleArea.rvb (1.8 KB)

What should be improved on that:
*)
because it is just generating a text, changing the size of a closed curve does not reflect on the corresponding area dimension. This would come true using leaders, but the leader line is annoying.

*)
Text position is not well done. One idea is to give opportunities like LeftTop, LeftBottom, Center, OffsetX/OffsetY

*)
dimension unit and/or scale factor can be made working better together (currently the unit “m2” is hard coded)

Bye, MillingGuy

Hi MG- I monkeyed with your script a bit- this one will update with changes in area.
MultipleArea_PG.rvb (2.0 KB)

-Pascal

1 Like

Two questions to Pascal’s update of the script:

  1. I am not a programmer at all, but I can open the rvb script in Notepad. Is there a way to update the script so that it converts/ divides the area into a new unit? For example, I work in inches, but want area in sq.ft. So I want the inch areas divided by 144. If that can be written into the script, I could find that line of code and save it as a separate script (CalcAreaSqFt) for example. Then you could make another copy for metric, etc. Probably easier than writing a GUI.

  2. I am getting an error after choosing the closed curves that notes:
    Source: Microsoft VBScript runtime error
    Error: Object doesn’t support this property or method: 'Rhino.TextObjectFormula’
    Line: 68
    Char: 4
    Code:

Is my VBS script in need of an update or is the Rhino script hitting an error inside Rhino?

Thank you,
Matt

Well, I’m not sure that’s possible right now using text fields… The text field “area” is an internal calculation and does not appear to have any options as to unit output - looks like it uses the file units, period. So I’m not sure how to get an updatable field that includes a conversion factor in this case.

It doesn’t error out on line 68 here, so maybe your Rhino/Rhinoscript is out of date?

@pascal looks like an extension of text fields to allow calculations would be a good addition…

–Mitch

Hi Helvetosaur,

I’m not implying making the calculation in the text field; someone already noted that idea is currently unavailable. I was wondering if someone would be able to program that mini-calc (area divided by 144) into the rvb script. Then that particular script is really a “calc-area-from-file-in-inches_give-square-feet”.rvb file. No text field modified by the end user. I don’t know enough programming to do this myself.

Matt

So you don’t need a field that auto updates if you modify the object, but just a static area indication in the desired units?

You can try this : (edited, typos)

import rhinoscriptsyntax as rs
import scriptcontext as sc

def ccrv_filter(rhino_object, geometry, component_index):
    return rs.IsCurveClosed(geometry)

def SqFtAreaInInchFile():
    if rs.UnitSystem() != 8:
        #file is not in inches
        print "File is not an inch file"
        return
        
    msg="Select closed curves for area mesurement"
    objs=rs.GetObjects(msg,4,preselect=True,custom_filter=ccrv_filter)
    if not objs: return
    
    mult=1/144 #convert inches to sq. ft.
    suffix=" sq.ft."
    dStyle=rs.CurrentDimStyle()
    font=rs.DimStyleFont(dStyle)
    ht=rs.DimStyleTextHeight(dStyle)
    prec=sc.doc.ModelDistanceDisplayPrecision

    for obj in objs:
        area,ev=rs.CurveArea(obj)
        if area:
            cent,ev=rs.CurveAreaCentroid(obj)
            if cent:
                rs.AddText(str(round(area*mult,prec))+suffix,cent,ht,font)
SqFtAreaInInchFile()

–Mitch

Hi Mitch,

Thanks for the help. I’ll try to clarify what I’m hoping for.

From Pascal’s .rvb tweak (higher up on this email chain) of MillingGuy’s .rvb file, the multiple areas do show up and they do update if the curves are updated. That’s all fine.

  1. WITHIN that same .rvb file, I am hoping that your line of code “Mult=1/144” can be added after it calculates the area. Then each text object will display the correct numbers I’m after.

  2. Better still would be if the .rvb script would add up the summed areas of all the closed curves you select and create only one text object with the final sum tally (again, with the mult=1/144). Perhaps this is named as a different script, so you could call up either one by different commands within Rhino.

If these options are coded within the .rvb script, then the user has no need for Excel commands within the Text Properies dialog box.

Thanks,
Matt

I guess you didn’t understand what I was trying to tell you previously. As far as I know you can’t do that. That script is using a “text field” for the area calculation and you can’t introduce any supplementary calculations into those as far as I know. So anything else simple will have to be static.

I’ll have to look into the possibility of using History on a text object to do this, but I won’t have time in the next few days…

–Mitch

You could also try the following Grasshopper definition. For all referenced curves it will calculate the area divided by 144; if there are more than one selected it will also give you the total area off to the right of the objects. It will ignore open curves. You can change the conversion factor for other scales if you want; you may need to change the text size and/or offset slider limits depending on the type size you want…

You can bake the text tags if you want them in the file as text objects, but then of course they become static.

–Mitch

ClosedCrvArea.gh (16.1 KB)

Thanks Mitch,

I understand the issue stemming from the text object now.

Your GH definition was great. Besides the clean setup, groups, and colors (whereas my definitions are visually ambiguous), you used some GH commands that I don’t, so my learning happened there also.

Now GH could use its text objs with the ability to import & use a dimension style definition.

Thanks again,
Matt

I love this Mitch, just found it now. And I’m just now learning GH for real. I want to figure out how to add extra notation to these objects (sq", sqft, etc)
thanks for posting this years ago.