[Paraview-developers] stl writer(s)
Laurent Paul
laurent.paul at uclouvain.be
Thu Feb 7 03:38:18 EST 2013
Dear developper,
I write some scripts that exports data into a STL file.
The issue comes when I try to use a STLWriter. I've tried several ways:
- compute data in the paraview field, I mean using filters provided by
the python tool from paraview
- compute data and export them using VTK filters
- compute data using VTK and export it using a trivialProducer + writer.
The STL file is just empty, only :
"solid ascii
endsolid"
when writing down in ASCII mode.
Is there a bug somewhere? Are the data incorrect to be written using STL
writer?
Thanks for your help.
Laurent.
________________
#Here is the code:
from paraview.simple import *
from paraview.vtk import *
from paraview.util import *
from math import *
import paraview.vtk.io as vtk_io
MathObject = vtk.vtkMath()
exportCylinderFilename = ""D:/Work/Axis.stl"
#1st method using paraview filters
LineSourcePV = Line(guiName = "Axis")
LineSourcePV.Point1 = LineUp[0],LineUp[1], LineUp[2] #points are OK
LineSourcePV.Point2 = LineDown[0],LineDown[1], LineDown[2]
tube = Tube()
tube.Radius = 2
tube.NumberofSides = 32
tube.UpdatePipeline()
tube.Capping = 1
SetActiveSource(tube)
Show(tube)
#In the GUI, I get a cylinder with 34 cells and 288 points. So data are ok.
stlWriter = PSTLWriter()
stlWriter.FileName = exportCylinderFilename
stlWriter.Input = tube
stlWriter.FileType = 1
stlWriter.UpdatePipeline()
#I get one empty file
writer = servermanager.writers.PSTLWriter( Input=tube,
FileName=exportCylinderFilename , FileType=1)
writer.UpdatePipeline()
#I get the same empty file
#2nd method using VTK filters
Linesource = vtk.vtkLineSource()
Linesource.SetPoint1(LineUpTibia)
Linesource.SetPoint2(LineDownTibia)
Linesource.SetResolution(1)
Linesource.Update()
tube2 = vtk.vtkTubeFilter()
tube2.SetInput(Linesource.GetOutput())
tube2.SetRadius(1)
tube2.SetNumberOfSides(32)
tube2.CappingOn()
tube2.Update()
print "nb cells: ", tube2.GetOutput().GetNumberOfCells()
stlWriter2 = vtk_io.vtkSTLWriter()
stlWriter2.SetFileName("D:/Work/stl2.stl")
stlWriter2.SetInputConnection(tube2.GetOutputPort())
stlWriter2.SetFileTypeToASCII()
stlWriter2.Update()
#I get the same empty file
--
Please consider environmental impact before printing documents
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20130207/c91243c3/attachment.htm>
More information about the Paraview-developers
mailing list