Have an Openscad to Freecad conundrum to solve [solved]

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!
Yuri
Posts: 34
Joined: Sun May 09, 2021 1:14 am

Re: Have an Openscad to Freecad conundrum to solve

Post by Yuri »

And yet another thing to note is that:

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 32-bit
Version: 0.18.4 (GitTag)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 980bf9060e28555fecd9e3462f68ca74007b70f8
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/Canada (en_CA)

when given the importCSG.py and the OPENSCADfeatures.py provided by chennes on the proper OPENSCAD/ folder location with the ambition of having proper partial rotate extrude, FC above no longer opens the file shown in BearPartialFC which was loaded to test if the step file was exported correctly (which succeeded indeed).

With the new importCSG and OPENSCADfeatures I get the following in the report window all in red:

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files (x86)\FreeCAD 0.18\Mod\OpenSCAD\importCSG.py", line 42, in <module>
from OpenSCADFeatures import *
<type 'exceptions.SyntaxError'>: ("Non-ASCII character '\\xc2' in file C:\\Program Files (x86)\\FreeCAD 0.18\\Mod\\OpenSCAD\\OpenSCADFeatures.py on line 468, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details", ('C:\\Program Files (x86)\\FreeCAD 0.18\\Mod\\OpenSCAD\\OpenSCADFeatures.py', 468, 0, None))
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files (x86)\FreeCAD 0.18\Mod\OpenSCAD\importCSG.py", line 42, in <module>
from OpenSCADFeatures import *
<type 'exceptions.SyntaxError'>: ("Non-ASCII character '\\xc2' in file C:\\Program Files (x86)\\FreeCAD 0.18\\Mod\\OpenSCAD\\OpenSCADFeatures.py on line 468, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details", ('C:\\Program Files (x86)\\FreeCAD 0.18\\Mod\\OpenSCAD\\OpenSCADFeatures.py', 468, 0, None))

I went on to look at the issue of the non ASCII character. I concluded that the 2 magic lines were probably missing in the new importCSG but it is missing on both. So, no reason to add it. Then went on to look at the code line 468 in the OpenSCADFeatures. py to try to copy paste the code that is causing the problem in the newer OpenSCADFeatures with the older one so making the code readable to FC as in facts reads the older one.

I found:
class PrismaticToroid:
def __init__(self, obj,child=None,angle=360.0,n=3):
obj.addProperty("App::PropertyLink","Base","Base",
"The 2D face that will be swept")
obj.addProperty("App::PropertyAngle","Angle","Base","Angle to sweep through")
obj.addProperty("App::PropertyInteger","Segments","Base","Number of segments per 360° (OpenSCAD's \"$fn\")")

In the new openscad features. The class PrismaticToroid does not exist in the older openscad features so that the copy paste ambition went out the window.

So, why is it that I cannot use the newer openscadfeatures and the importCSG in FC 0.184
User avatar
Kunda1
Posts: 10973
Joined: Thu Jan 05, 2017 9:03 pm

Re: Have an Openscad to Freecad conundrum to solve

Post by Kunda1 »

please put the code in bbcode code tags for better readability, thanks
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
Yuri
Posts: 34
Joined: Sun May 09, 2021 1:14 am

Re: Have an Openscad to Freecad conundrum to solve

Post by Yuri »

Understood regarding the code display field issue.

I'm icing up the FC 0.192 version that I have. It does almost everything that I need. I would hate the world if I change something that is going to trigger problems that I have overcome. It is easy to think that I could uninstall it, then I can re-install it again with newer importCSG and OpenSCADFeatures if I run into problems. I don't trust that any more based on experience and I go in dread thinking that I will be thrown back into older issues.

Keith suggested to try 0.191. The 0.191 release notes say "FreeCADLibs_12.5.3_VC1.7 updates QT 5.15.1, OpenCascade 7.5 with Fillet fix from https://gitlab.com/blobfish/occt provided by Chris Hennes " .

So, it seems that the 0.191 will come with the OCC 7.5 which is the culprit of the main problem I'm having. i.e. defects on step exports.

So, 0.184 will let me process files not having partial rotate extrudes so that I can produce step files. It won't however, let me use the newer importCSG and OpenSCADFeatures to enable rotate extrude.

0.192 will let me correctly read scad files having partial rotate extrude but it won't let me export step files. 0.192 also have some problems with booleans of very simple booleans that 0.184 doesn't.

So, a late version using OCC different than 7.5.0 and 7.5.1 enabled to deal with scad imports having partial rotate extrudes and with the ability to read dxf files as 0.184 (because of the failed simple booleans in the base file from the 0.192 version) is my ambition.
keithsloan52
Posts: 2092
Joined: Mon Feb 27, 2012 5:31 pm

Re: Have an Openscad to Freecad conundrum to solve

Post by keithsloan52 »

Yuri wrote: Thu May 20, 2021 8:32 pm
Keith suggested to try 0.191. The 0.191 release notes say "FreeCADLibs_12.5.3_VC1.7 updates QT 5.15.1, OpenCascade 7.5 with Fillet fix from https://gitlab.com/blobfish/occt provided by Chris Hennes " .

So, it seems that the 0.191 will come with the OCC 7.5 which is the culprit of the main problem I'm having. i.e. defects on step exports.
I am afraid more MISS information !!! I just double checked and downloaded FreeCAD 0.19.1 from https://www.freecadweb.org/downloads.php

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)
Works just fine for STEP export. But then I am on a Mac, maybe FreeCAD 0.19.1 on other platforms is different.
Yuri
Posts: 34
Joined: Sun May 09, 2021 1:14 am

Re: Have an Openscad to Freecad conundrum to solve

Post by Yuri »

The unfortunate thing is that I went on to uninstall 0.192 to give way to 0.191 exactly at the link provided by Keith which clearly says 0.191, however, the information that I get from the about freecad menu item is:

Code: Select all

OS: Windows 10 Version 2004
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24276 (Git)
Build type: Release
Branch: releases/FreeCAD-0-19
Hash: a88db11e0a908f6e38f92bfc5187b13ebe470438
Python version: 3.8.6+
Qt version: 5.15.1
Coin version: 4.0.1
OCC version: 7.5.0
Locale: English/Canada (en_CA)
The library tab confirms OCC 7.5.0

So where keith pointed at says 0.191 where in fact seems to be 0.192.

I didn't know this when I downloaded so that I went happy to test my files. I'm at the exact point as I was before. Same problems.

Note that the version pointed out by Keith, doesn't deal correctly with the partial rotate extrude so that the latest importCSG and the OpenSCADFeatures by chennes are still needed.

So, Keith is right: there is a lot of misinformation out there.

Plus, from what Keith says, it seems that 0.191 is in fact available in the download for Macs.

Could one, among all the misinformation decipher where the 0.191 for windows with the proper OCC is ? The one that keith has in his Mac.
Yuri
Posts: 34
Joined: Sun May 09, 2021 1:14 am

Re: Have an Openscad to Freecad conundrum to solve

Post by Yuri »

English translation by google translate appears acceptable. The state of thing at this point and the possible path to fixes are as follows:

In the following context it is necessary to note the existence of the new (N) and old V () importCSG.py (ICSG) and OpenSCADFeatures.py (OSCF) files and also the Openscad Partial Extrusion (PE) command. Also note the processes involved in reading dwg that Freecad FC (LDWG) executes and in exporting step files (EXS).
  • PE can be successfully executed by FC only with the availability of ICSGN and OSCFN.
  • LDWG can be run better by ICSGV and OSCFV than by newer ones. The new ones have problems executing simple Boolean operations when executing LDWG as in the example of the simple prism belonging to the base that you already have.
  • EXS can only be executed correctly with the presence of OCCs other than versions 7.5.0 and 7.5.1.
  • ICSGN and OSCFN versions do not run correctly on FC 0.184.
The solutions I see at the moment are as follows:
  • The solution that solves more problems (possibly not all) is to take ICSGV and OSCFV and implement the changes that allow the correct execution of PE and install them in a version of FC with a correct version of OCC. FC 0.19 windows 10 cannot because of the OCC version it uses. The question that remains open if this were to be done is whether the problems I have had executing Boolean operations in 3D remain.
  • Implement the necessary changes so that FC 0.184 can work with ICSGN and OSCFN. EXS becomes functional but the work of implementing simple Boolean operations remains pending in this solution.
  • Implement the LDWG available in ICSGV and OSCFV in ICSGN and OSCFN and then run the previous solution. There is a possibility that this solves simple Boolean operations.
  • Find a version 0.19 for Windows 10 that uses OCC other than 7.5.0 and 7.5.1.
Choose the one that seems most viable to you.

For someone that is following who is Spanish:

En el contexto siguiente es necesario notar la existencia de los archivos importCSG.py (ICSG) y OpenSCADFeatures.py (OSCF) nuevos (N) y los viejos V() y también el comando de extrusión parcial de Openscad (PE). También hay que notar los procesos involucrados en la lectura de dwg que ejecuta Freecad FC (LDWG) y en la exportación de archivos step (EXS) .
  • PE puede ser ejecutato correctamente por FC solo con la disponibilidad de ICSGN and OSCFN.
  • LDWG puede ser ejecutada mejor por ICSGV y OSCFV que por los nuevos. Los nuevos tienen problemas ejecutando simples operaciones Booleanas al ejecutar LDWG como en el ejemplo del prisma simple perteneciente a la base que usted ya tiene.
  • EXS solo puede ser ejecutado correctamente con la presencia de OCC differentes a las versiones 7.5.0 y 7.5.1.
  • Las versiones ICSGN and OSCFN no se ejecutan correctamente en FC 0.184.
Las soluciones que veo en este momento son las siguientes:
  • La solución que resuelve mas problemas (posiblemente no todos) es tomar ICSGV y OSCFV e implementar los cambios que permiten la correcta ejecución de PE e instalarlos en una versión de FC con una versión correcta de OCC. FC 0.19 windows 10 no puede por la versión de OCC que usa. La pregunta que queda abierta si esto se hiciera es si los problemas que he tenido ejecutando operaciones Booleanas en 3D permanecen existentes.
  • Implementar los cambios necesarios para que FC 0.184 pueda trabajar con ICSGN and OSCFN. EXS se vuelve funcional pero el trabajo de implementar simples operaciones booleanas permanece pendiente en esta solución.
  • Implementar la LDWG disponible en ICSGV y OSCFV en ICSGN y OSCFN y entonces ejecutar la solución anterior. Existe la posibilidad de que esto resuelva las simples operaciones Booleanas.
  • Encontrar una versión 0.19 para Windows 10 que utilize OCC diferente a 7.5.0 y 7.5.1.
Escoja la que le paresca mas viable.
keithsloan52
Posts: 2092
Joined: Mon Feb 27, 2012 5:31 pm

Re: Have an Openscad to Freecad conundrum to solve

Post by keithsloan52 »

Yuri wrote: Fri May 21, 2021 3:14 am The unfortunate thing is that I went on to uninstall 0.192 to give way to 0.191 exactly at the link provided by Keith which clearly says 0.191, however, the information that I get from the about freecad menu item is:

Code: Select all

OS: Windows 10 Version 2004
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24276 (Git)
Build type: Release
Branch: releases/FreeCAD-0-19
Hash: a88db11e0a908f6e38f92bfc5187b13ebe470438
Python version: 3.8.6+
Qt version: 5.15.1
Coin version: 4.0.1
OCC version: 7.5.0
Locale: English/Canada (en_CA)
The library tab confirms OCC 7.5.0

So where keith pointed at says 0.191 where in fact seems to be 0.192.

I didn't know this when I downloaded so that I went happy to test my files. I'm at the exact point as I was before. Same problems.

Note that the version pointed out by Keith, doesn't deal correctly with the partial rotate extrude so that the latest importCSG and the OpenSCADFeatures by chennes are still needed.

So, Keith is right: there is a lot of misinformation out there.

Plus, from what Keith says, it seems that 0.191 is in fact available in the download for Macs.

Could one, among all the misinformation decipher where the 0.191 for windows with the proper OCC is ? The one that keith has in his Mac.
You could try one of Realthunders branches https://github.com/realthunder/FreeCAD_ ... 3/releases

Don't know if it would work on Windows, but after I install FreeCAD I rename it ( On Mac In Applications directory ).
Currently I have 8 versions I can call up without overwriting reinstalling
FDC30FE4-15D6-4372-A445-DB33B47172AD_4_5005_c.jpeg
FDC30FE4-15D6-4372-A445-DB33B47172AD_4_5005_c.jpeg (19.74 KiB) Viewed 805 times
Yuri
Posts: 34
Joined: Sun May 09, 2021 1:14 am

Re: Have an Openscad to Freecad conundrum to solve

Post by Yuri »

A major leap forward. Almost finished.

Remember that I hypothesized that:
The solution that solves more problems (possibly not all) is to take ICSGV and OSCFV and implement the changes that allow the correct execution of PE and install them in a version of FC with a correct version of OCC. FC 0.19 windows 10 cannot because of the OCC version it uses. The question that remains open if this were to be done is whether the problems I have had executing Boolean operations in 3D remain.
I tried this one.
As you may recollect I implemented changes suggested by Keith to enable the PE in the importCSG.py available in:

Code: Select all

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 32-bit
Version: 0.18.4 (GitTag)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 980bf9060e28555fecd9e3462f68ca74007b70f8
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/Canada (en_CA)
But I was getting no execution at all. Then I attempted to install the new importCSG and OpenSCADFeatures supplied by chennes here:
https://github.com/FreeCAD/FreeCAD/blob ... s.py[URL] https://github.com/FreeCAD/FreeCAD/blob ... portCSG.py[/url]

which will be referred to as new in the version above and I obtained the error below:

Code: Select all

File "<string>", line 1, in <module>
File "C:\Program Files (x86)\FreeCAD 0.18\Mod\OpenSCAD\importCSG.py", line 42, in <module>
from OpenSCADFeatures import *
<type 'exceptions.SyntaxError'>: ("Non-ASCII character '\\xc2' in file C:\\Program Files (x86)\\FreeCAD 0.18\\Mod\\OpenSCAD\\OpenSCADFeatures.py on line 468, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details", ('C:\\Program Files (x86)\\FreeCAD 0.18\\Mod\\OpenSCAD\\OpenSCADFeatures.py', 468, 0, None))
Today, I thought that I may take the changes that deal with PE in the new ones to the old ones originally installed in the version above and there was a chance that I may succeed.
So the code in the new one:

Code: Select all

def p_rotate_extrude_action(p): 
    'rotate_extrude_action : rotate_extrude LPAREN keywordargument_list RPAREN OBRACE block_list EBRACE'
    if printverbose: print("Rotate Extrude") 
    angle = 360.0
    if 'angle' in p[3]:
        angle = float(p[3]['angle'])
    n = int(round(float(p[3]['$fn'])))
    fnmax = FreeCAD.ParamGet(\
        "User parameter:BaseApp/Preferences/Mod/OpenSCAD").\
        GetInt('useMaxFN', 16)
    if (len(p[6]) > 1) :
        part = fuse(p[6],"Rotate Extrude Union")
    else :
        part = p[6][0]

    if n < 3 or fnmax != 0 and n > fnmax:
        p[0] = [process_rotate_extrude(part,angle)]
    else:
        p[0] = [process_rotate_extrude_prism(part,angle,n)]
    if printverbose: print("End Rotate Extrude")
went on to replace the older definition. And also the code in the new one:

Code: Select all

def process_rotate_extrude(obj, angle):
    newobj=doc.addObject("Part::FeaturePython",'RefineRotateExtrude')
    RefineShape(newobj,obj)
    if gui:
        if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/OpenSCAD").\
            GetBool('useViewProviderTree'):
            from OpenSCADFeatures import ViewProviderTree
            ViewProviderTree(newobj.ViewObject)
        else:
            newobj.ViewObject.Proxy = 0
        obj.ViewObject.hide()
    myrev = doc.addObject("Part::Revolution","RotateExtrude")
    myrev.Source = newobj
    myrev.Axis = (0.00,1.00,0.00)
    myrev.Base = (0.00,0.00,0.00)
    myrev.Angle = angle
    myrev.Placement=FreeCAD.Placement(FreeCAD.Vector(),FreeCAD.Rotation(0,0,90))
    if gui:
        newobj.ViewObject.hide()
    return(myrev)
went on to replace the old definition. The definition below which only exist in the new importCSG was pasted into the old one:

Code: Select all

def process_rotate_extrude_prism(obj, angle, n):


You will also find a line in the old one having the call to

Code: Select all

process_rotate_extrude(obj)
which should be

Code: Select all

def process_rotate_extrude_prism(obj, angle,):
And guess what, not only it did work in the 0.184 version above but also as per
The question that remains open if this were to be done is whether the problems I have had executing Boolean operations in 3D remain


The solution did remove the problems with the simple and way more complicated booleans imported from Openscad files which rely on dwg imports. It takes FC probably one minute or more to open the scad files.

I still have a problem that doesn't seem to be too big but for the most part all of my parts can be uploaded to FC from openscad without errors. Given that the OCC of the 0.184 version export steps correctly, I suspect that the step export of the last 2 files will work.

If I solve my last "small" problem I will come back to inform you, If not, I may need your help again.
Last edited by Yuri on Mon May 24, 2021 2:17 am, edited 2 times in total.
Yuri
Posts: 34
Joined: Sun May 09, 2021 1:14 am

Re: Have an Openscad to Freecad conundrum to solve

Post by Yuri »

It seems that the problems have been resolved.

Is it you that close threads?
GeneFC
Posts: 2839
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Have an Openscad to Freecad conundrum to solve

Post by GeneFC »

Yuri wrote: Sun May 23, 2021 7:59 pm It seems that the problems have been resolved.
Is it you that close threads?
Threads never "close". If you think you have all the answers you need then you can go back and edit the subject of the very first post. Add [Solved] at the beginning of the subject.

Gene
Post Reply