Hi everyone. I’m trying to write some scripts operating only on “box-like” objects – which I currently define as right-angled cuboids, sometimes rotated so that they are not grid-aligned.
RhinoScript has a test method “IsBox”, which is useful (whether or not the definition exactly matches the above). If an object passes that, then BoxPoints will provide the array (inevitably size 8) of corner coordinates. So I have something like this:
arrSelected = Rhino.SelectedObjects If IsArray(arrSelected) Then For Each objo In arrSelected If rhino.IsBox(objo) Then arrPoints = Rhino.BoxPoints(objo) ' ... and now deal with arrPoints ...
My main question is: how could I achieve something similar to the above using PythonScript?
(I see that IsBox was added for breps: Rhino 7 Service Release Available - #14 by brian – but I have no idea what breps are. The initial discussion that prompted that is linked – and in that discussion, the initial answers suggested roll-your-own methods in Grasshopper. I was hoping that there would be PythonScript equivalents to all RhinoScript commands, but perhaps that is overoptimistic.)
Two more detailed questions:
• What does IsBox test for? (For example, does it matter whether a polysurface was originally created using a Box command, or extruding a rectangular surface or curve? Is a sheared box still a box?)
• Is there a list of indexes for the BoxPoints array that is guaranteed to create a right-handed coordinate system for the edges? Something like “From index 0 as the origin, to indexes 1, 3 and 4 in that order”. The in-app PythonScript help files (but not the online ones) specify “Points are returned in counter-clockwise order starting with the bottom rectangle of the box.” – but what is the bottom rectangle of a rotated box? I’ve tried a few experiments, but the results confused me.