Ticket #4684 STEP export loses colour (split from "Ticket #4610: OCC's step export pathway generates bad geometry")

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!
pragmatist
Posts: 11
Joined: Wed Jun 02, 2021 10:51 pm

Ticket #4684 STEP export loses colour (split from "Ticket #4610: OCC's step export pathway generates bad geometry")

Postby pragmatist » Thu Jun 03, 2021 12:34 am

Mod Edit: This thread was split off from https://forum.freecadweb.org/viewtopic.php?f=8&t=57226

Just wanted to chime in here with some similar experience.

I am having this issue attempting to convert OpenSCAD models to STEP/IGES for KiCAD import.

The models look fine in OpenSCAD and FreeCAD (with which I have ~zero experience) despite some CSG import warnings on a few but not all of the extrude operations, but when imported in to KiCAD appear to have lost substantial amounts of their CSG operations and translate operations. See https://imgur.com/a/eCXijk1 for visuals.

Errors on import are as follows:

Code: Select all

09:09:14  Traceback (most recent call last):
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 406, in execute
    self.createGeometry(fp)
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 448, in createGeometry
    pipe_shell.build()
<class 'Part.OCCError'>: Approx_CurvlinFunc::GetUParameter
09:09:14  0
09:09:14  Traceback (most recent call last):
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 406, in execute
    self.createGeometry(fp)
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 448, in createGeometry
    pipe_shell.build()
<class 'Part.OCCError'>: Approx_CurvlinFunc::GetUParameter
09:09:14  0
09:09:14  Traceback (most recent call last):
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 406, in execute
    self.createGeometry(fp)
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 448, in createGeometry
    pipe_shell.build()
<class 'Part.OCCError'>: Approx_CurvlinFunc::GetUParameter
Unfortunately I am based on OSX instead of Linux (regularly regretting this decision) and there does not appear to be an updated binary available which resolves this issue. I have tried based on other thread suggestions:
  • the latest fork build by Lei Zheng (FreeCAD-asm3-Daily-BigSur-OSX-Py3-Qt5-20210531-x86_64.dmg) (wont import CSG)
  • the latest weekly builds version

    Code: Select all

    OS: macOS 10.16
    Word size of FreeCAD: 64-bit
    Version: 0.20.24910 (Git)
    Build type: Release
    Branch: master
    Hash: 089b2ae47824232f649eb74ce1f97673cf77b78c
    Python version: 3.9.4
    Qt version: 5.12.9
    Coin version: 4.0.0
    OCC version: 7.5.2
    Locale: C/Default (C)
    
  • an older 0.19 version
  • brew install freecad-pre (fails with Download failed: https://github.com/FreeCAD/FreeCAD/rele ... -conda.dmg)
In short: spent lots of time, tried lotsa things, but nothing works.

Therefore I am posting here in the hopes that it may motivate someone to make a new binary release for OSX with the issue resolved.

Also, I am new to FreeCAD so maybe I am messing something up. I did try some other formats (eg. IGES) which had the same issue, also tried via Wings3D (WRL no longer seems to import in to KiCad).

Thanks devs!
Last edited by pragmatist on Thu Jun 03, 2021 2:06 am, edited 3 times in total.
keithsloan52
Posts: 1916
Joined: Mon Feb 27, 2012 5:31 pm

Re: [FIXED] Ticket #4610: OCC's step export pathway generates bad geometry

Postby keithsloan52 » Fri Jun 04, 2021 5:11 pm

pragmatist wrote: Thu Jun 03, 2021 12:34 am Just wanted to chime in here with some similar experience.

I am having this issue attempting to convert OpenSCAD models to STEP/IGES for KiCAD import.

The models look fine in OpenSCAD and FreeCAD (with which I have ~zero experience) despite some CSG import warnings on a few but not all of the extrude operations, but when imported in to KiCAD appear to have lost substantial amounts of their CSG operations and translate operations. See https://imgur.com/a/eCXijk1 for visuals.

Errors on import are as follows:

Code: Select all

09:09:14  Traceback (most recent call last):
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 406, in execute
    self.createGeometry(fp)
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 448, in createGeometry
    pipe_shell.build()
<class 'Part.OCCError'>: Approx_CurvlinFunc::GetUParameter
09:09:14  0
09:09:14  Traceback (most recent call last):
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 406, in execute
    self.createGeometry(fp)
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 448, in createGeometry
    pipe_shell.build()
<class 'Part.OCCError'>: Approx_CurvlinFunc::GetUParameter
09:09:14  0
09:09:14  Traceback (most recent call last):
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 406, in execute
    self.createGeometry(fp)
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 448, in createGeometry
    pipe_shell.build()
<class 'Part.OCCError'>: Approx_CurvlinFunc::GetUParameter
Unfortunately I am based on OSX instead of Linux (regularly regretting this decision) and there does not appear to be an updated binary available which resolves this issue. I have tried based on other thread suggestions:
  • the latest fork build by Lei Zheng (FreeCAD-asm3-Daily-BigSur-OSX-Py3-Qt5-20210531-x86_64.dmg) (wont import CSG)
  • the latest weekly builds version

    Code: Select all

    OS: macOS 10.16
    Word size of FreeCAD: 64-bit
    Version: 0.20.24910 (Git)
    Build type: Release
    Branch: master
    Hash: 089b2ae47824232f649eb74ce1f97673cf77b78c
    Python version: 3.9.4
    Qt version: 5.12.9
    Coin version: 4.0.0
    OCC version: 7.5.2
    Locale: C/Default (C)
    
  • an older 0.19 version
  • brew install freecad-pre (fails with Download failed: https://github.com/FreeCAD/FreeCAD/rele ... -conda.dmg)
In short: spent lots of time, tried lotsa things, but nothing works.

Therefore I am posting here in the hopes that it may motivate someone to make a new binary release for OSX with the issue resolved.

Also, I am new to FreeCAD so maybe I am messing something up. I did try some other formats (eg. IGES) which had the same issue, also tried via Wings3D (WRL no longer seems to import in to KiCad).

Thanks devs!
OpenSCAD is working for me FreeCAD Daily FreeCAD-asm3-Daily-OSX-Conda-Py3-Qt5-20210531-x86_64.dmg
Mac OS Catalina 10.15.7. It is OCC 7.4.0 so in theory pre the export STEP regression. Unfortunately
I can only see images of your file rather than CSG or SCAD version so cannot properly test.

Code: Select all

OS: macOS 10.15
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 2021.531.24301 +3702 (Git)
Build type: Release
Branch: LinkDaily
Hash: 4ad819f55a108b7e8bddb134d0de39218e662aa4
Python version: 3.8.10
Qt version: 5.12.9
Coin version: 4.0.1
OCC version: 7.4.0
Locale: C/Default (C)
OpenSCAD is 2021.01
keithsloan52
Posts: 1916
Joined: Mon Feb 27, 2012 5:31 pm

Re: [FIXED] Ticket #4610: OCC's step export pathway generates bad geometry

Postby keithsloan52 » Fri Jun 04, 2021 8:53 pm

pragmatist wrote: Thu Jun 03, 2021 12:34 am
Errors on import are as follows:

Code: Select all

09:09:14  Traceback (most recent call last):
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 406, in execute
    self.createGeometry(fp)
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 448, in createGeometry
    pipe_shell.build()
<class 'Part.OCCError'>: Approx_CurvlinFunc::GetUParameter
09:09:14  0
09:09:14  Traceback (most recent call last):
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 406, in execute
    self.createGeometry(fp)
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 448, in createGeometry
    pipe_shell.build()
<class 'Part.OCCError'>: Approx_CurvlinFunc::GetUParameter
09:09:14  0
09:09:14  Traceback (most recent call last):
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 406, in execute
    self.createGeometry(fp)
  File "/Applications/FreeCAD.app/Contents/Resources/Mod/OpenSCAD/OpenSCADFeatures.py", line 448, in createGeometry
    pipe_shell.build()
<class 'Part.OCCError'>: Approx_CurvlinFunc::GetUParameter

Code: Select all

OS: macOS 10.16
Word size of FreeCAD: 64-bit
Version: 0.20.24910 (Git)
Build type: Release
Branch: master
Hash: 089b2ae47824232f649eb74ce1f97673cf77b78c
Python version: 3.9.4
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.2
Locale: C/Default (C)
This looks to me like ANOTHER OCC regression, this time in OCC 7.5.2 and not related to the Ticket #4610 for STEP export.
Perhaps @Kunda1 could check it out and open a new Ticket.
pragmatist
Posts: 11
Joined: Wed Jun 02, 2021 10:51 pm

Re: [FIXED] Ticket #4610: OCC's step export pathway generates bad geometry

Postby pragmatist » Fri Jun 04, 2021 9:56 pm

Sample file:

Code: Select all

// black
color("#505050")

// upper part
translate([0,0,0.3]) {
 difference() {
  linear_extrude(1.05) {
   square([2.36,3.94]);
  }
  // receiver
  // values with 1111 need updating
  translate([1.11111111,1.11111111,0.5]) {
   linear_extrude(3) {
    circle(r=0.5,$fn=25);
   }
  }
  // emitter
  // values with 1111 need updating
  translate([1.11111111,3.94-0.5,0.5]) {
   difference() {
    linear_extrude(3) {
     circle(d=0.98,$fn=25);
    }
    translate([0,0.8,0]) {
     linear_extrude(3) {
      square([1,1],center=true);
     }
    }
   }
  }
 }
}
// receiver bottom should be whiteish
color("#ffffff")
translate([1.3,1.3,0.8]) {
  linear_extrude(0.05) {
   square([2,2],center=true);
  }
}

// emitter bottom should be blackish
color("#000000")
translate([1.3,2.73,0.8]) {
  linear_extrude(0.05) {
   square([2,2],center=true);
  }
}



// pin1 marking
color("#404040")
translate([0.4,0.4,1.35]) {
 linear_extrude(0.001) {
  circle(r=0.2,$fn=10);
 }
}

// lower part
color("#dddddd")
translate([(2.36-2.1)/2,0.055,0]) {
 linear_extrude(0.3) {
  #square([2.1,3.73]);
 }
}

// pads - OFFSETS ARE CORRECT
color("#a0a0a0")
translate([(2.36-2.1)/2+(2.1-2)/2,0.1,-0.01]) {
 linear_extrude(0.01) {
    translate([0,0,0]) {
        square([0.6,0.72]);
        translate([0,0.72+0.25,0]) {
         square([0.6,0.72]);
        }
        translate([0,2*(0.72+0.25),0]) {
         square([0.6,0.72]);
        }
        translate([0,3*(0.72+0.25),0]) {
         square([0.6,0.72]);
        }

        translate([0.6+0.8,0,0]) {
            square([0.6,0.72]);
            translate([0,0.72+0.25,0]) {
             square([0.6,0.72]);
            }
            translate([0,2*(0.72+0.25),0]) {
             square([0.6,0.72]);
            }
            translate([0,3*(0.72+0.25),0]) {
             square([0.6,0.72]);
            }
        }

    }
 }
}
keithsloan52
Posts: 1916
Joined: Mon Feb 27, 2012 5:31 pm

Re: [FIXED] Ticket #4610: OCC's step export pathway generates bad geometry

Postby keithsloan52 » Sat Jun 05, 2021 5:28 am

Cut and pasted your code to
KicadPart.scad
(1.81 KiB) Downloaded 8 times
Something is not quite right with import.

I get some artefacts? that are not visible unless selected i.e.
FBA889FE-A4EA-409A-8561-358671A59C65.jpeg
FBA889FE-A4EA-409A-8561-358671A59C65.jpeg (82.89 KiB) Viewed 306 times
The parts concerned are polygon, square002 square001, circle001,circle.

I also get these message in report view after it has performed the CSG import

Code: Select all

06:14:02  End processing CSG file
06:14:02  <Part> importCSG.py(186)|FeaturePartFuse.cpp(241): fusion of non solid: KicadPart#square009
06:14:02  <Part> importCSG.py(186)|FeaturePartFuse.cpp(241): fusion of non solid: KicadPart#square010
06:14:02  <Part> importCSG.py(186)|FeaturePartFuse.cpp(241): fusion of non solid: KicadPart#square011
06:14:02  <Part> importCSG.py(186)|FeaturePartFuse.cpp(241): fusion of non solid: KicadPart#square012
06:14:02  <Part> importCSG.py(186)|FeaturePartFuse.cpp(241): fusion of non solid: KicadPart#square005
06:14:02  <Part> importCSG.py(186)|FeaturePartFuse.cpp(241): fusion of non solid: KicadPart#square006
06:14:02  <Part> importCSG.py(186)|FeaturePartFuse.cpp(241): fusion of non solid: KicadPart#square007
06:14:02  <Part> importCSG.py(186)|FeaturePartFuse.cpp(241): fusion of non solid: KicadPart#square008
06:14:02  <Part> importCSG.py(186)|FeaturePartFuse.cpp(241): fusion of non solid: KicadPart#Matrix_Union
06:18:33  Loading Import module... done
Which are different from the artefact parts

FreeCAD file is
KicadPart.FCStd
(73.76 KiB) Downloaded 8 times
Which exports to step as
KicadPart.step
(301.92 KiB) Downloaded 5 times
keithsloan52
Posts: 1916
Joined: Mon Feb 27, 2012 5:31 pm

Re: [FIXED] Ticket #4610: OCC's step export pathway generates bad geometry

Postby keithsloan52 » Sat Jun 05, 2021 5:57 am

If I use the Alternate Importer https://github.com/KeithSloan/OpenSCAD_Alt_Import Which has a number of Fixes that Chris Hennes has made and therefore a closer match to the importer being used by the OP in FreeCAD 0.20 I get the problems with

Code: Select all

<class 'Part.OCCError'>: Approx_CurvlinFunc::GetUParameter
FreeCAD File is
Kicadpart-Alt.FCStd
(120.3 KiB) Downloaded 6 times
Exported STEP file is
Kicadpart-Alt.step
(474.29 KiB) Downloaded 4 times
keithsloan52
Posts: 1916
Joined: Mon Feb 27, 2012 5:31 pm

Re: [FIXED] Ticket #4610: OCC's step export pathway generates bad geometry

Postby keithsloan52 » Sat Jun 05, 2021 6:03 am

Indeed if I try and use a version on my system which is called FreeCAD 0.19.1-Plus which is the version of the OpenSCAD workbench in FreeCAD 0.19.1 patched with Chris Hennes chennes fixes i.e Should be the same as the version in FreeCAD 0.20 then I get the same errors as the OP

Code: Select all

06:57:58  Traceback (most recent call last):
  File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/OpenSCAD_Alt_Import/OpenSCADFeatures.py", line 404, in execute
    self.createGeometry(fp)
  File "/Users/keithsloan/Library/Preferences/FreeCAD/Mod/OpenSCAD_Alt_Import/OpenSCADFeatures.py", line 446, in createGeometry
    pipe_shell.build()
<class 'Part.OCCError'>: Approx_CurvlinFunc::GetUParameter
06:57:58  0
pragmatist
Posts: 11
Joined: Wed Jun 02, 2021 10:51 pm

Re: [FIXED] Ticket #4610: OCC's step export pathway generates bad geometry

Postby pragmatist » Sat Jun 05, 2021 7:57 am

Here is the CSG as I export it. Attempted workflow is OpenSCAD -> CSG -> FreeCAD -> STEP/IGES
Attachments
LTR-553ALS-WA.csg
CSG
(3.42 KiB) Downloaded 5 times
keithsloan52
Posts: 1916
Joined: Mon Feb 27, 2012 5:31 pm

Re: [FIXED] Ticket #4610: OCC's step export pathway generates bad geometry

Postby keithsloan52 » Sat Jun 05, 2021 1:54 pm

pragmatist wrote: Sat Jun 05, 2021 7:57 am Here is the CSG as I export it. Attempted workflow is OpenSCAD -> CSG -> FreeCAD -> STEP/IGES
This loads for me and here is the saved FreeCAD file
LTR-553ALS-WA.FCStd
(73.83 KiB) Downloaded 8 times
Here is an exported STEP version
LTR-553ALS-WA.step
(236.93 KiB) Downloaded 10 times
Note: When the file is imported, it is coming in as a flat structure i.e. a number of objects at the top level. To export to step you need to select all the objects at the top level and NOT select the objects that have been hidden as they are constructions for the extrudes. i.e. eyes with red line through.
C258C04A-2F60-49C0-AA10-8FC4D801EA09.jpeg
C258C04A-2F60-49C0-AA10-8FC4D801EA09.jpeg (56.31 KiB) Viewed 386 times
pragmatist
Posts: 11
Joined: Wed Jun 02, 2021 10:51 pm

Re: [FIXED] Ticket #4610: OCC's step export pathway generates bad geometry

Postby pragmatist » Sun Jun 06, 2021 12:03 am

Thanks a lot Keith.

Ouch! I am guilty as charged for not knowing FreeCAD. When I received an error for having nothing selected, I just pressed CTRL+A to select all, like in every other app. Next time I will be sure to select each individually.
  • Perhaps there is an opportunity UI improvement/normalisation lurking here? Perhaps exports automatically filtering appropriately to top-level CSG when all children are selected (as per normal export intent), rather than modifying the UI.
The STEP file you supplied imports to KiCad with perfect geometry but lacks the colours. See attachment. I am really looking for a route which preserves colours from OpenSCAD to FreeCAD then from FreeCAD to KiCad, so I can just model the whole thing in OpenSCAD. I will try to replicate your method now and post results.
Attachments
Screen Shot 2021-06-06 at 07.56.52.png
Screen Shot 2021-06-06 at 07.56.52.png (695.39 KiB) Viewed 342 times
Last edited by pragmatist on Sun Jun 06, 2021 12:13 am, edited 1 time in total.