Candidate for OpenSCAD Workbench update.

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Candidate for OpenSCAD Workbench update.

Post by keithsloan52 »

Following on from the demo at the FOSDEM. day.

A new candidate for an update to the OpenSCAD workbench is available at https://www.dropbox.com/scl/fo/3lwah4w7 ... o58lus2t7z

Suggest you make copy of a FreeCAD installation and use the contents of the Dropbox directory to replace ...Mod/OpenSCAD

You need to add a Text parameter of 'externalEditor' value 'Path to editor'
via Tools | Edit Parameters to the Mod | OpenSCAD section.

Only tested on MacOS so far. Would really value feedback if changes are required for using an external editor with other OS's

Looking for some icon designs

If you click on the first X this will create a SCADObject
Image 07-02-2023 at 16.33.jpg
Image 07-02-2023 at 16.33.jpg (241.61 KiB) Viewed 2794 times
If you toggle the edit property to True - It will fire up the external editor
When happy with source use editor file option.

If you then toggle the execute property to True it will send the source to OpenSCAD and create the SCADObjects Shape.
Each SCADObject can have its own maxfn property. ( Controls when to create circles, cylinders versus polygons etc)

If you set the mode property to 'Mesh' then rather than get a CSG file back from OpenSCAD it will get an STL file that it converts into the SCADObjects Shape. i.e. If you know the SCAD code contains Hulls and Minkowski operations, this will probably be quicker than trying to create a CSG and the importer has to do the Meshing for the Hulls & Minkowski's

Further work to be done.

Happy Testing
  • [*} Add externalEditor option to Workbench Preference
  • SCADModules
  • Import SCAD Source
  • Export SCAD Source
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: Candidate for OpenSCAD Workbench update.

Post by keithsloan52 »

Not had any feedback after FOSDEM

But the Alternate OpenSCAD importer has facilities for SCADObjects added
see https://github.com/KeithSloan/OpenSCAD_ ... ort#readme

Screenshot of using
  • SCADObjects
  • OpenSCAD external editor
  • FreeCAD external editor
That is SCAD source can be edited and previewed in OpenSCAD preview Window.
When happy with source, toggle the Objects execute property to update in FreeCAD

Image
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: Candidate for OpenSCAD Workbench update.

Post by keithsloan52 »

Just fixed a bug reported by Nick-Z0

He reported it in the Issue #4 OpenSCAD executable unavailable but it was a bug with ScadFileObject (importFileSCAD) and property modules=True

Should be fixed in latest version.
User avatar
chennes
Veteran
Posts: 3878
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Candidate for OpenSCAD Workbench update.

Post by chennes »

I feel like to get this really polished up and potentially into master, we need to come up with a solution to the "Execute" property thing. What about making a task panel for editing the code of the object? That seems to be a more "FreeCAD" way of doing things. You could potentially even go full "Macro editor" on it.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: Candidate for OpenSCAD Workbench update.

Post by keithsloan52 »

chennes wrote: Wed Feb 22, 2023 10:23 pm I feel like to get this really polished up and potentially into master, we need to come up with a solution to the "Execute" property thing. What about making a task panel for editing the code of the object? That seems to be a more "FreeCAD" way of doing things. You could potentially even go full "Macro editor" on it.
Nope : the advantage of an external editor is that OpenSCAD can be setup to use the same external editors, visual-code, Emacs to name just a few of the editors that they have supported for the last number of years, so they have preview from the editors, syntax editing, cheatsheets and a whole host of other goodness, a FreeCAD panel editor is just not going to compare.

See https://github.com/Antyos/vscode-openscad

We might even be able to persuade the editor developers to add key stokes to send info back to FreeCAD via the Pipes, so that when the user is happy with the code ( Preview in OpenSCAD is a lot faster than other ways of viewing) they press a keystroke and the SCADObject updates.
User avatar
chennes
Veteran
Posts: 3878
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Candidate for OpenSCAD Workbench update.

Post by chennes »

I don’t understand why having a task panel precludes supporting external editors. Just because we support external editors doesn’t mean no one will ever want to edit within FreeCAD. We need a nice way of triggering a reload in any case.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: Candidate for OpenSCAD Workbench update.

Post by keithsloan52 »

chennes wrote: Thu Feb 23, 2023 1:54 am I don’t understand why having a task panel precludes supporting external editors. Just because we support external editors doesn’t mean no one will ever want to edit within FreeCAD. We need a nice way of triggering a reload in any case.
So how would one invoke the task panel? Have an icon that opens the panel when a single suitable object is selected?
The Panel is the same as Add Elements with an extra button that is external edit? Also a button to fetch the source from the external file
and refresh the source in the task panel. Personally I don't like the possibility of an object having source in a FreeCAD task panel AND in an external editor, too easy for them to get out of sync. What if I have a number of SCADObjects in FreeCAD document a task panel each?
Even if you made the editor either FC or external you would still need task panel for error/parsing messages. If one of the aims would be
to get the stage where the external editor could initiate an update with a keystroke or icon ( see current editor addon for OpenSCAD etc)
easier to have an update of the objects property window if more than one object edit was open.
I was thinking looking at adding facilities to access SCAD Libraries, display Modules within Library, Module Comments etc.
Take the OpenSCAD library gears as an example https://github.com/Dtays-meanderings/gears could end up with a lot of task panels.

I much prefer that a new Property was implemented that was App::PropertyAction, for its value it displays a mini icon and clicking on the
icon/property drives the OnChange function. Parsing error message as a PropertyString as per I have done it so far, you can see the latest state of the Object, For multiple SCADObjects in a document no need for multiple task panels or multiplexing on a single panel. Execute and message in the same panel ( Objects property)
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: Candidate for OpenSCAD Workbench update.

Post by keithsloan52 »

I think my current problem with the update to the message property not being reflected in the display may go away if I was able to use an PropertyAction. The message property is getting changed as a result of a edit or execute Boolean property changing. With a PropertyAction there would be no need for any change its display so if it causes the message property to change there is only one property being changed i.e avoiding any conflict. I think it would be worth asking wmayer realthunder to see if I am correct.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Candidate for OpenSCAD Workbench update.

Post by adrianinsaval »

how about a command to update the selected object? From a user perspective changing a property to get and object updated seems odd and cumbersome. When you trigger a recompute is the object not updated unless you change the execute property?
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: Candidate for OpenSCAD Workbench update.

Post by keithsloan52 »

adrianinsaval wrote: Thu Feb 23, 2023 12:09 pm When you trigger a recompute is the object not updated unless you change the execute property?
Naming the property execute was probably not the best idea, open to better suggestions. With a SCADObject you have it's Shape if there is a recompute, I don't see why one would need to reprocess the SCAD source, which is what changing the the execute property to True does.
I don't think that reprocessing the SCAD source if something else in the document drives a recompute of the object is a good idea.
Post Reply