import of openscad file fails

Post here for help on using FreeCAD's graphical user interface (GUI).
User avatar
NormandC
Posts: 15002
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: import of openscad file fails

Postby NormandC » Sun Apr 15, 2018 10:04 pm

boelle
Posts: 19
Joined: Sun Sep 03, 2017 12:31 pm

Re: import of openscad file fails

Postby boelle » Sun Apr 15, 2018 10:05 pm

utils/teardrops.scad

in there i saw:

Code: Select all

module teardrop_plus(h, r, center, truncate = true)
    teardrop(h, r + layer_height / 4, center, truncate);
keithsloan52
Posts: 617
Joined: Mon Feb 27, 2012 5:31 pm

Re: import of openscad file fails

Postby keithsloan52 » Sun Apr 15, 2018 10:31 pm

Okay, I have a simple test case that fails.

The following CSG file produces a teardrop shape in OpenSCAD

Code: Select all

hull() {
circle($fn = 0, $fa = 5, $fs = 0.5, r = 2.3);
group() {
multmatrix([[1, 0, 0, 0], [0, 1, 0, 1.15], [0, 0, 1, 0], [0, 0, 0, 1]]) {
square(size = [1.90538, 2.3], center = true);
}
Given the circle as $fn = 0 it should create a circle, but in FreeCAD it is creating an n sided ( in this case eight)polygon.

I will try and find some time to look at the code
keithsloan52
Posts: 617
Joined: Mon Feb 27, 2012 5:31 pm

Re: import of openscad file fails

Postby keithsloan52 » Mon Apr 16, 2018 7:13 am

The problem seems to be that when the FreeCAD importer (importCSG.py) encounters a 2D hull request where one of the objects is a circle it exports a DXF file that is an 8 sided polygon, rather than say a 50 sided polygon or a DXF circle.

The hull request is then passed to OpenSCAD with import dxf file requests for it to produce a DXF file
that is read in.

So the problem seems to be in the DXF library as invoked by the export function in .../Mod/Draft/ImportDXF.py

Unfortunately, the code is not easy to follow or debug. I think the dxf functions were written by @yorik so maybe he can shed some light.
keithsloan52
Posts: 617
Joined: Mon Feb 27, 2012 5:31 pm

Re: import of openscad file fails

Postby keithsloan52 » Mon Apr 16, 2018 1:33 pm

Okay after some more debugging.

I saved the dxf files that importCSG.py output before combing with the hull request.

They are circle which produced dxf file
file1.dxf
(709 Bytes) Downloaded 2 times
which looks like a circle in LibreCAD

square which produced dxf file
file2.dxf
(753 Bytes) Downloaded 1 time
which looks like a single line rather than a square in LibreCAD.
Which seems like a bug

Under the covers importCSG.py would make the following request
test3.cgm which looks like

Code: Select all

hull(){import(file = "file1.dxf"); import(file = "file2.dxf");}
and this renders as an 8 sided polygon with OpenSCAD.

If in OpenSCAD I do a straight import(file="file1.dxf"); I get an 8 sided polygon rather than a circle. I think this calls for a query in the OpenSCAD forum see http://forum.openscad.org/Import-of-dxf ... 23852.html

Got a horrible suspicion that this is going to turn out to be a limitation with OpenSCAD
Last edited by keithsloan52 on Mon Apr 16, 2018 1:54 pm, edited 1 time in total.
boelle
Posts: 19
Joined: Sun Sep 03, 2017 12:31 pm

Re: import of openscad file fails

Postby boelle » Mon Apr 16, 2018 1:50 pm

oki, but i have aksed them about the direct export to step and they just pointed at freecad

i assume that they will do similar with anything they are asked

i will try and ask them at some point, but just in the middle of a website upgrade task that is more important
keithsloan52
Posts: 617
Joined: Mon Feb 27, 2012 5:31 pm

Re: import of openscad file fails

Postby keithsloan52 » Mon Apr 16, 2018 1:59 pm

OpenSCAD is built on the wrong sort of architecture CGAL to support STEP which needs BREP as used by FreeCAD. Think you will wait a very long time as I don't think it is possible. Certainly is not easy.