POV-Ray : Newsgroups : povray.general : from povray to stl (or any other 3d print format) Server Time
19 May 2024 09:02:17 EDT (-0400)
  from povray to stl (or any other 3d print format) (Message 11 to 14 of 14)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Christian Froeschlin
Subject: Re: from povray to stl (or any other 3d print format)
Date: 26 Dec 2015 22:16:29
Message: <567f580d$1@news.povray.org>
There may be some roundabout way via volumetric data, i.e.
generate an image stack from slices directly from POV-Ray by
intersecting your geometry with thin boxes (you can use the
animation feature to move its y position based on clock).

Naively one might expect that such data is already suitable
for additive printing techniques that build an object layer
by layer, but I have no experience with 3d printers and a web
search indicates most tools are geared to slice from stl and
generate g-code from that.

However there are use cases for volumetric images data e.g.
to print medical data from CT scan etc. One route might be to
load the stack into ImageJ and generate a mesh there (and then
try some other tools to clean up the mesh etc).


Post a reply to this message

From: Le Forgeron
Subject: Re: from povray to stl (or any other 3d print format)
Date: 28 Dec 2015 06:01:44
Message: <56811698$1@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Le 24/12/2015 16:43, claudio56 a écrit :
> Dear all,
> 
> I'm looking for a way to 3d-print my povray image. It is indeed a
> very easy picture, consisting only of spheres and cylinders. As far
> as I could find, there is no direct converter from povray to the
> stl format (or any other format suitable for 3d printing). I hoped
> I could somehow import my cylinders and spheres with autocad, by I
> couldn't. The cylinders and spheres are generated (i.e. the
> coordinates are written) by another program but I can surely
> re-write them in an other format. So, is there a way to convert
> this easy set of objects into a 3d-print suitable format?
> 
> Thank you all in advance

Answering late,

stl is a mesh: made of triangles, hopefully closed, and hopefully a
single part (well, it's a matter of constraint on printing).

I have done a STL export in experimental fork of povray, the hard part
is getting a mesh from the usual object (also in that fork a few mesh
creation mechanism from 3D finite shape(s), a few because not one is
perfect for all)

I did not tried to get the colours in stl (because I did not need it
for printing bronze, and also because there is two divergent colour
coding: VisCAM/SolidView & Materialise Magics)

https://en.wikipedia.org/wiki/STL_(file_format)

https://bitbucket.org/LeForgeron/povray/wiki/Home

https://github.com/LeForgeron/povray/wiki

Best regards.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iJwEAQEIAAYFAlaBFpcACgkQhKAm8mTpkW2LwgQAwPNzg5J+tWyC+cMghcncvZBm
R1JjIccKZEGvW4MceMZPfgPIlSrjB0pqfnuaUFUUxiWbdW/lNiGBKwYhvUjmDTqT
IzJFJ/BRh2fPRfre8UCRl3BJYLNk+03gxgF8voR1vNADo0oI9uF8oXZiyHuo3LQX
DBVLMUOY/FQrRHsM1O4=
=voE1
-----END PGP SIGNATURE-----


Post a reply to this message

From: Bill Pragnell
Subject: Re: from povray to stl (or any other 3d print format)
Date: 29 Dec 2015 10:10:01
Message: <web.5682a213e23216e08da727310@news.povray.org>
"claudio56" <nomail@nomail> wrote:
> I'm looking for a way to 3d-print my povray image. It is indeed a very easy
> picture, consisting only of spheres and cylinders. As far as I could find, there
> is no direct converter from povray to the stl format (or any other format
> suitable for 3d printing). I hoped I could somehow import my cylinders and
> spheres with autocad, by I couldn't. The cylinders and spheres are generated
> (i.e. the coordinates are written) by another program but I can surely re-write
> them in an other format. So, is there a way to convert this easy set of objects
> into a 3d-print suitable format?

I have recently done exactly what you are seeking to do - output some spheres
and cylinders from a POV-Ray source file into an STL file suitable for 3D
printing. I used OpenSCAD, an open-source CSG modelling language, which creates
triangle models from geometric primitives described in a text file in a similar
fashion to POV-Ray.

http://www.openscad.org/

To achieve this, I wrote a couple of POV-Ray macros to create spheres and
cylinders in the OpenSCAD scene format. I've included them below, together with
some sample code to generate a file with a sphere and a cylinder. The macros
also include equivalent POV-Ray code to produce the same objects in a render so
you can check your geometry.

Simply run a render with this code, and the output .scad file should then be
usable in OpenSCAD. If you have a large number of objects it may take OpenSCAD
quite a while to perform the intersections, but I've not seen any errors yet. I
used it to create some polyhedron skeletons, which are very nice printed in
stainless steel :-)

Bill

NB you can change the triangle resolution with the $fs property - see the
OpenSCAD docs for more info.

------------------------------------------------------------------

#macro ScadCylinder(P1, P2, Radius)
 #local Len = vlength(P2-P1);
 #local Axis = vnormalize(P2-P1);
 // ---------- //
 // transform taken from Reorient_Trans() and Axis_Rotate_Trans() in
transforms.inc
 #local VX1 = z;
 #local VX2 = Axis;
 #local Y = vcross(VX1, VX2);
 #if (vlength(Y) > 0)
  #local VY = vnormalize(Y);
  #local VZ1 = vnormalize(vcross(VX1, VY));
  #local VZ2 = vnormalize(vcross(VX2, VY));
  #local Transform = transform {
    matrix <VX1.x, VY.x, VZ1.x,  VX1.y, VY.y, VZ1.y, VX1.z, VY.z, VZ1.z,  0, 0,
0>
    matrix <VX2.x, VX2.y, VX2.z, VY.x, VY.y, VY.z,   VZ2.x, VZ2.y, VZ2.z, 0, 0,
0>
  }
  #write (SCADFile, "translate([",P1.x,", ",P1.y,", ",P1.z,"])\n")
  #write (SCADFile, "multmatrix(m=[\n")
  #write (SCADFile, " [",VX2.x,", ",VY.x,", ",VZ2.x,", 0],\n")
  #write (SCADFile, " [",VX2.y,", ",VY.y,", ",VZ2.y,", 0],\n")
  #write (SCADFile, " [",VX2.z,", ",VY.z,", ",VZ2.z,", 0],\n")
  #write (SCADFile, " [0, 0, 0, 1]\n")
  #write (SCADFile, "])\n")
  #write (SCADFile, "multmatrix(m=[\n")
  #write (SCADFile, " [",VX1.x,", ",VX1.y,", ",VX1.z,", 0],\n")
  #write (SCADFile, " [",VY.x,", ",VY.y,", ",VY.z,", 0],\n")
  #write (SCADFile, " [",VZ1.x,", ",VZ1.y,", ",VZ1.z,", 0],\n")
  #write (SCADFile, " [0, 0, 0, 1]\n")
  #write (SCADFile, "])\n")
 #else
  #if (vlength(VX1-VX2) = 0)
   #local Transform = transform { }
   #write (SCADFile, "translate([",P1.x,", ",P1.y,", ",P1.z,"])\n")
  #else
   #local VZ = VPerp_To_Vector(VX2);
   #local AVX = vaxis_rotate(x, VZ, 180);
   #local AVY = vaxis_rotate(y, VZ, 180);
   #local AVZ = vaxis_rotate(z, VZ, 180);
   #local Transform = transform {
    matrix <AVX.x, AVX.y, AVX.z,  AVY.x, AVY.y, AVY.z,  AVZ.x, AVZ.y, AVZ.z,  0,
0, 0>
   }
   #write (SCADFile, "translate([",P1.x,", ",P1.y,", ",P1.z,"])\n")
   #write (SCADFile, "multmatrix(m=[\n")
   #write (SCADFile, " [",AVX.x,", ",AVY.x,", ",AVZ.x,", 0],\n")
   #write (SCADFile, " [",AVX.y,", ",AVY.y,", ",AVZ.y,", 0],\n")
   #write (SCADFile, " [",AVX.z,", ",AVY.z,", ",AVZ.z,", 0],\n")
   #write (SCADFile, " [0, 0, 0, 1]\n")
   #write (SCADFile, "])\n")
  #end
 #end
 // ---------- //
 cylinder {
  <0, 0, 0>, <0, 0, Len>, Radius
  transform { Transform }
  translate P1
 }
 #write (SCADFile, "cylinder(r=",Radius,",h=",Len,",center=false,$fs=0.02);\n")
#end

#macro ScadSphere(P, Radius)
 sphere {
  <0, 0, 0>, Radius
  translate P
 }
 #write (SCADFile, "translate([",P.x,", ",P.y,", ",P.z,"])
sphere(r=",Radius,",$fs=0.02);\n")
#end


#declare SCADFileName = "scad_file.scad";
#ifdef (SCADFile) #undef SCADFile #end
#fopen SCADFile SCADFileName write
#write (SCADFile, "// OpenSCAD generated by POV-Ray\n\n")

#write (SCADFile, "union () {\n")

union {
 ScadSphere(<0,0,0>, 5)
 ScadCylinder(<-10,0,0>, <10,0,0>, 2)
 pigment { rgb x }
 finish { ambient 0 }
}

#write (SCADFile, "}\n")

------------------------------------------------------------------


Post a reply to this message

From: Kenneth
Subject: Re: from povray to stl (or any other 3d print format)
Date: 30 Dec 2015 08:10:01
Message: <web.5683d67be23216e033c457550@news.povray.org>
"Bill Pragnell" <bil### [at] hotmailcom> wrote:

>
> I have recently done exactly what you are seeking to do - output some spheres
> and cylinders from a POV-Ray source file into an STL file suitable for 3D
> printing...

That's a very clever piece of coding, worth experimenting with! Thanks for
posting it. I haven't tried 3D printing yet (or OpenSCAD), but your code opens
up an interesting POV-to-STL pathway.


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.