CGAL on Rhino8 ScriptEditor

Hi,

I recently made compas_cgal available for the Rhino 8 Script Editor.
It should generally work on most Mac, Windows, and Linux systems (outside Rhino).

Here are some examples: Examples — COMPAS CGAL

A GitHub Action builds this package for Python from 3.9 to 3.13 and uploads it to PyPI.
Therefore, the simple #r: tag should be the only command needed to install it.

I would be grateful if anyone could test whether it works. Here is a sample script for the ScriptEditor:


#! python3
# r: compas, compas_cgal

from compas.geometry import Box
from compas.geometry import Polyhedron
from compas.geometry import Sphere
from compas.datastructures import Mesh
from compas_cgal.booleans import (
boolean_difference_mesh_mesh,
boolean_intersection_mesh_mesh,
boolean_union_mesh_mesh,
split_mesh_mesh,
)

from compas_cgal.meshing import mesh_remesh
from compas.scene import Scene
box = Box(2)

A = box.to_vertices_and_faces(triangulated=True)

sphere = Sphere(1, point=[1, 1, 1])

B = sphere.to_vertices_and_faces(u=64, v=64, triangulated=True)

B = mesh_remesh(B, 0.3, 50)
V, F = boolean_difference_mesh_mesh(A, B)

shape = Polyhedron(V.tolist(), F.tolist())
shape = shape.to_mesh()

scene = Scene()
scene.clear_context()
scene.add(shape)
scene.draw()

It remeshes a sphere and performs mesh boolean-difference:

P.S. if anyone wants to contribute to compas_cgal package or just curious how the binding C++ to Python works, I am happy to share the little details behind this process :slight_smile:

@eirannejad ScriptEditor is really great and helps to bring a lot of things, we could not do before, thanks!

5 Likes

I’ve tested it on macOS with your script below and it doesn’t work. The compas module can’t be found, although my firewall reported a connection to PYPI.

1 Like

If you write this:

# r: compas, compas_cgal

Is there any difference?

1 Like

Yes, that fixed it.

2 Likes

AWESOME, thank you :slight_smile:

2 Likes

You’re welcome. This is very cool!

2 Likes

:sparkler: :fireworks:

Worked just fine here (Rhino 8 on Windows) :smiley: Thanks for all the work you put into this

1 Like

Thank you:)

1 Like