[Paraview] exporting VRML files with python script

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Thu Jun 24 09:23:47 EDT 2010


You have to write each file individually. However, you can do it just
a few lines without copy-pasting as follows:

exporters = servermanager.createModule("exporters")
vrml = exporters.VRMLExporter()

for d in range(3):
  vrml.FileName = "/tmp/%d.vrml" % d
  vrml.View = GetActiveView()
  vrml.Write()

Utkarsh


2010/6/24 Yann-Hervé Hellouvry <yannherve.hellouvry at gmail.com>:
> thanks for the reply, I've just one more question : how can i do to export
> serial files easily?
>
> guess I import 3 vtk files :  1.vtk 2.vtk 3.vtk . Am I oblige to do :
>
> exporters = servermanager.createModule("exporters")
> vrml1 = exporters.VRMLExporter(FileName="/tmp/1.vrml")
> vrml1.View = GetActiveView()
> vrml1.Write()
> vrml2 = exporters.VRMLExporter(FileName="/tmp/2.vrml")
> vrml2.View = GetActiveView()
> vrml2.Write()
> vrml3 = exporters.VRMLExporter(FileName="/tmp/3.vrml")
> vrml3.View = GetActiveView()
> vrml3.Write()
>
> Or is there a way to make series like :
>
> exporters = servermanager.createModule("exporters")
> vrml = exporters.VRMLExporter(FileName="/tmp/*.vrml")
> vrml.View = GetActiveView()
> vrml.Write()
>
> Regards,
>
> Yann
>
> 2010/6/17 Utkarsh Ayachit <utkarsh.ayachit at kitware.com>
>>
>> Here's a sample script:
>>
>> exporters = servermanager.createModule("exporters")
>> vrml = exporters.VRMLExporter(FileName="/tmp/foo.vrml")
>> vrml.View = GetActiveView()
>> vrml.Write()
>>
>>
>> Utkarsh
>>
>>
>>
>> 2010/6/17 Yann-Hervé Hellouvry <yannherve.hellouvry at gmail.com>:
>> > Hi everyone,
>> >
>> > I am a new user of Paraview and I'm quite interested in using Python
>> > script
>> > for Paraview
>> >
>> > My goal is to import VTK series files, apply a contour to all of them
>> > and
>> > finally export the contours in VRML format. This is my first script :
>> >
>> > #--------------------------------------------------
>> > from paraview.simple import *
>> >
>> > reader = servermanager.sources.LegacyVTKReader()
>> > reader.FileNames = [ "/.../1.vtk" , "/.../2.vtk" ]
>> > reader.UpdatePipeline()
>> >
>> > SetActiveSource(reader)
>> >
>> > aContour = Contour(Input = reader)
>> > aContour.ContourBy = "alpha1"
>> > aContour.Isosurfaces = [0.5]
>> >
>> > Show(aContour)
>> > Render()
>> >
>> > #from this point it doesn't work
>> > exporters = servermanager.createModule("exporters")
>> > VRMLExporter = servermanager.exporters.VRMLExporter( ? , FileName=
>> > "/.../output_1.vrml ")
>> > #--------------------------------------------------
>> >
>> > Can anyone help me, I'm totally lost with the export part ? (but if you
>> > see
>> > others problems please tell me!)
>> >
>> > Regards,
>> >
>> > Yann
>> >
>> > _______________________________________________
>> > Powered by www.kitware.com
>> >
>> > Visit other Kitware open-source projects at
>> > http://www.kitware.com/opensource/opensource.html
>> >
>> > Please keep messages on-topic and check the ParaView Wiki at:
>> > http://paraview.org/Wiki/ParaView
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > http://www.paraview.org/mailman/listinfo/paraview
>> >
>> >
>
>


More information about the ParaView mailing list