Struggling to convert OpenSCAD to STEP

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
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!
Mauroa
Posts: 1
Joined: Wed May 05, 2021 12:53 pm

Struggling to convert OpenSCAD to STEP

Post by Mauroa »

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);}}
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: Struggling to convert OpenSCAD to STEP

Post by keithsloan52 »

Mauroa 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
Struggling to understand your problem
  • Cut and pasted your OpenSCAD script
    Mauroa.scad
    (705 Bytes) Downloaded 67 times
  • Imported into FreeCAD
    Mauroa.FCStd
    (35.31 KiB) Downloaded 61 times
  • Selected highest level object and exported to STEP
    Mauroa.step
    (85.42 KiB) Downloaded 49 times
All looks okay to me where are these parts that should have been subtracted?
User avatar
onekk
Veteran
Posts: 6144
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Struggling to convert OpenSCAD to STEP

Post by onekk »

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.
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/
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Struggling to convert OpenSCAD to STEP

Post by Roy_043 »

keithsloan52 wrote: Sun May 09, 2021 4:33 pm All looks okay to me
Can you post your FreeCAD info and a screenshot of your STEP export settings? Like the OP I cannot get a valid STEP file.
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: Struggling to convert OpenSCAD to STEP

Post by keithsloan52 »

Roy_043 wrote: Sun May 09, 2021 5:03 pm
keithsloan52 wrote: Sun May 09, 2021 4:33 pm All looks okay to me
Can you post your FreeCAD info and a screenshot of your STEP export settings? Like the OP I cannot get a valid STEP file.
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)
Step options
C1376604-9853-4B46-9154-AC162F2089CD.jpeg
C1376604-9853-4B46-9154-AC162F2089CD.jpeg (92.59 KiB) Viewed 3026 times
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: Struggling to convert OpenSCAD to STEP

Post by keithsloan52 »

onekk wrote: Sun May 09, 2021 5:00 pm 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".

Regards

Carlo D.
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 !!!
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: Struggling to convert OpenSCAD to STEP

Post by keithsloan52 »

onekk wrote: Sun May 09, 2021 5:00 pm OpenSCAD WB has been modified so maybe some answers will not be applicable to your versions.
Regards

Carlo D.
@chennes changes would not effect any of this, Chris changes are mostly to do with extrusions of various types.
User avatar
Roy_043
Veteran
Posts: 8450
Joined: Thu Dec 27, 2018 12:28 pm

Re: Struggling to convert OpenSCAD to STEP

Post by Roy_043 »

keithsloan52 wrote: Sun May 09, 2021 7:04 pm here you go.
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)
STEP BAD:

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
Mauroa-difference-0.20.png (14.21 KiB) Viewed 3005 times
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: Struggling to convert OpenSCAD to STEP

Post by keithsloan52 »

Roy_043 wrote: Sun May 09, 2021 7:29 pm
keithsloan52 wrote: Sun May 09, 2021 7:04 pm here you go.
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)
STEP BAD:

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)
Trust you will raise as a bug - I am a bit busy for a while.

Most likely to be an issue with OCC as I think it does the heavy lifting with creating a STEP file.
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Struggling to convert OpenSCAD to STEP

Post by jmaustpc »

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.
Roy_043 wrote: Sun May 09, 2021 7:29 pm There seems to be an issue with version 0.20.
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.
Mauroa-difference_019_1.step
(86.05 KiB) Downloaded 47 times
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)
Post Reply