Getting the size of an object


#1

I’m hoping someone can help with this.

This is something I developed a few years back for kitchen cupboards and doors, which we cut via CNC, and I’m checking in now to see if there is another way to achieve the same outcome.

The image attached is representative of a kitchen door, which has a HEIGHT, WIDTH & THICKNESS. To date I have been using a polyline as a tracer so I can extract these 3 variables. As the polylines ‘startpoint’ stays the same no matter how I rotate the door I can always get those 3 variables from the polyline. 1-2 = THICKNESS, 2-3 = HEIGHT and 3-4 = WIDTH.

The issue is that if I want to change the size of the door model, I have to separately change the polyline, so I can’t use MOVEFACE, MOVEEDGE as the means of editing.

I’m hoping there might be a way to extract this info consistently from the actual door object directly and eliminate the tracer. The trials I did originally failed when the object was rotated or mirrored and it would not maintain the 3 variables I needed.

Thanks in advance!

Adrian


#2

Hi Adrian, glad to meet you here :smiley:
Does this help ?
AMK-doorsize.py (1.0 KB)
It only could work if the door is a simple vertical solid box.

Cheers


#3

Thanks for that - it seems to work well, even if I mirror, rotate, etc. For panels that are horizontal (on the flat), I think I can overcome the limitation, knowing that we work with standard material thicknesses, so if height = 18mm then what would have been thickness will be depth.

I haven’t played with python scripting, just vbscript. Do you find it better than vbscripting and worth some relearning?

Cheers,

Adrian


#4

Yes … but I have to admit that I never liked VBS and already liked to play with Python.
Beyond personal taste … I think there are advantages in using Python to script Rhino:
Rhino runs IronPython, so you can use several Python-specific libraries plus Microsoft’s .NET libraries.
Also (and IMO more important), besides rhinoscriptsyntax, which replicates (unfortunately not yet completely) the VBS RhinoScript library, you cab also use RhinoCommon, which, as you may know, is the core library for many Rhino plug-ins (e.g. Grasshopper).
RhinoCommon is more powerful than RhinoScript: you can do almost everything in Rhino with it.
You can work directly with ‘abstract’ geometric objects, not just with objects from the Rhino document like in RhinoScript.
Obviously you can use Layers, Views, etc.
And you can set up command options just like those of the native Rhino commands, improving the script’s user interface a lot.