Check if points are inside a Brep (Python)

as mentioned by the honorable judge @AndersDeleuran, the RhinoCommon method seems to work just fine?

import Rhino
import scriptcontext as sc

sc.doc = Rhino.RhinoDoc.ActiveDoc
tol = sc.doc.ModelAbsoluteTolerance
sc.doc = ghdoc

a = x.IsPointInside(y, tol, True) 

note, I probably err on the side of “overuse”, but anytime I need to do something with the active rhino document, (like get the tolerance), my rule of thumb is to use scriptcontext to switch the focus, do what I need to do, then switch the focus back to GH. Lots of discussion on that topic here in the forum.

To get that code to work, set your type hints to Brep and Point3d respectively.

Lastly, while the RhinoCommon documentation does have mostly C#/VB examples, (almost) all the methods can be used with python. (it’s not a common case, but the “almost” statement applies to methods that use something called “out parameters” in C#. You can still use those as well, but python requires a few more steps). Edge case example here:

2 Likes