[Paraview] vtkPVTrivialProducer issues

wastrel at gmail.com wastrel at gmail.com
Wed Apr 28 21:14:05 EDT 2010


I have read that, but wonder if there is any more detailed and systematic
document available.

Thanks.

Ken



On Wed, Apr 28, 2010 at 5:58 PM, pat marion <pat.marion at kitware.com> wrote:

> You can read about python scripting in paraview here:
>
>
> http://www.paraview.org/Wiki/ParaView/Python_Scripting
>
> Paraview has the concept of an active source.  Making a source the active
> source in python is like selecting it in the gui.  For all operations, if no
> input is specified, the active source is used.  You can get the active
> source with GetActiveSource().  When you create a new object, like
> TrivialProducer(), it becomes the active source.
>
> When creating a new source (or writer), you can specify the input(s)
> explicity using arguments to the constructor.  Or you can specify a Input
> keyword argument that takes a list.  Such as:
>
> AppendDatasets(source1, source2)
>  or
> AppendDatasets(Input=[source1, source2])
>
> Pat
>
>
> On Wed, Apr 28, 2010 at 6:22 PM, <wastrel at gmail.com> wrote:
>
>> Thanks. I just tired it and it seems to work. But how does the writer
>> figure out the input object?
>>
>> Is there any detailed documentation on pvpython?
>>
>> Thanks,
>>
>> Ken
>>
>>
>>
>>
>> On Sun, Apr 25, 2010 at 6:37 AM, Utkarsh Ayachit <
>> utkarsh.ayachit at kitware.com> wrote:
>>
>>> Here's a modified version of the script, using the updated python
>>> scripting style (since ParaView 3.6)
>>>
>>>
>>> from paraview.simple import *
>>> from paraview.simple import servermanager as sm
>>> from paraview import vtk
>>>
>>> # Set the pvpython path
>>> INPUTFILE="test.vtu"
>>> OUTPUTFILE="tested.vtu"
>>>
>>> # create a reader
>>> reader=XMLUnstructuredGridReader(FileName=INPUTFILE)
>>>
>>> # get the data i.e moves data from the server to the client
>>> data=sm.Fetch(reader)
>>>
>>> tp=TrivialProducer()
>>> obj=tp.GetClientSideObject()
>>> obj.SetOutput(data)
>>>
>>> writer=XMLUnstructuredGridWriter(DataMode=2,FileName=OUTPUTFILE)
>>> writer.UpdatePipeline()
>>>
>>>
>>> Utkarsh
>>>
>>> On Sat, Apr 24, 2010 at 3:24 PM,  <wastrel at gmail.com> wrote:
>>> > I simplified the code and tried it on Paraview3.8.0. It reads in a vtu
>>> file,
>>> > fetch the data and then write it back to a new file. But still got
>>> errors as
>>> > follow.
>>> >
>>> > Script:
>>> >
>>> > from paraview.simple import *
>>> > from paraview.simple import servermanager as sm
>>> > from paraview import vtk
>>> >
>>> > # connect internally
>>> > connection=sm.Connect()
>>> >
>>> > # Set the pvpython path
>>> > INPUTFILE="test.vtu"
>>> > OUTPUTFILE="tested.vtu"
>>> >
>>> > # create a reader
>>> > reader=sm.sources.XMLUnstructuredGridReader(FileName=INPUTFILE)
>>> >
>>> > # get the data i.e moves data from the server to the client
>>> > data=sm.Fetch(reader)
>>> >
>>> > tp=sm.sources.TrivialProducer()
>>> > obj=tp.GetClientSideObject()
>>> > obj.SetOutput(data)
>>> >
>>> >
>>> writer=sm.writers.XMLUnstructuredGridWriter(DataMode=2,FileName=OUTPUTFILE,Input=obj)
>>> >
>>> > writer.UpdatePipeline()
>>> >
>>> >
>>> > Errors:
>>> >
>>> > getting appended
>>> > vtkReductionFilter : [ ...........]
>>> > Traceback (most recent call last):
>>> >   File "convert.py", line 88, in <module>
>>> >
>>> >
>>> writer=sm.writers.XMLUnstructuredGridWriter(DataMode=2,FileName=OUTPUTFILE,Input=obj)
>>> >   File
>>> >
>>> "/home/kitware/ParaView-3-8/ParaView-3.8/ParaView3Bin/Utilities/VTKPythonWrapping/paraview/servermanager.py",
>>> > line 186, in __init__
>>> >   File
>>> >
>>> "/home/kitware/ParaView-3-8/ParaView-3.8/ParaView3Bin/Utilities/VTKPythonWrapping/paraview/servermanager.py",
>>> > line 204, in __setattr__
>>> >   File
>>> >
>>> "/home/kitware/ParaView-3-8/ParaView-3.8/ParaView3Bin/Utilities/VTKPythonWrapping/paraview/servermanager.py",
>>> > line 2361, in setProperty
>>> >   File
>>> >
>>> "/home/kitware/ParaView-3-8/ParaView-3.8/ParaView3Bin/Utilities/VTKPythonWrapping/paraview/servermanager.py",
>>> > line 253, in SetPropertyWithName
>>> >   File
>>> >
>>> "/home/kitware/ParaView-3-8/ParaView-3.8/ParaView3Bin/Utilities/VTKPythonWrapping/paraview/servermanager.py",
>>> > line 1162, in SetData
>>> > AttributeError: SMProxy
>>> >
>>> >
>>> >
>>> > Any clues?
>>> >
>>> >
>>> > On Sat, Apr 24, 2010 at 9:41 AM, Utkarsh Ayachit
>>> > <utkarsh.ayachit at kitware.com> wrote:
>>> >>
>>> >> Here are my results from 3.7 (consequently 3.8 or git master should
>>> >> work as well).
>>> >>
>>> >> >>> from paraview.simple import *
>>> >> paraview version 3.7.0, Date: 2010-03-27
>>> >> >>> TrivialProducer()
>>> >> <paraview.servermanager.TrivialProducer object at 0x121587e90>
>>> >> >>> servermanager.sources.TrivialProducer()
>>> >> <paraview.servermanager.TrivialProducer object at 0x121587d50>
>>> >>
>>> >> Utkarsh
>>> >>
>>> >> On Fri, Apr 23, 2010 at 5:44 PM, Utkarsh Ayachit
>>> >> <utkarsh.ayachit at kitware.com> wrote:
>>> >> > You no longer need the initial part for loading the XML. You can
>>> >> > directly use:
>>> >> >
>>> >> >  tp = sm.sources.TrivialProducer()
>>> >> >
>>> >> > and that should work.
>>> >> >
>>> >> > Utkarsh
>>> >> >
>>> >> > On Fri, Apr 23, 2010 at 5:09 PM,  <wastrel at gmail.com> wrote:
>>> >> >> I used the the following snippet to generate data on the client
>>> side
>>> >> >> but
>>> >> >> ended up with errors:
>>> >> >>
>>> >> >> Code:
>>> >> >> sm = servermanager
>>> >> >> f = open('trivialproducer.xml', 'r')
>>> >> >> parser = sm.vtkSMXMLParser()
>>> >> >> parser.Parse(f.read())
>>> >> >> parser.ProcessConfiguration(sm.vtkSMObject.GetProxyManager())
>>> >> >> # Update the modules
>>> >> >> sm._updateModules()
>>> >> >>
>>> >> >> tp = sm.sources.TrivialProducer()
>>> >> >> obj = tp.GetClientSideObject()
>>> >> >> obj.SetOutput(pd)
>>> >> >>
>>> >> >> # use tp as any other source proxy
>>> >> >>
>>> >> >>
>>> >> >> trivialproducer.xml:
>>> >> >>
>>> >> >> <ServerManagerConfiguration>
>>> >> >> <ProxyGroup name="sources">
>>> >> >>
>>> >> >> <SourceProxy name="TrivialProducer"
>>> >> >> class="vtkPVTrivialProducer">
>>> >> >> </SourceProxy>
>>> >> >> </ProxyGroup>
>>> >> >>
>>> >> >>
>>> >> >> Errors:
>>> >> >> ERROR: In
>>> >> >>
>>> >> >>
>>> /home/berk/Work/ReleaseBuilds/ParaView3/Servers/Common/vtkProcessModule.cxx,
>>> >> >> line 1001
>>> >> >> vtkProcessModule (0x807b790): Cannot create object of type
>>> >> >> "vtkPVTrivialProducer".
>>> >> >> while processing
>>> >> >> Message 0 = New
>>> >> >>   Argument 0 = string_value {vtkPVTrivialProducer}
>>> >> >>   Argument 1 = id_value {40}
>>> >> >>
>>> >> >>
>>> >> >> ERROR: In
>>> >> >>
>>> >> >>
>>> /home/berk/Work/ReleaseBuilds/ParaView3/Servers/Common/vtkProcessModule.cxx,
>>> >> >> line 1002
>>> >> >> vtkProcessModule (0x807b790): Aborting execution for debugging
>>> >> >> purposes.
>>> >> >>
>>> >> >> Abort
>>> >> >>
>>> >> >>
>>> >> >> _______________________________________________
>>> >> >> 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
>>> >> >>
>>> >> >>
>>> >> >
>>> >
>>> >
>>>
>>
>>
>> _______________________________________________
>> 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
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20100428/b5369f62/attachment.htm>


More information about the ParaView mailing list