cadquery-freecad-module icon indicating copy to clipboard operation
cadquery-freecad-module copied to clipboard

Update to support of CQ 2.0

Open KeithSloan opened this issue 5 years ago • 8 comments

How feasible is it to update this workbench to work with CQ 2.0 which uses PythonOCC? Clearly you cannot have python that is using PythonOCC outputing directly to a FreeCAD window. I know that Part has Part.toPythonOCC() and Part.fromPythonOCC() to exchange TopoDS_Shape entities to/from pythonOCC, would it be possible to put wrappers round things? I know the answer should be to look at the code, but would like somebody who is already familiar with the code to comment on feasibility of doing this before investigating further.

KeithSloan avatar Jan 28 '20 16:01 KeithSloan

@KeithSloan

Background/History

When CQ 2.0 was in the earlier stages my plan was to update this workbench, and part of that was going to be using toPythonOCC and fromPythonOCC. However, as other options became available such as CQ-editor and jupyter-cadquery, and the community didn't seem to be asking for the things this workbench provides, it became harder to justify upgrading this. With that said, I still think good integration and interop with FreeCAD is a good thing.

Technical

It did not take a lot to update cadquery-gui for CQ 2.0 because CQGI works the same way. I expect that most of the work on this workbench would be done here. If you're interested in putting together a PR, it would be nice if the user could select between CQ versions (default to CQ 1.0) instead of being forced to upgrade to CQ 2.0. CQ 2.0 wouldn't be the "batteries included" experience that users of this workbench have come to expect. The settings dialog code is here where a CQ version setting could be added.

jmwright avatar Jan 28 '20 20:01 jmwright

I had a look at "here" and the only thing I saw was newFeature.Shape = cqObject.toFreecad()

So I assume that cg already does some conversion to FreeCAD Shape and I need to look at the cgObject implementation

KeithSloan avatar Jan 29 '20 12:01 KeithSloan

toFreecad is from CQ 1.0. There's no equivalent in CQ 2.0. I imagine that code would have to change to something like:

newFeature.Shape = Part.fromPythonOCC(cqObject.val().wrapped)

But that's just off the top of my head. I also may be missing other changes that will have to be made, but that's where I would start.

jmwright avatar Jan 29 '20 13:01 jmwright

I was wondering about this thing for a few days before arriving to this thread. CQ-editor may be more than ideal as a primary editor but freecad is a much broader tool, so it makes total sense for CQ to have a shelter there as well.

ghost avatar May 15 '21 02:05 ghost

@infosisio I spent some time looking into it, but the main problem I ran into was that FreeCAD would not use an Anaconda environment, so it's very hard to experiment with it. I don't have a lot of time to spend on this ATM, but am supportive of the community working on it. I would like to see CadQuery and FreeCAD integrated again.

jmwright avatar May 15 '21 03:05 jmwright

@jmwright Got it!

ghost avatar May 15 '21 03:05 ghost

The latest beta version of cadquery now supports being used without conda / with pip

pip install cadquery==2.2.0b0

Hecatron avatar Jul 17 '22 11:07 Hecatron

@grbd Thanks for pointing that out. This main branch needs more than just installing CQ 2.x, and so I have been pointing people to this fork. Tagging @jpmlt to make sure the pip install line above is seen for that fork.

jmwright avatar Aug 03 '22 11:08 jmwright