tpaviot / pythonocc-core

Python package for 3D geometry CAD/BIM/CAM
GNU Lesser General Public License v3.0
1.28k stars 368 forks source link

Pythonocc and Flask #1325

Open cesarecaoduro opened 2 months ago

cesarecaoduro commented 2 months ago

I’m wondering if anyone has tried to create a REST api that exposes functionalities from pythonocc. Something similar to what Rhino Compute does with Rhino and Grasshopper. I’ve quickly tried today to create an endpoint to expose the creation of an edge based on 2 points, trying to use gp_Pnt as input type and TopoDS_Edge as return object, but obviously that didn’t work. Now I can create some DTO to wrap the coordinates of a point, but it becomes a lot more complex to start wrapping an edge. Ultimately I was trying to have a few endpoints to create a series of edges and pass them to another endpoint to create a wire, to finally extract a point along the wire. All of this pretty straight forward from a coding perspective, but not as straight forward if you want to create a geometry kernel as a service. Thoughts? This might really be game changer as I think also at the implication can have with other libraries like IfcOpenshell. Cheers!

tpaviot commented 2 months ago

As far as I know, there have been some limited scope services implemented, and it's quite easy. A wider scope REST API would certainly be more difficult, but the main question for me is: for what purpose? pythonocc is easily deployable on any machine, free to use and redistribute. I can't see any advantage in moving from a Python script that runs on my machine to a small granularity geometry service (e.g., make a set of points, then a spline, then extrude the spline) that would run in the cloud. This situation is different for dedicated services which are not part of pythonocc, require heavy computations, and could be offered as paid services in a saas mode.