FreePySCAD Beta - Combining OpenSCAD and FreeCAD

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
User avatar
Kunda1
Posts: 9236
Joined: Thu Jan 05, 2017 9:03 pm

FreePySCAD Beta - Combining OpenSCAD and FreeCAD

Post by Kunda1 » Tue Nov 24, 2020 9:29 pm

You like OpenSCAD but you hate it at the same time? You can't work in FreeCAD because don't like wasting your time moving the mouse and clicking? FreePySCAD is for you!

note: it's in a beta stage right now. You can use it but some fucntions may have some restrictions (these should be indicated here or in the wiki). It needs the FreeCAD 0.19 version, because the text() function, but you may be able to use older ones if you don't use it.

How it works

FreePySCAD is a python library for FreeCAD to let user write their code in a text editor and see the result after a "compilation" process, like OpenSCAD but in FreeCAD.
To install the library, clone the github repository into the "FreeCAD X.xx/mod" directory
To write your code, you can open the FreeCAD macro editor and beginning your macro with
"from FreePySCAD.freepyscad import *"
You can also type in the python console "exec(open('path_to/my_pycad.py').read())", this has the advantage to show the errors. The geometry passed inside the scene().redraw(...) function will be added inside the current document, replacing everything.
Source: https://github.com/supermerill/FreePySCAD
Alone you go faster. Together we go farther
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features

User avatar
HakanSeven12
Posts: 1085
Joined: Wed Feb 06, 2019 10:30 pm

Re: FreePySCAD Beta - Combining OpenSCAD and FreeCAD

Post by HakanSeven12 » Wed Nov 25, 2020 10:22 am

Nice work ;) I like the idea

raymw
Posts: 81
Joined: Fri Sep 25, 2020 4:06 pm
Location: UK

Re: FreePySCAD Beta - Combining OpenSCAD and FreeCAD

Post by raymw » Sun Nov 29, 2020 3:08 pm

Not sure why it's openscad, with a different syntax.


Braces are replaced with parenthesis

The ; (semicolons) are replaced with , (commas) and is required to place it after ) if no other ) are directly after that to respect the python syntax.

Modifiers like translate, rotate must not be unattached. Use the parenthesis or a dot:

OpenSCAD: difference(){ translate([1,1,0]) cube(2); rotate([0,0,45]) cube(2); }
FreePySCAD: difference()( translate([1,1,0]).cube(2), rotate([0,0,45])(cube(2)),)

After more than 50 years, it's about time the software industry standardised its language.

User avatar
Zolko
Posts: 1189
Joined: Mon Dec 17, 2018 10:02 am

Re: FreePySCAD Beta - Combining OpenSCAD and FreeCAD

Post by Zolko » Tue Dec 01, 2020 1:33 pm

raymw wrote:
Sun Nov 29, 2020 3:08 pm
After more than 50 years, it's about time the software industry standardised its language.
obligatory XKCD reference:

Image
try the Assembly4 workbench for FreCAD v0.19
install with Tools > Addon Manager > Assembly4 — tutorials here and here

raymw
Posts: 81
Joined: Fri Sep 25, 2020 4:06 pm
Location: UK

Re: FreePySCAD Beta - Combining OpenSCAD and FreeCAD

Post by raymw » Wed Dec 02, 2020 12:42 pm

I have, in the past, imported openscad files into freecad, to fillet edges, etc, and export as stl. It mostly works. I would get annoyed in remembering ','s instead of ';' or whatever. While I'm having a whinge, when did it happen that if entering a numeric value, you have to first delete the original value? It is only in some software that is necessary, I noticed it first with Borland Delphi, iirc (unless you added a sr to take care of it). Freecad is similar. And then there is shift delete / insert, ctrl c / v not always being available.

Post Reply