Cannot import rotate extrude done in openScad.

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

Re: Cannot import rotate extrude done in openScad.

Post by keithsloan52 »

Code: Select all

14:13:04  Rotate Extrude
14:13:04  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/share/freecad-daily/Mod/OpenSCAD/importCSG.py", line 85, in open
    processcsg(tmpfile)
  File "/usr/share/freecad-daily/Mod/OpenSCAD/importCSG.py", line 143, in processcsg
    result = parser.parse(f.read())
  File "/usr/lib/python3/dist-packages/ply/yacc.py", line 331, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/usr/lib/python3/dist-packages/ply/yacc.py", line 1106, in parseopt_notrack
    p.callable(pslice)
  File "/usr/share/freecad-daily/Mod/OpenSCAD/importCSG.py", line 660, in p_rotate_extrude_action
    angle = float(p[3]['angle'])    
<class 'KeyError'>: 'angle'
This error indicates the CSG file does not contain the angle parameter. Need to check CSG file.
If in CSG file then maybe you did not make the right changes to where rotate_extrude_action is called
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Cannot import rotate extrude done in openScad.

Post by keithsloan52 »

Here is a version of importCSG.py that works on my system.
importCSG.py
(42.48 KiB) Downloaded 42 times
SidSparks
Posts: 6
Joined: Wed Jul 29, 2020 5:34 pm

Re: Cannot import rotate extrude done in openScad.

Post by SidSparks »

Code: Select all

OS: Linux Mint 18.3 Sylvia
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.4.
Build type: Release
Python version: 3.5.2
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)
keithsloan52 wrote: Sun Aug 02, 2020 4:31 pm Would be good to test CSG file. i.e. load scad file into OpenSCAD
and export CSG.

If you look at the rotate_extrude it has angle=90. Is that what you also see,
I was getting totally confused with the different versions so I decided to go back to the start and reinstalled version 0.18.4.
I exported from OpenSCAD to CSG format and imported into FreeCAD with the same result as before (360 deg extrude). It had the rotate_extrude angle=90 in the CSG file.
I also imported the scad format file with slightly different result but still with the 360 deg extrude (not 90).
I copied your importCSG.py file into the MOD/OpenSCAD directory and re-ran the program.
Importing the CSG file gives the correct result, importing the scad file gave the same error as previously ie. no rotate extrude.
keithsloan52 wrote: Sun Aug 02, 2020 4:39 pm

Code: Select all

14:13:04  Rotate Extrude
14:13:04  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/share/freecad-daily/Mod/OpenSCAD/importCSG.py", line 85, in open
    processcsg(tmpfile)
  File "/usr/share/freecad-daily/Mod/OpenSCAD/importCSG.py", line 143, in processcsg
    result = parser.parse(f.read())
  File "/usr/lib/python3/dist-packages/ply/yacc.py", line 331, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/usr/lib/python3/dist-packages/ply/yacc.py", line 1106, in parseopt_notrack
    p.callable(pslice)
  File "/usr/share/freecad-daily/Mod/OpenSCAD/importCSG.py", line 660, in p_rotate_extrude_action
    angle = float(p[3]['angle'])    
<class 'KeyError'>: 'angle'
This error indicates the CSG file does not contain the angle parameter. Need to check CSG file.
If in CSG file then maybe you did not make the right changes to where rotate_extrude_action is called
The above error only occurs with the scad import not the CSG import.

Thank you for your help in resolving this.
Sid
SidSparks
Posts: 6
Joined: Wed Jul 29, 2020 5:34 pm

Re: Cannot import rotate extrude done in openScad.

Post by SidSparks »

Code: Select all

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.4 (GitTag)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 980bf9060e28555fecd9e3462f68ca74007b70f8
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)
keithsloan52 wrote: Sun Aug 02, 2020 4:31 pm Would be good to test CSG file. i.e. load scad file into OpenSCAD
and export CSG.
I imported the CSG file into the windows version and it failed as expected but then worked fine with your importCSG.py file.
There's no option to import a scad file directly into this windows version.

Thanks
Sid
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Cannot import rotate extrude done in openScad.

Post by keithsloan52 »

SidSparks wrote: Tue Aug 04, 2020 9:44 pm

Code: Select all

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.4 (GitTag)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 980bf9060e28555fecd9e3462f68ca74007b70f8
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)
keithsloan52 wrote: Sun Aug 02, 2020 4:31 pm Would be good to test CSG file. i.e. load scad file into OpenSCAD
and export CSG.
I imported the CSG file into the windows version and it failed as expected but then worked fine with your importCSG.py file.
There's no option to import a scad file directly into this windows version.

Thanks
Sid
Hi Sid

There is no direct import of scad files in any versions, what happens when you import a scad file is that the OpenSCAD workbench
calls OpenSCAD under the covers and creates a temporary CSG file that ImportCSG.py imports.

You need to tell the Workbench where your OpenSCAD executable is.

With OpenSCAD as your workbench if you click on FreeCAD Preferences you get.
preferences.png
preferences.png (316.3 KiB) Viewed 566 times
Then if you click on the OpenSCAD icon ( bottom left )
You get
OpenSCAD Options.png
OpenSCAD Options.png (357.14 KiB) Viewed 566 times
Where you see the place to tell the workbench where the executable is.

If you are not seeing the option to import a SCAD file, then the path is probably not set.

When I said check the CSG file, I should have been more precise and said using the OpenSCAD application, rather than FreeCAD.
SidSparks
Posts: 6
Joined: Wed Jul 29, 2020 5:34 pm

Re: Cannot import rotate extrude done in openScad.

Post by SidSparks »

Hi Keith,

This now makes sense.
The path to OpenSCAD was set to the original version that I installed which doesn't support rotate extrude. I had to install version 2019.05 which came as an appimage and it ended up being installed in a different directory. So FreeCAD was using the old version of OpenSCAD when trying to import the scad file.
This is why the CSG file imported ok as I had exported it directly from the latest version of OpenSCAD.

Thanks again for your help.
Sid
Post Reply