Hi,
I want the user to select a couple of objects and after only the widest is selected.
If I know the widest I can get the mid point of it and move all selected items to the right position to get milled.
I’ve started with this:
Dim rhObject As Rhino.DocObjects.ObjRef() = Nothing
Dim rc2 = Rhino.Input.RhinoGet.GetMultipleObjects("objects left", False, Rhino.DocObjects.ObjectType.AnyObject, rhObject)
If rc2 <> Rhino.Commands.Result.Success Then
Return rc2
End If
Dim brep = rhObject(0).Brep
But I fill in the 0 to pick the first object but thats not the widest.
Any ideas?
I expect you want to get the bounding box of each object and measure the X length, then pick the largest… I don’t know if it’s curve or surface objects you’re dealing with, but you might look at:
Rhino.Geometry.Brep.GetBoundingBox()
Rhino.Geometry.Curve.GetBoundingBox()
Which return a bounding box object that has properties including Min and Max, from which can be calculated the X length.
HTH,
–Mitch
Dim bbox = surface.GetBoundingBox(False)
If Not bbox.IsValid Then
Return Rhino.Commands.Result.Failure
End If
I see what you mean. I got a surface
I have to create a for each srf as rhinoobject in rhobject. Calculate and add the number to an array. Then pick the largest. Just have to figure out how to link the largest number with the right object
or i can get the largest one and link a location with it. So if I get the widest object I also get the location.
Thnx Mitch
Well if you do it in order, the index of the largest number in the bounding box width array should be the same as the index of the corresponding object in the object array…
–Mitch
True but I can also check for each object. Calculate the width. If width > previous width then variable will change. else nothing
P.S. thats because I dont really know how to do it with the array
Result:
Dim x = 0
Dim y = 0
Dim xloc = 0
Dim yloc = 0
For Each ref As Rhino.DocObjects.ObjRef In rhObject
Dim minx = ref.Brep.GetBoundingBox(False).Min.X.ToString
Dim maxx = ref.Brep.GetBoundingBox(False).Max.X.ToString
Dim sumx = maxx - minx
Dim miny = ref.Brep.GetBoundingBox(False).Min.Y.ToString
Dim maxy = ref.Brep.GetBoundingBox(False).Max.Y.ToString
Dim sumy = maxy - miny
If x < sumx Then
x = sumx
xloc = (sumx / 2) + minx
yloc = (sumy / 2) + miny
End If
Next