Vb.net equivalent of Rhino.Getbox

I’m wanting to select an object as follows:

        Dim rc = RhinoGet.GetOneObject("Select object", True, Rhino.DocObjects.ObjectType.AnyObject, rhobj)

And then store each of the 8 corner points in a variable.

Then create a point for each of those points as follows:

        For Each ptinsert In ptgroup
            doc.Objects.AddPoint(ptinsert)
        Next

I’m not sure how to get those points into variable ptgroup.

Thanks in advance!

Adrian

Hi Mckenna,

Check the Brep.DuplicateVertices method.
In case you have an extrusion box, you might have to use the ToBrep method first before calling DuplicateVertices.

Hi Adrian
When trying to replicate a RhinoScript method by RhinoCommon,
looking at https://github.com/mcneel/rhinopython/tree/master/scripts/rhinoscript may help.
This the code written by Steve Baer that is used to replictae RhinoScript methods in IronPython.
(BTW in IronPython it’s called the rhinoscriptsyntax library)
Yes, it’s Python, not Vb.net, but the RhinoCommon objects and function used should also work in VB.
The same code should be found on the PC where Rhino is installed.
Here it is in

C:\Users\computer\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript

The following is rhinoscriptsyntax’s GetBox code


def GetBox(mode=0, base_point=None, prompt1=None, prompt2=None, prompt3=None):
    """Pauses for user input of a box
    Parameters:
      mode[opt] = The box selection mode.
         0 = All modes
         1 = Corner. The base rectangle is created by picking two corner points
         2 = 3-Point. The base rectangle is created by picking three points
         3 = Vertical. The base vertical rectangle is created by picking three points.
         4 = Center. The base rectangle is created by picking a center point and a corner point
      base_point[opt] = optional 3D base point
      prompt1, prompt2, prompt3 [opt] = optional prompts to set
    Returns:
      list of eight Point3d that define the corners of the box on success
      None is not successful, or on error
    """
    base_point = rhutil.coerce3dpoint(base_point)
    if base_point is None: base_point = Rhino.Geometry.Point3d.Unset
    rc, box = Rhino.Input.RhinoGet.GetBox(mode, base_point, prompt1, prompt2, prompt3)
    if rc==Rhino.Commands.Result.Success: return tuple(box.GetCorners())


Use Rhino.Input.RhinoGet.GetBox.

Thanks guys, I think I have mistakenly described my aims.

I’m hoping to select an existing ‘box’ or closed polysurface in the model and store all of its corner points / grips within variable ptarray.

Adrian

Your post was clear. I simply forgot to read it and only looked at the title … sorry
But Djordje got it right, I’d follow his suggestion:
Brep.DuplicateVertices() will give you the points. It doesn.t ‘duplicate’ Rhino objects in the document, it just returns Point3d objects, which I think is what you need.
To get the Brep object, just use the Brep() method on the ObjRef object (the rhobj var loaded by GetOneObject() )

Pseudocode:

brep = rhobj.Brep()
ptgroup = brep.DuplicateVertices()

1 Like

Awesome, thanks @emilio & @djordje (@dale also) for your perseverance, that has nailed it.
I think I am coming to grips with the way the SDK documentation is written, which is why I didn’t get it first time.

Adrian