Add 'plane_brep intersection' method

Just found in compas.geometry, there is no intersection_plane_brep like Rhino.Geometry.Intersect.Intersection.BrepPlane method in Rhino API. This function would be useful for slicing objects in additive printing, or other fabrication scenarios. Hope this function could be added.


yes, that would indeed be useful.
if you add a feature request to the issue tracker it will probably be added soon…

however, perhaps it is worth mentioning that brep/plane intersections and other brep operations are part of the BRep API which is available here

through the pluggable/plugin mechanism, it will receive implementations from different plugins in different environments.

the plugin for Rhino currently doesn’t implement the slice method yet, but the one for “not Rhino” should already provide this functionality…

perhaps the explanation is a bit abstract. will add an example soon…

Thanks for the reply! A feature request has been added in compas-dev / compas.

Yes, the functionality of the compas.geometry.Brep.slice is exactly what we need, although it is a bit hidden and not categorized in compas.geometry.intersection.

As you mentioned and I tested, compas.geometry.Brep.slice doesn’t work on Rhino, and it returns Null. Additionally, the whole Brep class requires the plugin system and cannot be easily used by us. The common errors are

line 486, in select_plugin
raise PluginNotInstalledError(“Plugin not found for extension point URL: {}”.format(extension_point_url))
compas.plugins.PluginNotInstalledError: Plugin not found for extension point URL: https:/

Hope it can be upgraded soon! :slight_smile:

Hi Zac!

I’m not sure entirely sure what the difference is, but for the off chance it’s just the name (@brgcode ?) the RhinoBrep plugin for Brep has a .trim() method (in docs) Maybe that’s what you’re looking for?

Otherwise, if you could specify what the difference is, I’ll make sure to add it soon.


BTW the PluginNotInstalledError you’re getting when using compas.geometry.Brep outside of Rhino is expected as, at the moment, the only plugin implementation is for Rhino.

There is a COMPAS wrapper for brep available for use outside Rhino which uses OCCT’s as a backend. However, it cannot yet be used with compas.geometry.Brep and you’d have to use compas_occ.brep.BRep directly.
See here for more info on that.


Hi Chen! Thanks for the reply.

To specifically describe it, I was hoping to find a method which could input Brep and Plane/Frame, then output the intersection curves as a list of a curve or similar types. It is neither getting the BrepFace in Brep.slice nor erasing one part of the Brep in Brep.trim. The Brep.slice is actually close enough and can be an alternative.

The Intersection.BrepPlane Method in Rhino API is the ideal one, and I hope the below C# example could show what I mean:

    //Construct a geometry demo
    Plane plane = new Plane(new Point3d(0, 0, 1), new Vector3d(0, 0, 1));
    Box box = new Box(Plane.WorldXY, new Interval(-1, 1), new Interval(-1, 1), new Interval(-1, 1));
    Brep brep = box.ToBrep();

    // Outputs
    Curve[] intersectionCurves;
    Point3d[] intersectionPoints;

    // Intersection method
    Rhino.Geometry.Intersect.Intersection.BrepPlane(brep, plane, 0.01, out intersectionCurves, out intersectionPoints);

    // Visualize in Rhino
    A = intersectionCurves;

One typical scenario is slicing a brep object for printing path planning, which is basically a simplified compas slicer.


Unfortunately, the compas.geometry.Brep.slice doesn’t work on my device and keep returning Null. Below is the test code I used.

import compas.geometry as cg

plane = cg.Plane([0, 0, 0.5], [0, 0, 1])
box = cg.Box(cg.Frame(cg.Point(0, 0, 0), cg.Vector(1, 0, 0), cg.Vector(0, 1, 0)), 2, 2, 2)
brep = cg.Brep.from_box(box)

# slice
slice = brep.slice(plane)

print (slice)
print (type(slice))

>>><type 'NoneType'>

Thanks for reminding me of the compas_occ.brep.BRep and I will check it out soon! :slight_smile:


since the BREP pluggables/plugins are not fully implemented yet, you currently still have to use the non-Rhino version from the implementing backend (compas_occ) directly.

the following should work if you have compas_occ installed.
note the different spelling of the pluggable (compas.geometry.Brep) and the plugin (compas_occ.brep.BRep). we will iron out these differences in the near future.

>>> from compas.geometry import Plane, Frame, Box
>>> from compas_occ.brep import BRep
>>> plane = Plane([0, 0, 0.5], [0, 0, 1])
>>> box = Box(Frame([0, 0, 0], [1, 0, 0], [0, 1, 0]), 2, 2, 2)
>>> brep = BRep.from_box(box)
>>> brep.slice(plane)
<compas_occ.brep.brep.BRep object at 0x18838ccd0>

let me know if you still have problems.

1 Like

Thanks for the support!