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
@eirannejad ScriptEditor is really great and helps to bring a lot of things, we could not do before, thanks!
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.
Hello, I’m struggling to load compas_CGAL script - any hints welcome!
Traceback (most recent call last):
File “file:///C:/Users/e43435/.rhinocode/stage/jm35ahfx.kw3”, line 10, in
File “C:\Users\e43435.rhinocode\py39-rh8\site-envs\default-xQiPWTEl\compas\datastructures_init_.py”, line 50, in
from .graph.graph import Graph
File “C:\Users\e43435.rhinocode\py39-rh8\site-envs\default-xQiPWTEl\compas\datastructures\graph\graph.py”, line 20, in
from compas.files import OBJ
File “C:\Users\e43435.rhinocode\py39-rh8\site-envs\default-xQiPWTEl\compas\files_init_.py”, line 17, in
from .xml import XML, XMLElement, XMLReader, XMLWriter, prettify_string # noqa: F401
File “C:\Users\e43435.rhinocode\py39-rh8\site-envs\default-xQiPWTEl\compas\files\xml.py”, line 6, in
import xml.etree.ElementTree as ET
File “C:\Users\e43435.rhinocode\py39-rh8\lib\xml\etree\ElementTree.py”, line 2085, in
from _elementtree import *
AttributeError: module ‘pyexpat’ has no attribute ‘expat_CAPI’
Yes, I was running your example code from the top of this thread.
The error was generated when importing, by this line of code: from compas.datastructures import Mesh