problems with 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!
jon_bondy
Posts: 9
Joined: Sat Jul 30, 2016 12:06 pm

problems with OpenSCAD

Post by jon_bondy »

When I try to open a fairly complex OpenSCAD model in CSG format, FreeCAD goes into an infinite loop, asking that the dxf libraries be loaded. I clicked OK over 100 times and then gave up.

Note that the dxf files cannot be loaded automatically for some reason, but I did load them manually. This has not stopped the flurry of requests that I load the dxf libraries manually. When I loaded the libraries manually, it was clear what to load for 0.14 and 0.15, but not for 0.16 (which I have), so I could have loaded the wrong files. I'm not sure how to determine whether I loaded them correctly. I have attached a screen shot of the macros.

At one point, I was able to load an OpenSCAD model, but it had errors (as shown in the attached screen shots). Note that the use of the "\\" appears to be invalid syntax. And the files mentioned are nowhere to be found on my system (not surprising if FreeCAD wrote them to an invalid path).

This FreeCAD feature is important to me, so I am willing to work on getting things sorted out. I cannot, unfortunately, share the OpenSCAD file (in either SCAD or CSG format) because the IP involved does not belong to me, but rather to a customer.

Jon

OS: Windows
Word size of OS: 64-bit
Word size of FreeCAD: 32-bit
Version: 0.16.6704 (Git)
Build type: Release
Branch: releases/FreeCAD-0-16
Hash: 0c449d7e8f9b2b1fb93e3f8d1865e2f59d7ed253
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Attachments
FreeCad dxf Files.PNG
FreeCad dxf Files.PNG (10.5 KiB) Viewed 5257 times
FreeCAD Error 1.PNG
FreeCAD Error 1.PNG (11.14 KiB) Viewed 5257 times
FreeCAD Error 2.PNG
FreeCAD Error 2.PNG (13.68 KiB) Viewed 5257 times
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: problems with OpenSCAD

Post by jmaustpc »

jon_bondy wrote:I cannot, unfortunately, share the OpenSCAD file (in either SCAD or CSG format) because the IP involved does not belong to me, but rather to a customer.
Can you create an as simple as possible model of random shapes that demonstrates the issue?
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: problems with OpenSCAD

Post by keithsloan52 »

I think there is potentially 3 problems here.

The following is my understanding which may of course be wrong.

1) I started importCSG.py and Sebastian Hogen shogen added the dxf handling aspects. He used calls to what were then existing functions in the FreeCAD dxf importer. Because of licensing problems with the dxf importer that FreeCAD used, things were first changed to not ship the library but download it. Subsequently I think Yorik rewrote or reworked the library and at that point importCSG.py broke with the rework. IMHO What importCSG needs is access to a function to load a DXF file and create a FreeCAD object, this is slightly different to what FreeCAD needs which is to create a FreeCAD document from a dxf file. Given such a function then I think importCSG could be modified to work with it. I did raise this with Yorik some time ago, but he just wished me luck. Anyway the bottom line is that importCSG may currently be broken when handling dxf files. Last I heard Sebastian was very busy with other things and did not think doing any updates was worth the effort,

2) The handling of OpenSCAD hull and minkowski requests are potentially troublesome and at least very slow. The way things work is that a mesh is created for the source FreeCAD objects, OpenSCAD is then called with the hull request and mesh and the output mesh from OpenSCAD is converted back to a FreeCAD object. I would not be surprised if there were not some bugs in the process. At the very least it makes things very slow. Just try to load a simple file with a simple hull request and you will see what I mean.

3) The latest version of OpenSCAD has introduced new CSG function like offset which is very difficult to handle in FreeCAD
jon_bondy
Posts: 9
Joined: Sat Jul 30, 2016 12:06 pm

Re: problems with OpenSCAD

Post by jon_bondy »

Thanks for the suggestions.

I have attached the latest LOG file. Towards the end, notice the repeated attempts to load the DXF libraries. I either need to understand why this is happening (so I can inspect and modify my OpenSCAD code) or the attempts to update need to succeed.

I do not need to do this often, so the fact that it is slow does not concern me. The fact that it does not work does concern me.

I have simplified things, but I have to click OK endlessly (literally: it never stops).

Jon
Attachments
FreeCAD.log
(14.81 KiB) Downloaded 123 times
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: problems with OpenSCAD

Post by keithsloan52 »

jon_bondy wrote:Thanks for the suggestions.

I have attached the latest LOG file. Towards the end, notice the repeated attempts to load the DXF libraries. I either need to understand why this is happening (so I can inspect and modify my OpenSCAD code) or the attempts to update need to succeed.

I do not need to do this often, so the fact that it is slow does not concern me. The fact that it does not work does concern me.

I have simplified things, but I have to click OK endlessly (literally: it never stops).

Jon
You probably have multiple import_dxf requests which is quite valid. As to why it try's to reload the library I suspect that dxf handling with CSG files may well be broke. You could try sending a private msg to user shoogen to see if he is willing to help.
jon_bondy
Posts: 9
Joined: Sat Jul 30, 2016 12:06 pm

Re: problems with OpenSCAD

Post by jon_bondy »

BTW, on my Win 10 machine, running FireFox, all of the dxf files appear to being downloaded, but perhaps not into the place that FreeCAD is expecting. I found a load of them in the folder where I store all of my downloaded files

Jon
jon_bondy
Posts: 9
Joined: Sat Jul 30, 2016 12:06 pm

Re: problems with OpenSCAD

Post by jon_bondy »

I switched to 0.15. I get no dxf library error messages, and the calculations run to completion, but there are errors. Hull gets "maximum recursion depth exceeded while calling a Python object", so I guess I'm hosed.

Perhaps the problems I encountered with dxf libraries and 0.16 was because I had loaded the libraries for 0.15, and 0.16 was repeatedly trying to acquire different files.

Jon
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: problems with OpenSCAD

Post by keithsloan52 »

Hull has nothing to do with dxf or dxf libraries so I guess you hit a limitation/bug.

In the source scad/csg you could try changing hull to union. Might get you something close, that you could work with.
jon_bondy
Posts: 9
Joined: Sat Jul 30, 2016 12:06 pm

Re: problems with OpenSCAD

Post by jon_bondy »

Replacing hull() with union() will not produce geometry that is even close to correct.

I was setting $fn to 100, so I removed that, so that I could use the default values. The idea was to simplify all of the geometry so that the Python recursion would stop failing. This did not correct the problem, so there may well be a bug in FreeCAD.

I have attached a CSG file that demonstrates the recursion problem in 0.15.

Jon
Attachments
Hull Test For FreeCAD.csg
(1020 Bytes) Downloaded 105 times
keithsloan52
Veteran
Posts: 2756
Joined: Mon Feb 27, 2012 5:31 pm

Re: problems with OpenSCAD

Post by keithsloan52 »

Okay I am on FreeCAD Version
OS: Ubuntu 14.04.4 LTS
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.16.6703 (Git)
Build type: None
Branch: releases/FreeCAD-0-16
Hash: 2ce5c8d2e3020d05005ed71f710e09e9aa561f40
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17

I have no problem with loading dxf library

I edited /usr/lib/freecad/Mod/importCSG.py
and changed line 34 printVerbose=False to printVerbose=True

Then invoked FreeCAD from the command line with freecad >> /tmp/freecad_log
I then tried to open your file "Hull Test For FreeCAD.csg"
FreeCAD goes into a loop and looking at the freecad_log it goes into a loop exporting dxf files for circle and circle1
So there is definitely a bug. I added python print statements for debugging and it calls OpenSCAD but then goes back to exporting the dxf files for the circles. I am busy tomorrow will have another look Friday evening.
Last edited by keithsloan52 on Wed Aug 03, 2016 8:08 pm, edited 2 times in total.
Post Reply