discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Script to replicate hull and minkoswki for CSG export/import into FreeCAD

DM
doug moen
Fri, Mar 18, 2016 4:07 PM

Converting the model to a polyhedron would be no different from exporting
as STL and then importing the STL in FreeCAD.

Droftarts says that STL is no good because it doesn't "retain the geometry".

On 18 March 2016 at 12:02, Carsten Arnholm arnholm@arnholm.org wrote:

On 18. mars 2016 16:30, droftarts wrote:

And just to confirm, this exports as a CSG file, and imports nicely into
FreeCAD as :

http://forum.openscad.org/file/n16555/FreeCAD.png

Which exports happily as a STEP file, which Fusion 360 can import and
render:

http://forum.openscad.org/file/n16555/Fusion_360.png

Thanks! I'll try it with some more complex geometry, and see if it still
copes.

Does FreeCAD understand the polyhedron command? If so, OpenSCAD could have
an option to save the final body as a polyhedron to .csg, and you could
then use it in FreeCAD even if you had used Hull and Minkowski.

Carsten Arnholm


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Converting the model to a polyhedron would be no different from exporting as STL and then importing the STL in FreeCAD. Droftarts says that STL is no good because it doesn't "retain the geometry". On 18 March 2016 at 12:02, Carsten Arnholm <arnholm@arnholm.org> wrote: > On 18. mars 2016 16:30, droftarts wrote: > >> And just to confirm, this exports as a CSG file, and imports nicely into >> FreeCAD as : >> >> <http://forum.openscad.org/file/n16555/FreeCAD.png> >> >> Which exports happily as a STEP file, which Fusion 360 can import and >> render: >> >> <http://forum.openscad.org/file/n16555/Fusion_360.png> >> >> Thanks! I'll try it with some more complex geometry, and see if it still >> copes. >> > > Does FreeCAD understand the polyhedron command? If so, OpenSCAD could have > an option to save the final body as a polyhedron to .csg, and you could > then use it in FreeCAD even if you had used Hull and Minkowski. > > Carsten Arnholm > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > > >
NH
nop head
Fri, Mar 18, 2016 4:37 PM

Very true but he also said "so I can do some nice renders of it". My point
is you don't need geometry to get nice renders in Blender. It works with
meshes.

On 18 March 2016 at 16:07, doug moen doug@moens.org wrote:

Converting the model to a polyhedron would be no different from exporting
as STL and then importing the STL in FreeCAD.

Droftarts says that STL is no good because it doesn't "retain the
geometry".

On 18 March 2016 at 12:02, Carsten Arnholm arnholm@arnholm.org wrote:

On 18. mars 2016 16:30, droftarts wrote:

And just to confirm, this exports as a CSG file, and imports nicely into
FreeCAD as :

http://forum.openscad.org/file/n16555/FreeCAD.png

Which exports happily as a STEP file, which Fusion 360 can import and
render:

http://forum.openscad.org/file/n16555/Fusion_360.png

Thanks! I'll try it with some more complex geometry, and see if it still
copes.

Does FreeCAD understand the polyhedron command? If so, OpenSCAD could
have an option to save the final body as a polyhedron to .csg, and you
could then use it in FreeCAD even if you had used Hull and Minkowski.

Carsten Arnholm


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Very true but he also said "so I can do some nice renders of it". My point is you don't need geometry to get nice renders in Blender. It works with meshes. On 18 March 2016 at 16:07, doug moen <doug@moens.org> wrote: > Converting the model to a polyhedron would be no different from exporting > as STL and then importing the STL in FreeCAD. > > Droftarts says that STL is no good because it doesn't "retain the > geometry". > > On 18 March 2016 at 12:02, Carsten Arnholm <arnholm@arnholm.org> wrote: > >> On 18. mars 2016 16:30, droftarts wrote: >> >>> And just to confirm, this exports as a CSG file, and imports nicely into >>> FreeCAD as : >>> >>> <http://forum.openscad.org/file/n16555/FreeCAD.png> >>> >>> Which exports happily as a STEP file, which Fusion 360 can import and >>> render: >>> >>> <http://forum.openscad.org/file/n16555/Fusion_360.png> >>> >>> Thanks! I'll try it with some more complex geometry, and see if it still >>> copes. >>> >> >> Does FreeCAD understand the polyhedron command? If so, OpenSCAD could >> have an option to save the final body as a polyhedron to .csg, and you >> could then use it in FreeCAD even if you had used Hull and Minkowski. >> >> Carsten Arnholm >> >> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> >> > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
DM
doug moen
Fri, Mar 18, 2016 4:47 PM

My vague understanding of STEP is that it can preserve information like:
"this is a circle with radius r", which is lost if you export to STL, but
preserved in the CSG file. Droftarts is using circle() in his model, so
maybe he wants to preserve the identity of circles for use by the Blender
and Fusion360 rendering engines?

On 18 March 2016 at 12:37, nop head nop.head@gmail.com wrote:

Very true but he also said "so I can do some nice renders of it". My point
is you don't need geometry to get nice renders in Blender. It works with
meshes.

On 18 March 2016 at 16:07, doug moen doug@moens.org wrote:

Converting the model to a polyhedron would be no different from exporting
as STL and then importing the STL in FreeCAD.

Droftarts says that STL is no good because it doesn't "retain the
geometry".

On 18 March 2016 at 12:02, Carsten Arnholm arnholm@arnholm.org wrote:

On 18. mars 2016 16:30, droftarts wrote:

And just to confirm, this exports as a CSG file, and imports nicely into
FreeCAD as :

http://forum.openscad.org/file/n16555/FreeCAD.png

Which exports happily as a STEP file, which Fusion 360 can import and
render:

http://forum.openscad.org/file/n16555/Fusion_360.png

Thanks! I'll try it with some more complex geometry, and see if it still
copes.

Does FreeCAD understand the polyhedron command? If so, OpenSCAD could
have an option to save the final body as a polyhedron to .csg, and you
could then use it in FreeCAD even if you had used Hull and Minkowski.

Carsten Arnholm


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

My vague understanding of STEP is that it can preserve information like: "this is a circle with radius r", which is lost if you export to STL, but preserved in the CSG file. Droftarts is using circle() in his model, so maybe he wants to preserve the identity of circles for use by the Blender and Fusion360 rendering engines? On 18 March 2016 at 12:37, nop head <nop.head@gmail.com> wrote: > Very true but he also said "so I can do some nice renders of it". My point > is you don't need geometry to get nice renders in Blender. It works with > meshes. > > On 18 March 2016 at 16:07, doug moen <doug@moens.org> wrote: > >> Converting the model to a polyhedron would be no different from exporting >> as STL and then importing the STL in FreeCAD. >> >> Droftarts says that STL is no good because it doesn't "retain the >> geometry". >> >> On 18 March 2016 at 12:02, Carsten Arnholm <arnholm@arnholm.org> wrote: >> >>> On 18. mars 2016 16:30, droftarts wrote: >>> >>>> And just to confirm, this exports as a CSG file, and imports nicely into >>>> FreeCAD as : >>>> >>>> <http://forum.openscad.org/file/n16555/FreeCAD.png> >>>> >>>> Which exports happily as a STEP file, which Fusion 360 can import and >>>> render: >>>> >>>> <http://forum.openscad.org/file/n16555/Fusion_360.png> >>>> >>>> Thanks! I'll try it with some more complex geometry, and see if it still >>>> copes. >>>> >>> >>> Does FreeCAD understand the polyhedron command? If so, OpenSCAD could >>> have an option to save the final body as a polyhedron to .csg, and you >>> could then use it in FreeCAD even if you had used Hull and Minkowski. >>> >>> Carsten Arnholm >>> >>> >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> Discuss@lists.openscad.org >>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>> >>> >>> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
NH
nop head
Fri, Mar 18, 2016 4:58 PM

My guess is he needs it for Fusion360 but I don't think Blender understands
circles. You can get a nice render of a textured cylinder with not many
facets by interpolating the normals in the lighting calculation.

On 18 March 2016 at 16:47, doug moen doug@moens.org wrote:

My vague understanding of STEP is that it can preserve information like:
"this is a circle with radius r", which is lost if you export to STL, but
preserved in the CSG file. Droftarts is using circle() in his model, so
maybe he wants to preserve the identity of circles for use by the Blender
and Fusion360 rendering engines?

On 18 March 2016 at 12:37, nop head nop.head@gmail.com wrote:

Very true but he also said "so I can do some nice renders of it". My
point is you don't need geometry to get nice renders in Blender. It works
with meshes.

On 18 March 2016 at 16:07, doug moen doug@moens.org wrote:

Converting the model to a polyhedron would be no different from
exporting as STL and then importing the STL in FreeCAD.

Droftarts says that STL is no good because it doesn't "retain the
geometry".

On 18 March 2016 at 12:02, Carsten Arnholm arnholm@arnholm.org wrote:

On 18. mars 2016 16:30, droftarts wrote:

And just to confirm, this exports as a CSG file, and imports nicely
into
FreeCAD as :

http://forum.openscad.org/file/n16555/FreeCAD.png

Which exports happily as a STEP file, which Fusion 360 can import and
render:

http://forum.openscad.org/file/n16555/Fusion_360.png

Thanks! I'll try it with some more complex geometry, and see if it
still
copes.

Does FreeCAD understand the polyhedron command? If so, OpenSCAD could
have an option to save the final body as a polyhedron to .csg, and you
could then use it in FreeCAD even if you had used Hull and Minkowski.

Carsten Arnholm


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

My guess is he needs it for Fusion360 but I don't think Blender understands circles. You can get a nice render of a textured cylinder with not many facets by interpolating the normals in the lighting calculation. On 18 March 2016 at 16:47, doug moen <doug@moens.org> wrote: > My vague understanding of STEP is that it can preserve information like: > "this is a circle with radius r", which is lost if you export to STL, but > preserved in the CSG file. Droftarts is using circle() in his model, so > maybe he wants to preserve the identity of circles for use by the Blender > and Fusion360 rendering engines? > > On 18 March 2016 at 12:37, nop head <nop.head@gmail.com> wrote: > >> Very true but he also said "so I can do some nice renders of it". My >> point is you don't need geometry to get nice renders in Blender. It works >> with meshes. >> >> On 18 March 2016 at 16:07, doug moen <doug@moens.org> wrote: >> >>> Converting the model to a polyhedron would be no different from >>> exporting as STL and then importing the STL in FreeCAD. >>> >>> Droftarts says that STL is no good because it doesn't "retain the >>> geometry". >>> >>> On 18 March 2016 at 12:02, Carsten Arnholm <arnholm@arnholm.org> wrote: >>> >>>> On 18. mars 2016 16:30, droftarts wrote: >>>> >>>>> And just to confirm, this exports as a CSG file, and imports nicely >>>>> into >>>>> FreeCAD as : >>>>> >>>>> <http://forum.openscad.org/file/n16555/FreeCAD.png> >>>>> >>>>> Which exports happily as a STEP file, which Fusion 360 can import and >>>>> render: >>>>> >>>>> <http://forum.openscad.org/file/n16555/Fusion_360.png> >>>>> >>>>> Thanks! I'll try it with some more complex geometry, and see if it >>>>> still >>>>> copes. >>>>> >>>> >>>> Does FreeCAD understand the polyhedron command? If so, OpenSCAD could >>>> have an option to save the final body as a polyhedron to .csg, and you >>>> could then use it in FreeCAD even if you had used Hull and Minkowski. >>>> >>>> Carsten Arnholm >>>> >>>> >>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> Discuss@lists.openscad.org >>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>>> >>>> >>>> >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> Discuss@lists.openscad.org >>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>> >>> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
CA
Carsten Arnholm
Fri, Mar 18, 2016 5:58 PM

On 18. mars 2016 17:07, doug moen wrote:

Converting the model to a polyhedron would be no different from exporting
as STL and then importing the STL in FreeCAD.

That makes no sense. The model is effectively a polyhedron mesh and
does not need to be converted.

Droftarts says that STL is no good because it doesn't "retain the

geometry".

STL is ALL geometry and no topology, unlike a polyhedron. It may be true
it does not retain the geometry either, depending on how the coordinates
are modified.

Does FreeCAD understand the polyhedron command?

Carsten Arnholm

On 18. mars 2016 17:07, doug moen wrote: > Converting the model to a polyhedron would be no different from exporting > as STL and then importing the STL in FreeCAD. That makes no sense. The model *is* effectively a polyhedron mesh and does not need to be converted. > Droftarts says that STL is no good because it doesn't "retain the geometry". STL is ALL geometry and no topology, unlike a polyhedron. It may be true it does not retain the geometry either, depending on how the coordinates are modified. Does FreeCAD understand the polyhedron command? Carsten Arnholm
CA
Carsten Arnholm
Fri, Mar 18, 2016 6:30 PM

On 18. mars 2016 18:58, Carsten Arnholm wrote:

Does FreeCAD understand the polyhedron command?

I just tried it and it doesn't.

I guess the explanation is that FreeCAD is based on OpenCASCADE which
does booleans on a B-rep model only.

Carsten Arnholm

On 18. mars 2016 18:58, Carsten Arnholm wrote: > Does FreeCAD understand the polyhedron command? I just tried it and it doesn't. I guess the explanation is that FreeCAD is based on OpenCASCADE which does booleans on a B-rep model only. Carsten Arnholm
NH
nop head
Fri, Mar 18, 2016 6:34 PM

By "geometry" people mean CSG in this context. I.e. cylinders and cubes,
etc, as opposed to a triangle mesh.

On 18 March 2016 at 17:58, Carsten Arnholm arnholm@arnholm.org wrote:

On 18. mars 2016 17:07, doug moen wrote:

Converting the model to a polyhedron would be no different from exporting
as STL and then importing the STL in FreeCAD.

That makes no sense. The model is effectively a polyhedron mesh and does
not need to be converted.

Droftarts says that STL is no good because it doesn't "retain the

geometry".

STL is ALL geometry and no topology, unlike a polyhedron. It may be true
it does not retain the geometry either, depending on how the coordinates
are modified.

Does FreeCAD understand the polyhedron command?

Carsten Arnholm


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

By "geometry" people mean CSG in this context. I.e. cylinders and cubes, etc, as opposed to a triangle mesh. On 18 March 2016 at 17:58, Carsten Arnholm <arnholm@arnholm.org> wrote: > On 18. mars 2016 17:07, doug moen wrote: > >> Converting the model to a polyhedron would be no different from exporting >> as STL and then importing the STL in FreeCAD. >> > > That makes no sense. The model *is* effectively a polyhedron mesh and does > not need to be converted. > > Droftarts says that STL is no good because it doesn't "retain the >> > geometry". > > STL is ALL geometry and no topology, unlike a polyhedron. It may be true > it does not retain the geometry either, depending on how the coordinates > are modified. > > Does FreeCAD understand the polyhedron command? > > Carsten Arnholm > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
D
droftarts
Sat, Mar 19, 2016 1:43 AM

Yes, that is what I meant, that CSG appears to be the only way to export a
model from openSCAD with smooth curves, and with the parts still
individually selectable. When you import a CSG into FreeCAD, you should get
smooth geometry, and the ability to select individual bodies of the
assembly. This should continue into the STEP file, and allow the individual
parts to be assigned material appearance, so making the render appear more
lifelike. You could export each individual part, in position, as an STL, and
bring this in, but I was experimenting to see if I can export for rendering
in one smooth operation, while maintaining quality (ie without
triangulation).

Thanks for the help, I'll incorporate it into my model, see how far it gets,
and report back. My only other option was to write a better renderer for
OpenSCAD, which is definitely above my programming level! Or maybe STEP
export...

Ian S

--
View this message in context: http://forum.openscad.org/Script-to-replicate-hull-and-minkoswki-for-CSG-export-import-into-FreeCAD-tp16537p16575.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Yes, that is what I meant, that CSG appears to be the only way to export a model from openSCAD with smooth curves, and with the parts still individually selectable. When you import a CSG into FreeCAD, you should get smooth geometry, and the ability to select individual bodies of the assembly. This should continue into the STEP file, and allow the individual parts to be assigned material appearance, so making the render appear more lifelike. You could export each individual part, in position, as an STL, and bring this in, but I was experimenting to see if I can export for rendering in one smooth operation, while maintaining quality (ie without triangulation). Thanks for the help, I'll incorporate it into my model, see how far it gets, and report back. My only other option was to write a better renderer for OpenSCAD, which is definitely above my programming level! Or maybe STEP export... Ian S -- View this message in context: http://forum.openscad.org/Script-to-replicate-hull-and-minkoswki-for-CSG-export-import-into-FreeCAD-tp16537p16575.html Sent from the OpenSCAD mailing list archive at Nabble.com.
N
Neon22
Sat, Mar 19, 2016 2:04 AM

STEP format import/export is available via:

Its a database kind of format.
In case anyone's interested....

--
View this message in context: http://forum.openscad.org/Script-to-replicate-hull-and-minkoswki-for-CSG-export-import-into-FreeCAD-tp16537p16576.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

STEP format import/export is available via: - PythonOCC (github) - http://www.pythonocc.org/features_overview/data-exchange/ - Step people themselves: (github) - http://stepcode.org/ Its a database kind of format. In case anyone's interested.... -- View this message in context: http://forum.openscad.org/Script-to-replicate-hull-and-minkoswki-for-CSG-export-import-into-FreeCAD-tp16537p16576.html Sent from the OpenSCAD mailing list archive at Nabble.com.
D
droftarts
Mon, Mar 21, 2016 9:01 AM

Hi nophead

Thanks for this, I never knew how to loop an array before! I wrote a little
example for myself, which helped me understand:

points = [0,1,2,3,4];
length = len (points);
for (i=[0:length*2-1])
echo (points[(i) % length],points[(i+1) % length]);

This runs around the array twice (the '*2' part in the 'for' loop), and
produces:

ECHO: 0, 1
ECHO: 1, 2
ECHO: 2, 3
ECHO: 3, 4
ECHO: 4, 0
ECHO: 0, 1
ECHO: 1, 2
ECHO: 2, 3
ECHO: 3, 4
ECHO: 4, 0

I'm sure using MOD is a fairly standard programming technique, but then I'm
not much of a programmer!

Ian S

nophead wrote

It calculates the remainder after dividing by the length. That causes the
wrap round to zero to close the loop when i+1 equals the length.

--
View this message in context: http://forum.openscad.org/Script-to-replicate-hull-and-minkoswki-for-CSG-export-import-into-FreeCAD-tp16537p16623.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hi nophead Thanks for this, I never knew how to loop an array before! I wrote a little example for myself, which helped me understand: points = [0,1,2,3,4]; length = len (points); for (i=[0:length*2-1]) echo (points[(i) % length],points[(i+1) % length]); This runs around the array twice (the '*2' part in the 'for' loop), and produces: ECHO: 0, 1 ECHO: 1, 2 ECHO: 2, 3 ECHO: 3, 4 ECHO: 4, 0 ECHO: 0, 1 ECHO: 1, 2 ECHO: 2, 3 ECHO: 3, 4 ECHO: 4, 0 I'm sure using MOD is a fairly standard programming technique, but then I'm not much of a programmer! Ian S nophead wrote > It calculates the remainder after dividing by the length. That causes the > wrap round to zero to close the loop when i+1 equals the length. -- View this message in context: http://forum.openscad.org/Script-to-replicate-hull-and-minkoswki-for-CSG-export-import-into-FreeCAD-tp16537p16623.html Sent from the OpenSCAD mailing list archive at Nabble.com.