discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

FreeCAD to openSCAD export time

RW
Rogier Wolff
Mon, Apr 11, 2022 12:48 PM

Hi,

What I'm saying is that the quick-and-dirty method should at least
work. And it's easy to implement if you can do STL.

The thing is that, no mater how you export, the resulting file will be
close to unreadable. So the blunt points and faces method isn't much
worse than trying to export primitives.

the reason I expect the resulting file to possibly be "too large to
read" is that if you have a primitive "sphere", the customary
"approximation accuracy" is to set $fn to 50 max in openscad. But
somehow, that seems a bit odd: modern graphics cards can handle
millions of triangles per second, so it should be possible to render a
sphere with say $fn=500. Openscad has some limitation that makes this
unreasonable. Maybe freecad doesn't have that restriction and will
happily write out a million entry vertex-array. Reading that may take
longer than expected, even with little processing going on.

Also if the programmer didn't expect this size of array, then maybe
that's also a problem.

For example, e2fsck was written to store stuff in a database when
things got too large for memory. This was stored in a "smalldb",
"simpledb" or something like that. Turns out e2fsck's use was "simple"
but the database was not SMALL, which the writer of the library had
assumed. And instead of bombing out, the library would tolerate going beyond
the expected size, but become terribly slow.

I had raid arrays with millions of files before anybody else. An fsck
was expected to run for over a month (based on the progress after say
a day, but performance was quadratic, so the first 3% probably went
30x faster than the last 3% would have. Anyway, diagnosing and writing
the fix was faster than waiting for it to finish.

You can expect openscad coders to expect you to type out a few
vertices and triangles for non-primitives as arguments to polyhedron.
But in this machine generated file the order of magnitude can be off
quite a lot.

Roger. 

On Mon, Apr 11, 2022 at 01:15:17PM +0100, nop head wrote:

CAD designs are not arbitrary points on meshes. They are some
representation of primitives and operations on them, just as OpenSCAD is.
So it can't be too hard to convert one internal representation, which is
generally a tree, to OpenSCAD, which is a textual representation of a tree.
The only issues are when there are missing primitives or missing operations
in OpenSCAD compared to FreeCAD. For example if you can make fillets easily
in FreeCAD then it would get tricky to represent them in OpenSCAD. But I
can't see it being computationally expensive until the geometry actually
needs to be rendered in OpenSCAD.

On Mon, 11 Apr 2022 at 08:46, Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

It seems extremely difficult to me.
How would you decide the ordering or sequence of arbitrary points.

On Mon, 11 Apr 2022, 12:58 Rogier Wolff, R.E.Wolff@bitwizard.nl wrote:

On Sun, Apr 10, 2022 at 07:26:28PM -0400, jon wrote:

"export to OpenSCAD" makes me think that some arbitrary CAD design has

to be

decomposed into OpenSCAD source code.  That sounds stunningly

challenging.

Perhaps I am misunderstanding the original posting

If you can export-to-stl, you can also export-to-openscad in the same
way.

An STL is essentially a list-of-vertices and then a list-of-triangles
where each triangle is three references to a vertex from the list.

You can do that in openscad exactly like that.

points = [[0,0,0],[0,0,1], [0,1,0],[0,1,1],
[1,0,0],[1,0,1], [1,1,0],[1,1,1]];
triangles = [[0,1,2],[1,2,3],  [0,1,4], [1,4,5],
[0,2,4],[2,4,6],  [7,6,5], [6,5,4],
[7,6,3],[6,3,2], [7,5,3], [5,3,1];
polyhedron (points=points, faces=triangles, convexity=5);

     Roger.

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110
**
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233
**
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

Hi, What I'm saying is that the quick-and-dirty method should at least work. And it's easy to implement if you can do STL. The thing is that, no mater how you export, the resulting file will be close to unreadable. So the blunt points and faces method isn't much worse than trying to export primitives. the reason I expect the resulting file to possibly be "too large to read" is that if you have a primitive "sphere", the customary "approximation accuracy" is to set $fn to 50 max in openscad. But somehow, that seems a bit odd: modern graphics cards can handle millions of triangles per second, so it should be possible to render a sphere with say $fn=500. Openscad has some limitation that makes this unreasonable. Maybe freecad doesn't have that restriction and will happily write out a million entry vertex-array. Reading that may take longer than expected, even with little processing going on. Also if the programmer didn't expect this size of array, then maybe that's also a problem. For example, e2fsck was written to store stuff in a database when things got too large for memory. This was stored in a "smalldb", "simpledb" or something like that. Turns out e2fsck's use was "simple" but the database was not SMALL, which the writer of the library had assumed. And instead of bombing out, the library would tolerate going beyond the expected size, but become terribly slow. I had raid arrays with millions of files before anybody else. An fsck was expected to run for over a month (based on the progress after say a day, but performance was quadratic, so the first 3% probably went 30x faster than the last 3% would have. Anyway, diagnosing and writing the fix was faster than waiting for it to finish. You can expect openscad coders to expect you to type out a few vertices and triangles for non-primitives as arguments to polyhedron. But in this machine generated file the order of magnitude can be off quite a lot. Roger. On Mon, Apr 11, 2022 at 01:15:17PM +0100, nop head wrote: > CAD designs are not arbitrary points on meshes. They are some > representation of primitives and operations on them, just as OpenSCAD is. > So it can't be too hard to convert one internal representation, which is > generally a tree, to OpenSCAD, which is a textual representation of a tree. > The only issues are when there are missing primitives or missing operations > in OpenSCAD compared to FreeCAD. For example if you can make fillets easily > in FreeCAD then it would get tricky to represent them in OpenSCAD. But I > can't see it being computationally expensive until the geometry actually > needs to be rendered in OpenSCAD. > > On Mon, 11 Apr 2022 at 08:46, Sanjeev Prabhakar <sprabhakar2006@gmail.com> > wrote: > > > It seems extremely difficult to me. > > How would you decide the ordering or sequence of arbitrary points. > > > > > > > > On Mon, 11 Apr 2022, 12:58 Rogier Wolff, <R.E.Wolff@bitwizard.nl> wrote: > > > >> On Sun, Apr 10, 2022 at 07:26:28PM -0400, jon wrote: > >> > "export to OpenSCAD" makes me think that some arbitrary CAD design has > >> to be > >> > decomposed into OpenSCAD source code. That sounds stunningly > >> challenging. > >> > Perhaps I am misunderstanding the original posting > >> > >> If you can export-to-stl, you can also export-to-openscad in the same > >> way. > >> > >> An STL is essentially a list-of-vertices and then a list-of-triangles > >> where each triangle is three references to a vertex from the list. > >> > >> You can do that in openscad exactly like that. > >> > >> points = [[0,0,0],[0,0,1], [0,1,0],[0,1,1], > >> [1,0,0],[1,0,1], [1,1,0],[1,1,1]]; > >> triangles = [[0,1,2],[1,2,3], [0,1,4], [1,4,5], > >> [0,2,4],[2,4,6], [7,6,5], [6,5,4], > >> [7,6,3],[6,3,2], [7,5,3], [5,3,1]; > >> polyhedron (points=points, faces=triangles, convexity=5); > >> > >> Roger. > >> > >> -- > >> ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 > >> ** > >> ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 > >> ** > >> f equals m times a. When your f is steady, and your m is going down > >> your a is going up. -- Chris Hadfield about flying up the space shuttle. > >> _______________________________________________ > >> OpenSCAD mailing list > >> To unsubscribe send an email to discuss-leave@lists.openscad.org > >> > > _______________________________________________ > > OpenSCAD mailing list > > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org -- ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 ** f equals m times a. When your f is steady, and your m is going down your a is going up. -- Chris Hadfield about flying up the space shuttle.
J
jon
Mon, Apr 11, 2022 1:04 PM

I wonder if the OP could explain exactly what they are trying to do. 
Why bother to export to OpenSCAD if the result is impossible to
comprehend?  What would the advantage be?  If you want to drill a hole
in an object, you can do that with OpenSCAD if you have the object as an
STL, and FreeCAD should be able to export an STL (and drill a hole)
quickly and easily.

On 4/11/2022 8:48 AM, Rogier Wolff wrote:

Hi,

What I'm saying is that the quick-and-dirty method should at least
work. And it's easy to implement if you can do STL.

The thing is that, no mater how you export, the resulting file will be
close to unreadable. So the blunt points and faces method isn't much
worse than trying to export primitives.

the reason I expect the resulting file to possibly be "too large to
read" is that if you have a primitive "sphere", the customary
"approximation accuracy" is to set $fn to 50 max in openscad. But
somehow, that seems a bit odd: modern graphics cards can handle
millions of triangles per second, so it should be possible to render a
sphere with say $fn=500. Openscad has some limitation that makes this
unreasonable. Maybe freecad doesn't have that restriction and will
happily write out a million entry vertex-array. Reading that may take
longer than expected, even with little processing going on.

Also if the programmer didn't expect this size of array, then maybe
that's also a problem.

For example, e2fsck was written to store stuff in a database when
things got too large for memory. This was stored in a "smalldb",
"simpledb" or something like that. Turns out e2fsck's use was "simple"
but the database was not SMALL, which the writer of the library had
assumed. And instead of bombing out, the library would tolerate going beyond
the expected size, but become terribly slow.

I had raid arrays with millions of files before anybody else. An fsck
was expected to run for over a month (based on the progress after say
a day, but performance was quadratic, so the first 3% probably went
30x faster than the last 3% would have. Anyway, diagnosing and writing
the fix was faster than waiting for it to finish.

You can expect openscad coders to expect you to type out a few
vertices and triangles for non-primitives as arguments to polyhedron.
But in this machine generated file the order of magnitude can be off
quite a lot.

Roger.

On Mon, Apr 11, 2022 at 01:15:17PM +0100, nop head wrote:

CAD designs are not arbitrary points on meshes. They are some
representation of primitives and operations on them, just as OpenSCAD is.
So it can't be too hard to convert one internal representation, which is
generally a tree, to OpenSCAD, which is a textual representation of a tree.
The only issues are when there are missing primitives or missing operations
in OpenSCAD compared to FreeCAD. For example if you can make fillets easily
in FreeCAD then it would get tricky to represent them in OpenSCAD. But I
can't see it being computationally expensive until the geometry actually
needs to be rendered in OpenSCAD.

On Mon, 11 Apr 2022 at 08:46, Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

It seems extremely difficult to me.
How would you decide the ordering or sequence of arbitrary points.

On Mon, 11 Apr 2022, 12:58 Rogier Wolff, R.E.Wolff@bitwizard.nl wrote:

On Sun, Apr 10, 2022 at 07:26:28PM -0400, jon wrote:

"export to OpenSCAD" makes me think that some arbitrary CAD design has
to be
decomposed into OpenSCAD source code.  That sounds stunningly
challenging.
Perhaps I am misunderstanding the original posting
If you can export-to-stl, you can also export-to-openscad in the same
way.

An STL is essentially a list-of-vertices and then a list-of-triangles
where each triangle is three references to a vertex from the list.

You can do that in openscad exactly like that.

points = [[0,0,0],[0,0,1], [0,1,0],[0,1,1],
[1,0,0],[1,0,1], [1,1,0],[1,1,1]];
triangles = [[0,1,2],[1,2,3],  [0,1,4], [1,4,5],
[0,2,4],[2,4,6],  [7,6,5], [6,5,4],
[7,6,3],[6,3,2], [7,5,3], [5,3,1];
polyhedron (points=points, faces=triangles, convexity=5);

     Roger.

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110
**
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233
**
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

I wonder if the OP could explain exactly what they are trying to do.  Why bother to export to OpenSCAD if the result is impossible to comprehend?  What would the advantage be?  If you want to drill a hole in an object, you can do that with OpenSCAD if you have the object as an STL, and FreeCAD should be able to export an STL (and drill a hole) quickly and easily. On 4/11/2022 8:48 AM, Rogier Wolff wrote: > Hi, > > What I'm saying is that the quick-and-dirty method should at least > work. And it's easy to implement if you can do STL. > > The thing is that, no mater how you export, the resulting file will be > close to unreadable. So the blunt points and faces method isn't much > worse than trying to export primitives. > > the reason I expect the resulting file to possibly be "too large to > read" is that if you have a primitive "sphere", the customary > "approximation accuracy" is to set $fn to 50 max in openscad. But > somehow, that seems a bit odd: modern graphics cards can handle > millions of triangles per second, so it should be possible to render a > sphere with say $fn=500. Openscad has some limitation that makes this > unreasonable. Maybe freecad doesn't have that restriction and will > happily write out a million entry vertex-array. Reading that may take > longer than expected, even with little processing going on. > > Also if the programmer didn't expect this size of array, then maybe > that's also a problem. > > For example, e2fsck was written to store stuff in a database when > things got too large for memory. This was stored in a "smalldb", > "simpledb" or something like that. Turns out e2fsck's use was "simple" > but the database was not SMALL, which the writer of the library had > assumed. And instead of bombing out, the library would tolerate going beyond > the expected size, but become terribly slow. > > I had raid arrays with millions of files before anybody else. An fsck > was expected to run for over a month (based on the progress after say > a day, but performance was quadratic, so the first 3% probably went > 30x faster than the last 3% would have. Anyway, diagnosing and writing > the fix was faster than waiting for it to finish. > > You can expect openscad coders to expect you to type out a few > vertices and triangles for non-primitives as arguments to polyhedron. > But in this machine generated file the order of magnitude can be off > quite a lot. > > Roger. > > > > On Mon, Apr 11, 2022 at 01:15:17PM +0100, nop head wrote: >> CAD designs are not arbitrary points on meshes. They are some >> representation of primitives and operations on them, just as OpenSCAD is. >> So it can't be too hard to convert one internal representation, which is >> generally a tree, to OpenSCAD, which is a textual representation of a tree. >> The only issues are when there are missing primitives or missing operations >> in OpenSCAD compared to FreeCAD. For example if you can make fillets easily >> in FreeCAD then it would get tricky to represent them in OpenSCAD. But I >> can't see it being computationally expensive until the geometry actually >> needs to be rendered in OpenSCAD. >> >> On Mon, 11 Apr 2022 at 08:46, Sanjeev Prabhakar <sprabhakar2006@gmail.com> >> wrote: >> >>> It seems extremely difficult to me. >>> How would you decide the ordering or sequence of arbitrary points. >>> >>> >>> >>> On Mon, 11 Apr 2022, 12:58 Rogier Wolff, <R.E.Wolff@bitwizard.nl> wrote: >>> >>>> On Sun, Apr 10, 2022 at 07:26:28PM -0400, jon wrote: >>>>> "export to OpenSCAD" makes me think that some arbitrary CAD design has >>>> to be >>>>> decomposed into OpenSCAD source code. That sounds stunningly >>>> challenging. >>>>> Perhaps I am misunderstanding the original posting >>>> If you can export-to-stl, you can also export-to-openscad in the same >>>> way. >>>> >>>> An STL is essentially a list-of-vertices and then a list-of-triangles >>>> where each triangle is three references to a vertex from the list. >>>> >>>> You can do that in openscad exactly like that. >>>> >>>> points = [[0,0,0],[0,0,1], [0,1,0],[0,1,1], >>>> [1,0,0],[1,0,1], [1,1,0],[1,1,1]]; >>>> triangles = [[0,1,2],[1,2,3], [0,1,4], [1,4,5], >>>> [0,2,4],[2,4,6], [7,6,5], [6,5,4], >>>> [7,6,3],[6,3,2], [7,5,3], [5,3,1]; >>>> polyhedron (points=points, faces=triangles, convexity=5); >>>> >>>> Roger. >>>> >>>> -- >>>> ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 >>>> ** >>>> ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 >>>> ** >>>> f equals m times a. When your f is steady, and your m is going down >>>> your a is going up. -- Chris Hadfield about flying up the space shuttle. >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >