[Paraview] python programmable filter via xml with multiple input

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Mon Sep 29 08:48:43 EDT 2014


In your example, your XML is setup to provide the inputs on multiple
"ports", while you're code is expecting multiple "connections" on same
port. Use the following script, instead.

    print self.GetInputDataObject(0, 0).GetNumberOfPoints()
    print self.GetInputDataObject(1, 0).GetNumberOfPoints()

Utkarsh

On Sat, Sep 27, 2014 at 8:10 AM, Fraser Callaghan
<fraser.callaghan at sydney.edu.au> wrote:
> Hi,
>
> I am able to run a python programmable filter accessing multiple inputs selected from the pipe line e.g:
> #
> numInputs = self.GetNumberOfInputConnections(0)
> for i in range(numInputs):
>          print self.GetInputDataObject(0,i).GetNumberOfPoints()
> ##
>
> I am able to use the xml format to define multiple inputs in a cleaner way, but can not access the input data (example below).
> Changing "command" value does not help.
> How should I be accessing the inputs available from the xml setup?
>
> Thanks for the help,
> Fraser
>
> xml file:
>
> <ServerManagerConfiguration>
>   <ProxyGroup name="filters">
>     <!-- ================================================================== -->
>     <SourceProxy name="MyFilter" class="vtkPythonProgrammableFilter" label="MyFilter">
>       <Documentation
>          long_help="long help."
>          short_help="short help.">
>       </Documentation>
>
>       <InputProperty
>          name="Input0"
>                port_index="0"
>          command="SetInputConnection">
>         <ProxyGroupDomain name="groups">
>           <Group name="sources"/>
>           <Group name="filters"/>
>         </ProxyGroupDomain>
>         <DataTypeDomain name="input_type">
>           <DataType value="vtkPolyData"/>
>         </DataTypeDomain>
>         <Documentation>
>           Input data 0.
>         </Documentation>
>       </InputProperty>
>
>       <InputProperty
>          name="Input1"
>                port_index="1"
>          command="SetInputConnection">
>         <ProxyGroupDomain name="groups">
>           <Group name="sources"/>
>           <Group name="filters"/>
>         </ProxyGroupDomain>
>         <DataTypeDomain name="input_type">
>           <DataType value="vtkPolyData"/>
>         </DataTypeDomain>
>         <Documentation>
>           Input data 1
>         </Documentation>
>       </InputProperty>
>
>       <!-- Output data type: "vtkPolyData" -->
>       <StringVectorProperty
>         name="Script"
>         command="SetScript"
>         number_of_elements="1"
>         default_values="print 'Filter Working'&#xA;print self.GetInputDataObject(0,0)&#xA;#prints polydata&#xA;print self.GetInputDataObject(0,1)&#xA;#prints None&#xA;&#xA;"
>         panel_visibility="advanced">
>         <Hints>
>          <Widget type="multi_line"/>
>        </Hints>
>       <Documentation>This property contains the text of a python program that
>       the programmable source runs.</Documentation>
>       </StringVectorProperty>
>
>     </SourceProxy>
>     <!-- End LandmarkTransformFilter -->
>   </ProxyGroup>
>   <!-- End Filters Group -->
> </ServerManagerConfiguration>
>
>
>
> Error on loading:
>
> ERROR: In /home/utkarsh/Dashboards/MyTests/NightlyMaster/ParaViewSuperbuild-Release/paraview/src/paraview/VTK/Common/ExecutionModel/vtkAlgorithm.cxx, line 893
> vtkPythonProgrammableFilter (0x56aff30): Attempt to connect input port index 1 for an algorithm with 1 input ports.
> _______________________________________________
> 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://public.kitware.com/mailman/listinfo/paraview


More information about the ParaView mailing list