import of openscad file fails

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!
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: import of openscad file fails

Post by NormandC »

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

Re: import of openscad file fails

Post by boelle »

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

Re: import of openscad file fails

Post by keithsloan52 »

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

Re: import of openscad file fails

Post by keithsloan52 »

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

Re: import of openscad file fails

Post by keithsloan52 »

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 52 times
which looks like a circle in LibreCAD

square which produced dxf file
file2.dxf
(753 Bytes) Downloaded 48 times
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: 28
Joined: Sun Sep 03, 2017 12:31 pm

Re: import of openscad file fails

Post by boelle »

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

Re: import of openscad file fails

Post by keithsloan52 »

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.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: import of openscad file fails

Post by wandererfan »

This should be fixed by git commit 9975c75888.

A user preference now controls how many segments are used when approximating a circle from Dxf -
"User parameter:BaseApp/Preferences/Mod/OpenSCAD/fnForImport". The default is 32 segments.
User avatar
wandererfan
Veteran
Posts: 6268
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: import of openscad file fails

Post by wandererfan »

y-bracket_fix.png
y-bracket_fix.png (4 KiB) Viewed 1324 times
Post Reply