Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Be nice to others! Read the FreeCAD code of conduct!
Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?
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.
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.
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?
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
Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?
Indeed, I applaud the effort, well worth it.keithsloan52 wrote: ↑Wed Jun 16, 2021 11:47 amWhilst 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
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?
Works on my 0.19.1 versionduckmug 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.
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)
Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?
Doesn't work over here, I have the latest freecad version from the freecad repositories on ubuntu.
I followed these steps:
It appeared to have installed fine, but the workbench is nowhere to be seen.
Do you want me to supply anything further?
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)
Code: Select all
Using Addon Manager
Click on Configure
Enter https://github.com/KeithSloan/toSketch.git
Do you want me to supply anything further?
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?
While since I used Ubuntu.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.
I followed these steps: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)
It appeared to have installed fine, but the workbench is nowhere to be seen.Code: Select all
Using Addon Manager Click on Configure Enter https://github.com/KeithSloan/toSketch.git
Do you want me to supply anything further?
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
Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?
This worked!You could always goto/create .FreeCAD/Mod and then
git clone https://github.com/KeithSloan/toSketch.git
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.
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?
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.duckmug wrote: ↑Thu Jun 17, 2021 1:23 amThis worked!You could always goto/create .FreeCAD/Mod and then
git clone https://github.com/KeithSloan/toSketch.git
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.
i.e. where it finds a straight line it becomes a straight line and where n points a bezier curve.
Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?
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);
}
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);
}
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Discussion - Possible way ahead for OpenSCAD hull and Minkowski requests?
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 Your code pasted to a scad file I exported to step but it was not very successful. By changing the FreeCAD STEP preferences for Import/Export so that export used the legacy exporter, I got success
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 Your code pasted to a scad file I exported to step but it was not very successful. By changing the FreeCAD STEP preferences for Import/Export so that export used the legacy exporter, I got success