Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?

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!
duckmug
Posts: 95
Joined: Mon Jun 07, 2021 12:26 am

Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?

Post by duckmug »

Something offtopic, I came across this addon of yours as well: https://github.com/KeithSloan/toSketch

I've installed it via the addon manager but there is no workbench showing up.

I am on the latest version of Freecad. Is it out of date? That is such a neat concept, not sure how it compares to mesh remodel workbench.
keithsloan52
Posts: 2089
Joined: Mon Feb 27, 2012 5:31 pm

Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?

Post by keithsloan52 »

duckmug wrote: Wed Jun 16, 2021 9:26 am I had no idea that this was around, I am so glad, will be definitely using it.

What makes it restricted to two spheres or two cylinders etc?

Why not support a combination of a cylinder and a cube for instance?
Whilst there are algorithms for Hull of Mesh's not so easy for Brep shapes.
Not easy to make generic, so plan was/is to test for certain cases and hull those.
Cylinder and cube might be possible with lofts but not easy for the generic case where
they may not be aligned, same rotation etc etc.

Anyway have to start somewhere
duckmug
Posts: 95
Joined: Mon Jun 07, 2021 12:26 am

Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?

Post by duckmug »

keithsloan52 wrote: Wed Jun 16, 2021 11:47 am
duckmug wrote: Wed Jun 16, 2021 9:26 am I had no idea that this was around, I am so glad, will be definitely using it.

What makes it restricted to two spheres or two cylinders etc?

Why not support a combination of a cylinder and a cube for instance?
Whilst there are algorithms for Hull of Mesh's not so easy for Brep shapes.
Not easy to make generic, so plan was/is to test for certain cases and hull those.
Cylinder and cube might be possible with lofts but not easy for the generic case where
they may not be aligned, same rotation etc etc.

Anyway have to start somewhere
Indeed, I applaud the effort, well worth it.
keithsloan52
Posts: 2089
Joined: Mon Feb 27, 2012 5:31 pm

Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?

Post by keithsloan52 »

duckmug wrote: Wed Jun 16, 2021 10:03 am Something offtopic, I came across this addon of yours as well: https://github.com/KeithSloan/toSketch

I've installed it via the addon manager but there is no workbench showing up.

I am on the latest version of Freecad. Is it out of date? That is such a neat concept, not sure how it compares to mesh remodel workbench.
Works on my 0.19.1 version

Code: Select all

OS: macOS 10.15
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24276 (Git)
Build type: Release
Branch: (HEAD detached at 0.19.1)
Hash: a88db11e0a908f6e38f92bfc5187b13ebe470438
Python version: 3.8.8
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.4.0
Locale: C/Default (C)
AADD5077-43FE-4068-BF48-6CB11BE8E24C_4_5005_c.jpeg
AADD5077-43FE-4068-BF48-6CB11BE8E24C_4_5005_c.jpeg (40.64 KiB) Viewed 836 times
duckmug
Posts: 95
Joined: Mon Jun 07, 2021 12:26 am

Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?

Post by duckmug »

Doesn't work over here, I have the latest freecad version from the freecad repositories on ubuntu.

Code: Select all

OS: Ubuntu 20.04.2 LTS (ubuntu:GNOME/ubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Branch: unknown
Hash: 9e3b630bbfb6807e93eeffb655e6c20f218644fc
Python version: 3.8.5
Qt version: 5.12.8
Coin version: 4.0.0
OCC version: 7.5.1
Locale: English/United States (en_US)
I followed these steps:

Code: Select all

Using Addon Manager

Click on Configure
Enter https://github.com/KeithSloan/toSketch.git
It appeared to have installed fine, but the workbench is nowhere to be seen.

Do you want me to supply anything further?
keithsloan52
Posts: 2089
Joined: Mon Feb 27, 2012 5:31 pm

Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?

Post by keithsloan52 »

duckmug wrote: Wed Jun 16, 2021 11:53 am Doesn't work over here, I have the latest freecad version from the freecad repositories on ubuntu.

Code: Select all

OS: Ubuntu 20.04.2 LTS (ubuntu:GNOME/ubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Branch: unknown
Hash: 9e3b630bbfb6807e93eeffb655e6c20f218644fc
Python version: 3.8.5
Qt version: 5.12.8
Coin version: 4.0.0
OCC version: 7.5.1
Locale: English/United States (en_US)
I followed these steps:

Code: Select all

Using Addon Manager

Click on Configure
Enter https://github.com/KeithSloan/toSketch.git
It appeared to have installed fine, but the workbench is nowhere to be seen.

Do you want me to supply anything further?
While since I used Ubuntu.

Suggest you check your .FreeCAD directory(note the dot). Does it contain a Mod sub directory?
If yes, what sub directories does it have?

You could always goto/create .FreeCAD/Mod and then

Code: Select all

git clone https://github.com/KeithSloan/toSketch.git
Worth also checking Report View for startup messages and any errors.
duckmug
Posts: 95
Joined: Mon Jun 07, 2021 12:26 am

Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?

Post by duckmug »

You could always goto/create .FreeCAD/Mod and then

git clone https://github.com/KeithSloan/toSketch.git
This worked!

So I think it is safe to assume something is broken with the addon manager approach.

I think this would have tremendous potential if it was doing automatic recognition of what the contents actually are.

For example right now it recognizes a circle as a bunch of lines instead of a circle.

I suppose the same issue also exist for arcs, curves etc.

Looking at the code, I see that you add circles as circles provided that they are identified as such.

Unfortunately this will not be the case when trying to reverse engineer an stl->step as the circle will be a bunch of lines.
keithsloan52
Posts: 2089
Joined: Mon Feb 27, 2012 5:31 pm

Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?

Post by keithsloan52 »

duckmug wrote: Thu Jun 17, 2021 1:23 am
You could always goto/create .FreeCAD/Mod and then

git clone https://github.com/KeithSloan/toSketch.git
This worked!

So I think it is safe to assume something is broken with the addon manager approach.

I think this would have tremendous potential if it was doing automatic recognition of what the contents actually are.

For example right now it recognizes a circle as a bunch of lines instead of a circle.

I suppose the same issue also exist for arcs, curves etc.

Looking at the code, I see that you add circles as circles provided that they are identified as such.

Unfortunately this will not be the case when trying to reverse engineer an stl->step as the circle will be a bunch of lines.
The plan was when a section is/was created a bezier curve fit is performed. Not sure how far I got going down that line.
i.e. where it finds a straight line it becomes a straight line and where n points a bezier curve.
IPowIPi
Posts: 31
Joined: Sun Jul 25, 2021 9:37 am

Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?

Post by IPowIPi »

Before opening a new topic for this, just a check whether this is related to this "hull is known not to work in many cases" scenario.
Trying to import the OpenSCAD file below. When importing it with round_corners = false it works, with round_corners = true then FreeCAD throws an error message like that (and renders no object):

...
18:48:28 End Parser
18:48:28 [<Part::PartFeature>]
18:48:28 End processing CSG file
18:48:28 Traceback (most recent call last):
File "C:\Program Files\FreeCAD 0.19\Mod\OpenSCAD\OpenSCADFeatures.py", line 508, in execute
raise ValueError
<class 'ValueError'>:

Is this normal (because hulls over round shapes aren't supported in general) or more a bug?

My goal is to get a STEP file with round (non-approximated surfaces) from an OpenSCAD file like this.
Edit: Also tested with 0.20 daily and RT stable/daily - same result for all variants.


//OpenSCAD script:

roundness = 5;
round_corners = true; // can be imported in FreeCAD when this is false, an error is thrown during import when true

module rect(width, height) {
translate([-width / 2, -height / 2])
cube([width, height, 1]);
}

module sphereRect(width, height) {
if(round_corners) {
translate([-width / 2 + roundness, -height / 2 + roundness])
sphere(roundness);
translate([width / 2 - roundness, -height / 2 + roundness])
sphere(roundness);
translate([width / 2 - roundness, height / 2 - roundness])
sphere(roundness);
translate([-width / 2 + roundness, height / 2 - roundness])
sphere(roundness);
} else {
rect(width, height);
}
}

hull() {
sphereRect(50, 50);
translate([0, 0, 50])
sphereRect(50, 50);
}
keithsloan52
Posts: 2089
Joined: Mon Feb 27, 2012 5:31 pm

Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?

Post by keithsloan52 »

I get the same problem with the standard OpenSCAD importer ( importCSG ) in FreeCAD 0.19.1.
Chris @chennes has made some fixes which are in FreeCAD 0.20 but you say you tested 0.20
Are you sure you have the Latest 0.20? Might help to post your FreeCAD information.

Anyway I used the Alternate Importer https://github.com/KeithSloan/OpenSCAD_Alt_Import
and it imported fine
FC93F099-1BC3-4A21-AA33-A0871DA930F3.jpeg
FC93F099-1BC3-4A21-AA33-A0871DA930F3.jpeg (56.17 KiB) Viewed 389 times
Your code pasted to a scad file
valueError.scad
(726 Bytes) Downloaded 9 times
ValueError.FCStd
(169.3 KiB) Downloaded 7 times
I exported to step but it was not very successful.
ValueError-hull.step
(7.84 KiB) Downloaded 9 times
By changing the FreeCAD STEP preferences for Import/Export so that export used the legacy exporter, I got success
ValueError-hull-2.step
(995.21 KiB) Downloaded 8 times
Post Reply