Struggling to convert OpenSCAD to STEP
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
Struggling to convert OpenSCAD to STEP
Hello,
I am completely new to FreeCAD, but need to create a STEP file from an OpenSCAD file, and I can't understand why it is not working well. the OpenSCAD code is below. The file is created, but several parts that should be subtracted re-appear and several cuts are created. I tried to refine, and that helps but not completely. Any help would be appreciated. I just installed FreeCAD so I assume it is the latest version.
thanks
Mauro
difference(){
union(){
cube([16,46,16]);
translate([8,16,-3])
cylinder( $fn = 100, 10, 7, 7);}
translate([7,-1,-4]){
cube([2,15,20]);}
translate([8,16,-4])
{cylinder( $fn = 100, 20, 4.890, 4.890);
}
translate([0,35,7])
cube([20,15,2]);
translate([-1,32,8])
rotate([0,90,0]){
cylinder( $fn = 100, 20, 4.15, 4.15);
}
translate([8,5,8]){
rotate([0,90,0]){
cylinder( $fn = 100, 100, 2.1, 2.1);}}
translate([-2,5,8]){
rotate([0,90,0]){
cylinder( $fn = 100, 10, 3, 3);}}
translate([-1,5,8]){
rotate([0,90,0]){
cylinder( $fn = 100, 5, 4, 4);}}
translate([8,40,-2]){
cylinder( $fn = 100, 10, 2.1, 2.1);}
translate([8,40,8]){
cylinder( $fn = 100, 10, 3, 3);}
translate([8,40,12]){
cylinder( $fn = 100, 5, 4, 4);}}
I am completely new to FreeCAD, but need to create a STEP file from an OpenSCAD file, and I can't understand why it is not working well. the OpenSCAD code is below. The file is created, but several parts that should be subtracted re-appear and several cuts are created. I tried to refine, and that helps but not completely. Any help would be appreciated. I just installed FreeCAD so I assume it is the latest version.
thanks
Mauro
difference(){
union(){
cube([16,46,16]);
translate([8,16,-3])
cylinder( $fn = 100, 10, 7, 7);}
translate([7,-1,-4]){
cube([2,15,20]);}
translate([8,16,-4])
{cylinder( $fn = 100, 20, 4.890, 4.890);
}
translate([0,35,7])
cube([20,15,2]);
translate([-1,32,8])
rotate([0,90,0]){
cylinder( $fn = 100, 20, 4.15, 4.15);
}
translate([8,5,8]){
rotate([0,90,0]){
cylinder( $fn = 100, 100, 2.1, 2.1);}}
translate([-2,5,8]){
rotate([0,90,0]){
cylinder( $fn = 100, 10, 3, 3);}}
translate([-1,5,8]){
rotate([0,90,0]){
cylinder( $fn = 100, 5, 4, 4);}}
translate([8,40,-2]){
cylinder( $fn = 100, 10, 2.1, 2.1);}
translate([8,40,8]){
cylinder( $fn = 100, 10, 3, 3);}
translate([8,40,12]){
cylinder( $fn = 100, 5, 4, 4);}}
-
- Veteran
- Posts: 2756
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Struggling to convert OpenSCAD to STEP
Struggling to understand your problemMauroa wrote: ↑Wed May 05, 2021 1:03 pm Hello,
I am completely new to FreeCAD, but need to create a STEP file from an OpenSCAD file, and I can't understand why it is not working well. the OpenSCAD code is below. The file is created, but several parts that should be subtracted re-appear and several cuts are created. I tried to refine, and that helps but not completely. Any help would be appreciated. I just installed FreeCAD so I assume it is the latest version.
thanks
Mauro
- Cut and pasted your OpenSCAD script
- Imported into FreeCAD
- Selected highest level object and exported to STEP
Re: Struggling to convert OpenSCAD to STEP
You have not clear to simple things:
OpenSCAD create models that generally are meshes, so they are simply a "generic solid" generally they are "STL meshes".
The problem is:
1) are you trying to load the "OpenSCAD code" into FreeCAD
2) are you trying to load the "STL" file in FreeCAD
answers are different, to complicate things, without giving an idea of what version of FreeCAD are you using is difficult to help you as in 0.19 and maybe 0,20 OpenSCAD WB has been modified so maybe some anwers will not be applicable to your versions.
Plus please put the OpenSCAD code in a code tag (those marked with [</>] icon in the forum task bar)
Regards
Carlo D.
OpenSCAD create models that generally are meshes, so they are simply a "generic solid" generally they are "STL meshes".
The problem is:
1) are you trying to load the "OpenSCAD code" into FreeCAD
2) are you trying to load the "STL" file in FreeCAD
answers are different, to complicate things, without giving an idea of what version of FreeCAD are you using is difficult to help you as in 0.19 and maybe 0,20 OpenSCAD WB has been modified so maybe some anwers will not be applicable to your versions.
Plus please put the OpenSCAD code in a code tag (those marked with [</>] icon in the forum task bar)
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Struggling to convert OpenSCAD to STEP
Can you post your FreeCAD info and a screenshot of your STEP export settings? Like the OP I cannot get a valid STEP file.
-
- Veteran
- Posts: 2756
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Struggling to convert OpenSCAD to STEP
Surely it should be you guys posting the info as per the forum.
But anyway here you go.
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)
-
- Veteran
- Posts: 2756
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Struggling to convert OpenSCAD to STEP
But the FreeCAD importer parses the CSG file and tries to create Brep representation of the objects. There are two exceptions hull and minkowski operations where it needs to convert any objects involved into meshes. So in general OpenSCAD objects imported into FreeCAD have Brep Shapes, NOT meshes !!!
-
- Veteran
- Posts: 2756
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Struggling to convert OpenSCAD to STEP
Thanks. There seems to be an issue with version 0.20.
STEP OK:
Code: Select all
OS: Windows 8.1 (6.3)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24219 (Git)
Build type: Release
Branch: master
Hash: 8c26baebab320b8c1c3279bc8eb34a1eb6c7a363
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Dutch/Netherlands (nl_NL)
Code: Select all
OS: Windows 8.1 Version 6.3 (Build 9600)
Word size of FreeCAD: 64-bit
Version: 0.20.24840 (Git)
Build type: Release
Branch: master
Hash: 131cdd1e4ec5e1cc1ddd1ccce4435fe23dee68cf
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.0
Locale: Dutch/Netherlands (nl_NL)
- Attachments
-
- Mauroa-difference-0.20.step
- (98.55 KiB) Downloaded 40 times
-
- Mauroa-difference-0.20.png (14.21 KiB) Viewed 3008 times
-
- Veteran
- Posts: 2756
- Joined: Mon Feb 27, 2012 5:31 pm
Re: Struggling to convert OpenSCAD to STEP
Trust you will raise as a bug - I am a bit busy for a while.Roy_043 wrote: ↑Sun May 09, 2021 7:29 pmThanks. There seems to be an issue with version 0.20.
STEP OK:STEP BAD:Code: Select all
OS: Windows 8.1 (6.3) Word size of OS: 64-bit Word size of FreeCAD: 64-bit Version: 0.19.24219 (Git) Build type: Release Branch: master Hash: 8c26baebab320b8c1c3279bc8eb34a1eb6c7a363 Python version: 3.6.8 Qt version: 5.12.1 Coin version: 4.0.0a OCC version: 7.3.0 Locale: Dutch/Netherlands (nl_NL)
Code: Select all
OS: Windows 8.1 Version 6.3 (Build 9600) Word size of FreeCAD: 64-bit Version: 0.20.24840 (Git) Build type: Release Branch: master Hash: 131cdd1e4ec5e1cc1ddd1ccce4435fe23dee68cf Python version: 3.8.6+ Qt version: 5.15.2 Coin version: 4.0.1 OCC version: 7.5.0 Locale: Dutch/Netherlands (nl_NL)
Most likely to be an issue with OCC as I think it does the heavy lifting with creating a STEP file.
Re: Struggling to convert OpenSCAD to STEP
Hi Keith and all
I tried this in FreeCAD 0.19 from the stable PPA and daily PPA and FreeCAD compiled from master (see FreeCAD version data below). I imported the OpenSCAD file, exported via both STEP exporters, then opened the STEP file, in both 0.20 versions the STEP had missing faces, to be clear it also failed in FreeCAD 0.19. All of my FreeCADs use the same OCC version 7.5.1, so it seems logical that there must be a regression in or related to OCC STEP Export and/or import.
If you open it in 0.19 with an older OCC and it is still missing faces then we can assume it is "OCC export to STEP" that has a regression. However if it opens perfectly then logic would imply that it must be STEP import in OCC 7.5.1 that has the regression.
Keith was one of the original developers of FreeCAD's OpenSCAD support.
As far as I can tell, I think this is a FreeCAD/OCC issue rather than anything to do with OpenSCAD specifically.
Jim
OS: Ubuntu 20.04.2 LTS (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.stable PPA
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/Australia (en_AU)
Compiled from Master
OS: Ubuntu 20.04.2 LTS (KDE/plasma)
Word size of FreeCAD: 64-bit
Version: 0.20.24847 (Git)
Build type: Unknown
Branch: master
Hash: 20e756306d9aa624fcbf465f0345d721673ce720
Python version: 3.8.5
Qt version: 5.12.8
Coin version: 4.0.0
OCC version: 7.5.1
Locale: English/Australia (en_AU)
I tried this in FreeCAD 0.19 from the stable PPA and daily PPA and FreeCAD compiled from master (see FreeCAD version data below). I imported the OpenSCAD file, exported via both STEP exporters, then opened the STEP file, in both 0.20 versions the STEP had missing faces, to be clear it also failed in FreeCAD 0.19. All of my FreeCADs use the same OCC version 7.5.1, so it seems logical that there must be a regression in or related to OCC STEP Export and/or import.
If someone would like to check, this STEP file attached is missing faces.
If you open it in 0.19 with an older OCC and it is still missing faces then we can assume it is "OCC export to STEP" that has a regression. However if it opens perfectly then logic would imply that it must be STEP import in OCC 7.5.1 that has the regression.
Keith was one of the original developers of FreeCAD's OpenSCAD support.
As far as I can tell, I think this is a FreeCAD/OCC issue rather than anything to do with OpenSCAD specifically.
Jim
OS: Ubuntu 20.04.2 LTS (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.stable PPA
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/Australia (en_AU)
Compiled from Master
OS: Ubuntu 20.04.2 LTS (KDE/plasma)
Word size of FreeCAD: 64-bit
Version: 0.20.24847 (Git)
Build type: Unknown
Branch: master
Hash: 20e756306d9aa624fcbf465f0345d721673ce720
Python version: 3.8.5
Qt version: 5.12.8
Coin version: 4.0.0
OCC version: 7.5.1
Locale: English/Australia (en_AU)