Is it possible to constrain GetPoint object with multiple breps?

Hi everyone, @dale, I want to constrain the GetPoint object with multiple breps at the same time. Is it possible in C# with RhinoCommon API?

Thanks!

Hi @tahirhan,

below is a hack which creates a potentionally non valid brep from multiple non touching breps and then constrains the point picker to the result:

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

def DoSomething():
    
    brep_ids = rs.GetObjects("Breps", 8+16, False, False, False)
    if not brep_ids: return
    
    breps = [rs.coercebrep(brep_id, True) for brep_id in brep_ids]
    
    tolerance = scriptcontext.doc.ModelAbsoluteTolerance
    brep = Rhino.Geometry.Brep.MergeBreps(breps, tolerance)
    if not brep: return
    
    gp = Rhino.Input.Custom.GetPoint()
    gp.SetCommandPrompt("Pick point on breps")
    gp.Constrain(brep, -1, -1, False)
    
    while True:
        gp.Get()
        if gp.CommandResult() == Rhino.Commands.Result.Success:
            scriptcontext.doc.Objects.AddPoint(gp.Point())
            scriptcontext.doc.Views.Redraw()
        else:
            break
            
DoSomething()

_
c.

1 Like

Hmm, I thought about it but in my case, the minimum distance between discrete breps will be 500-600 mm. So I guess the code will always return at brep control because I don’t think merge operation will give valid brep, but I will give it a try, thanks a lot!