Hello All,
How do I check if a point is within a solid brep using python?
I know that grasshopper has a component called “Point in Brep", but I am scripting in Python 3 (Rhino WIP), and I only have access to Rhino Common or Rhinoscript. In rhino script, there is a feature called (Rhino.IsObjectInBox(brick.ObjectId,boundingBox), but this only works with bounding boxes from my understanding, and not with breps that are trapezoidal.
I wrote the following code which also works for plan boxes as the bounding box, but I need to cover a wider range of cases.
def isBrickWithinBounds(brick,bounds):
boundsDict = getBoundingBoxMaximumsAndMinumums(boundingBox) #dict
bounds = [ [boundsDict['minX'], boundsDict['maxX']],
[boundsDict['minY'], boundsDict['maxY']],
[boundsDict['minZ'], boundsDict['maxZ']] ]
brickCentroid = rg.AreaMassProperties.Compute(brick).Centroid
if (not boundsDict['minX'] < brickCentroid.X < boundsDict['maxX']):
#print('outsideX')
return False
elif (not boundsDict['minY'] < brickCentroid.Y < boundsDict['maxY']):
#print('outsideY')
return False
elif (not boundsDict['minZ'] < brickCentroid.Z < boundsDict['maxZ']):
#print('outsideZ')
return False
return True