CadQuery via FreeCAD cmd

514 views
Skip to first unread message

Michael Hoffer

unread,
Feb 8, 2017, 6:01:25 PM2/8/17
to CadQuery
Hi,

is it possible to use cadquery via ./FreeCADCmd myscript.py ? The example scripts don't seem to work since the cadquery module is not found:

$> ./FreeCADCmd  script.py

FreeCAD 0.16, Libs: 0.16R6706 (Git)

(c) Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2015

  #####                 ####  ###   ####  

  #                    #      # #   #   # 

  #     ##  #### ####  #     #   #  #   # 

  ####  # # #  # #  #  #     #####  #   # 

  #     #   #### ####  #    #     # #   # 

  #     #   #    #     #    #     # #   #  ##  ##  ##

  #     #   #### ####   ### #     # ####   ##  ##  ##


Exception while processing file: script.py [No module named cadquery]


The script.py contains the basic "box" sample that comes with cadquery.

Regards,
Michael




jmwright

unread,
Feb 8, 2017, 6:59:15 PM2/8/17
to CadQuery
Hi Michael, and welcome to the community. You'll probably have to add the path to the CadQuery library too your sys path. There's an example of how to do this in the CadQuery FreeCAD module.

Something like this: https://github.com/jmwright/cadquery-freecad-module/blob/master/CadQuery/InitGui.py#L55

Michael Hoffer

unread,
Feb 14, 2017, 6:10:37 PM2/14/17
to CadQuery
Thanks. That worked. BTW: I am developing visual programming environments that also support algorithmic 3d modeling. The reason why I'm testing CadQuery is that I need a high quality CAD engine. Could I use OpenCascade + CadQuery without a full FreeCad dependency?

Here are some examples:

  


Regards,
Michael

jmwright

unread,
Feb 14, 2017, 9:42:46 PM2/14/17
to CadQuery
Very cool. Is that code publicly available? I'd like to try it out if possible. How do you envision the software being used? What's your goal with it?

Right now CadQuery 0.x (which will be renumbered to 1.x eventually) is FreeCAD only. However, Dave has set up a new branch for a PythonOCC only version. https://github.com/dcowden/cadquery/tree/2_0_branch 

Dave has also done work on setting up a Docker image that has everything installed for the PythonOCC version of CadQuery.

You can also program straight in PythonOCC, but it's fairly cumbersome to do so in my experience. I created a script to set up OCE and PythonOCC from scratch on Ubuntu Linux if you're interested, but I haven't updated it in awhile. I'm not positive it will work in Ubuntu 16.04/16.10. https://github.com/jmwright/pythonocc_oce_setup

Let us know what your needs are and we can discuss whether or not our future direction will do what you are looking for.

Dave Cowden

unread,
Feb 15, 2017, 7:19:44 AM2/15/17
to Michael Hoffer, CadQuery
wow that's a cool project! thanks @jmwright for jumping in.

 Its definitely a sad truth that whether you use OCC or FreeCAD or both, deployment is a real pain. i think easily running and deploying is a key consideration-- a lot of users simply never get started because it is too difficult.

I'd like to learn more about how you're planning to deploy. Maybe i can help. As @jmwright says, i've gone through the steps myself, so that i could build a docker container. 

--
cadquery home: https://github.com/dcowden/cadquery
post issues at https://github.com/dcowden/cadquery/issues
run it at home at : https://github.com/jmwright/cadquery-freecad-module
see it in action at http://www.parametricparts.com
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/a219cf4e-4f2b-4f76-86ab-3f2ccab2e965%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Michael Hoffer

unread,
Feb 15, 2017, 10:27:16 AM2/15/17
to CadQuery, michi...@gmail.com
My goal is a bidirectional general purpose programming environment that works visually and textually at the same time. It is so much more fun to work with such an IDE :) It is by no means limited to CAD or geometry generation. But CAD is a very nice use case for it. The cool thing is that it gives you visual access to the runtime data of the code. The visualization that you use for the editor can actually be used for creating end-user interfaces.

The result of the first iteration of this approach is VRL-Studio which is an open source IDE that is used by several universities for teaching, rapid prototyping and for managing complex simulation workflows. The third picture shows the next prototype I'm currently working on which allows much deeper visualization and interaction with the code. It makes heavy use of ASTs and language models.

Very cool. Is that code publicly available? I'd like to try it out if possible. How do you envision the software being used? What's your goal with it?

You can download VRL-Studio at vrl-studio.mihosoft.eu. It comes with some examples. Two of them cover CSG algorithms. The CSG algorithms itself is hosted at: https://github.com/miho/JCSG. But is probably not interesting for you since it can't compete with a CAD engine. The reason for me to develop JCSG was to get some CAD/CSG functionality that is easy to deploy. For my language research it worked okay. But now I need more :)

 Its definitely a sad truth that whether you use OCC or FreeCAD or both, deployment is a real pain.

Oh, that's bad news :( Easy deployment is very important for my use case. 

a lot of users simply never get started because it is too difficult.

It is THE key feature. I have experienced that many times. If your app/library is hard to install, people will choose something else even if you have the better solution.

I'd like to learn more about how you're planning to deploy.

For me the ideal solution would be a static executable that I can talk to via RCP or scripting and file i/o. I don't like to dynamically load the native libraries since the CAD engine should run in isolation. Having it in it's own process has many benefits for me. Another key point is that the CAD engine should run on all major desktop platforms. The problem that I currently see is that there are no binary standard distributions for each platform.

Regards,
Michael



Am Mittwoch, 15. Februar 2017 13:19:44 UTC+1 schrieb thebluedirt:
wow that's a cool project! thanks @jmwright for jumping in.

 Its definitely a sad truth that whether you use OCC or FreeCAD or both, deployment is a real pain. i think easily running and deploying is a key consideration-- a lot of users simply never get started because it is too difficult.

I'd like to learn more about how you're planning to deploy. Maybe i can help. As @jmwright says, i've gone through the steps myself, so that i could build a docker container. 
On Tue, Feb 14, 2017 at 6:10 PM, Michael Hoffer <michi...@gmail.com> wrote:
Thanks. That worked. BTW: I am developing visual programming environments that also support algorithmic 3d modeling. The reason why I'm testing CadQuery is that I need a high quality CAD engine. Could I use OpenCascade + CadQuery without a full FreeCad dependency?

Here are some examples:

  


Regards,
Michael



Am Donnerstag, 9. Februar 2017 00:59:15 UTC+1 schrieb jmwright:
Hi Michael, and welcome to the community. You'll probably have to add the path to the CadQuery library too your sys path. There's an example of how to do this in the CadQuery FreeCAD module.

Something like this: https://github.com/jmwright/cadquery-freecad-module/blob/master/CadQuery/InitGui.py#L55

--
cadquery home: https://github.com/dcowden/cadquery
post issues at https://github.com/dcowden/cadquery/issues
run it at home at : https://github.com/jmwright/cadquery-freecad-module
see it in action at http://www.parametricparts.com
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.

Dave Cowden

unread,
Feb 15, 2017, 7:36:20 PM2/15/17
to Michael Hoffer, CadQuery

On Wed, Feb 15, 2017 at 10:27 AM, Michael Hoffer <michi...@gmail.com> wrote:
For me the ideal solution would be a static executable that I can talk to via RCP or scripting and file i/o. I don't like to dynamically load the native libraries since the CAD engine should run in isolation. Having it in it's own process has many benefits for me. Another key point is that the CAD engine should run on all major desktop platforms. The problem that I currently see is that there are no binary standard distributions for each platform.

​would you consider running a docker container? I'm fairly confident in saying that pretty much all 'capable' CAD kernels, commercial or not, require native code at this point-- which means DLLs for windows and shared libs for *nix.  

Docker containers are the only thing even close to binary portability. 

that said, CQ 1.x meets your requirements. FreeCAD is availale on all platforms, and then cq is just python code. You would still have quite a list of things to install, though:

   Python
   freecad
   vrl-studio ( and its dependencies)
   cadquery ( or cadquery-freecad-module)

jmwright

unread,
Feb 15, 2017, 7:52:14 PM2/15/17
to CadQuery, michi...@gmail.com
Another possibility to deal with the dependency complexity problem is to do what I did with the FreeCAD module. I dumped copies of all of the dependencies into a directory and then added that directory to the sys path for Python. That works well, and keeps people from having to worry about the deps when they install the module. The main drawback is that you have to keep those packages updated manually.



On Wednesday, February 15, 2017 at 7:36:20 PM UTC-5, thebluedirt wrote:

Michael Hoffer

unread,
Feb 16, 2017, 5:47:27 AM2/16/17
to CadQuery, michi...@gmail.com
I'm fairly confident in saying that pretty much all 'capable' CAD kernels, commercial or not, require native code at this point-- which means DLLs for windows and shared libs for *nix.  

Sure, the point is not wether the project itself consists of/uses native code. Many of my dependencies contain native packages. But for large projects such as CAD kernels I prefer running them in separate processes. So, in general I am not against docker containers. I just have no experience with docker on different platforms.  

that said, CQ 1.x meets your requirements.

Absolutely true.I was just a little discouraged by FreeCads size. And then, the FreeCadCmd actually requires all or at least most of the ui libraries (I tried to remove the Qt Gui *.ddl/*.so libs which immediately resulted in broken dependencies). So it is not a clean approach. The other thing is that in FreeCad it is not always clear whether commands do work in the headless environment or not. The best example here is my initial question on how to run CQ with FreeCadCmd. If CQ treats FreeCadCmd and FreeCad equally well, I could probably go with FreeCad.

Another possibility to deal with the dependency complexity problem is to do what I did with the FreeCAD module.

And then I would add your module and all the dependencies to the mix :) For my users it would just be one fat download of a VRL-Studio plugin. 

But I'd still prefer a real standalone OpenCascade/CQ distribution. And if I understood correctly, there's something in the pipeline, correct?

Dave Cowden

unread,
Feb 16, 2017, 6:37:28 AM2/16/17
to Michael Hoffer, CadQuery
Yes, an OCC/cq native solution is planned, but delivery is far away. Removing freecad requires a complete rewrite of C Q. The new version will be more capable, and of course the download size smaller.

It will probably be distributed as a conda package or as a docker container. pythonOCC +OCE  is itself distributed as a conda package.

--
cadquery home: https://github.com/dcowden/cadquery
post issues at https://github.com/dcowden/cadquery/issues
run it at home at : https://github.com/jmwright/cadquery-freecad-module
see it in action at http://www.parametricparts.com
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/4a954e17-b3f8-47de-a564-a6fb045d753f%40googlegroups.com.

jmwright

unread,
Feb 16, 2017, 8:02:12 AM2/16/17
to CadQuery, michi...@gmail.com
And then, the FreeCadCmd actually requires all or at least most of the ui libraries (I tried to remove the Qt Gui *.ddl/*.so libs which immediately resulted in broken dependencies).

We've had at least one occasion where one of our community members wanted to add a feature to CadQuery, but were stopped because the functionality they needed was tangled up with the FreeCAD GUI.


On Thursday, February 16, 2017 at 6:37:28 AM UTC-5, thebluedirt wrote:
Yes, an OCC/cq native solution is planned, but delivery is far away. Removing freecad requires a complete rewrite of C Q. The new version will be more capable, and of course the download size smaller.

It will probably be distributed as a conda package or as a docker container. pythonOCC +OCE  is itself distributed as a conda package.

Dave Cowden

unread,
Feb 16, 2017, 9:10:41 AM2/16/17
to jmwright, CadQuery, Michael Hoffer
Your requirements are that you have to have multi-platform, and you want cadquery/OCC. You also want to make your own gui.

What if we stood up a cadquery web service that allows you to execute cq scripts and get the results via a web service?  then, you would need to distribute nothing, and you could easily support all the platforms you want.

If we could iron our an interface that works, this is something i could do fairly quickly.  


Michael Hoffer

unread,
Feb 16, 2017, 10:46:57 AM2/16/17
to CadQuery, wrig...@gmail.com, michi...@gmail.com
Good idea. But we would still need a local version that works on all major platforms. For example, one group is located in China. Their internet connection is so bad that even downloading small things can be a pain. Another problematic groups of potential users comes from computing centers where most nodes are only reachable via intranet. Only a very narrow set of ports/services is allowed to connect to the internet on these machines. But the interface you propose could be used for both, the local and for the web service version.

The reason why OpenScad is so widely used is not because it has a powerful CAD engine but because users can install it with almost no effort. Personally, I still don't like it because quality wise (both, language and CAD) it is not the best solution.

One thing that should be done is a regular OpenCascade release cycle for binary distributions with a minimal set of dependencies. This would highly increase it's popularity. I don't know the OpenCascade community well enough. Are there other communities, except FreeCad, who distribute OpenCascade?



To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.

--
cadquery home: https://github.com/dcowden/cadquery
post issues at https://github.com/dcowden/cadquery/issues
run it at home at : https://github.com/jmwright/cadquery-freecad-module
see it in action at http://www.parametricparts.com
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.

Dave Cowden

unread,
Feb 16, 2017, 11:54:42 AM2/16/17
to Michael Hoffer, CadQuery, Jeremy Wright
yeah OpenSCAD is terrible language and capability wise-- its the main reason i wrote CQ. 

But sadly, this is a case where you simply cant have your cake and eat it too. Real CAD kernels are complex, and have a lot of code.

Opencascade is distrubted with a python wrapper via pythonOCC. I know Thomas Pavoit over there-- who leads both that project and the OCE project.

The project produces a python conda package that cleanly and quickly installs pythonOCC and OCE. 


This is currently the best way to install OCE if you want a local, easy install. but you first need to isntall conda ( i'd recommend mini-conda).



To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/88f67a8d-6bfd-4455-bc86-3c7bc97cdcaf%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages