Fellas,  can someone please point me to examples (current as of v5.0.1) of
how a PythonProgrammableFilter accesses the values of properties entered
via a DropDownList on the filter's Properties panel....

I have written a Python programmable filter which extracts user-specified
field arrays from user-specified blocks of multiple (MultiBlock) input
datasets.  I use this to perfrom statistical analysis of values from many
different simulatyions.
The filter works fine when the field array names and block numbers are
hardcoded in the script.
.
Then I used Pat Marion's python_filter_generator.py to wrap the filter in
XML and allow these values to be entered via TextBoxes in the Properties
panel.   That also works fine.  The property TextBoxes are accessible to
the Python script and I can retrieve the user-entered values.

Then I attempted to change the field array input widget from a textbox to a
DropDownList of cell arrays with checkboxes for selection, following the
example in http://www.paraview.org/Wiki/ParaView/Plugin_HowTo#Drop_down_list.
The DropDownList does appear correctly, populated correctly, along with
checkboxes for selecting items from the list.  However when I hit Apply I
get the following error:


> ERROR: In
>> C:\bbd\5105004d\build\paraview\src\paraview\ParaViewCore\ServerImplementation\Core\vtkPVSessionCore.cxx,
>> line 390
>
> vtkPVSessionCore (00000000036E8610): Object type:
>> vtkPythonProgrammableFilter, could not find requested method:
>> "SetCellArrayStatus"
>
> or the method was called with incorrect arguments.
>
>
>> while processing
>
> Message 0 = Invoke
>
>   Argument 0 = vtk_object_pointer {vtkPythonProgrammableFilter
>> (000000000D1BCCD0)}
>
>   Argument 1 = string_value {SetCellArrayStatus}
>
>   Argument 2 = string_value {cellInputs}
>
>   Argument 3 = int32_value {0}
>
>
>> ERROR: In
>> C:\bbd\5105004d\build\paraview\src\paraview\ParaViewCore\ServerImplementation\Core\vtkPVSessionCore.cxx,
>> line 391
>
> vtkPVSessionCore (00000000036E8610): Aborting execution for debugging
>> purposes.
>
>
>> ERROR: In
>> C:\bbd\5105004d\build\paraview\src\paraview\ParaViewCore\ServerImplementation\Core\vtkSIProxy.cxx,
>> line 134
>
> vtkSISourceProxy (000000000A29BFE0): Error pushing property state:
>> CellArrayStatus
>
>
I looked at the examples in
ParaView/ParaViewCore/ServerManager/SMApplication/Resources/readers.xml
as suggested, but nowhere do I see examples of how a Python script accesses
the user's selections (only examples of the XML code is shown, not the
Python scripts).  I also perused the site-packages subdirectory of my
installation, but those are all compiled Python and of no help.

I'm sure if I just see some Python code examples I can get this working.  I
have attached my filter if that helps...
many thanks for your help.

Dean Neumann
CEO, Malaspina Lans Inc
<ServerManagerConfiguration>
  <ProxyGroup name="filters">
    <SourceProxy name="SliceAcrossDatasets" class="vtkPythonProgrammableFilter" label="Slice Across Datasets">

      <Documentation
        long_help="extract the specified arrays from the specified blocks of multiple input datasets.  Output as VTKTable (RowData)"
        short_help="extract the specified arrays from the specified blocks of multiple input datasets.  Output as VTKTable (RowData)">
      </Documentation>


      <InputProperty
        name="Input"
                    clean_command="RemoveAllInputs"
            command="AddInputConnection"
            multiple_input="1">
          <ProxyGroupDomain name="groups">
            <Group name="sources"/>
            <Group name="filters"/>
          </ProxyGroupDomain>

          <DataTypeDomain name="input_type">
            <DataType value="vtkMultiBlockDataSet"/>
          </DataTypeDomain>
      </InputProperty>


      <StringVectorProperty
        name="sBlocks"
        label="Blocks to Extract"
        initial_string="sBlocks"
        command="SetParameter"
        animateable="1"
        default_values="1, 2"
        number_of_elements="1">
        <Documentation></Documentation>
      </StringVectorProperty>

      <StringVectorProperty command="SetCellArrayStatus" 
                            element_types="2 0" 
                            information_property="CellArrayInfo" 
                            label="Fields to Extract" 
                            name="CellArrayStatus" 
                            number_of_elements="0" 
                            number_of_elements_per_command="2" 
                            repeat_command="1"> 
        <ArrayListDomain name="array_list"
                         attribute_type="Scalars"
                         input_domain_name="inputs_array">
          <RequiredProperties>
            <Property name="Input"
                      function="Input" />
          </RequiredProperties>
        </ArrayListDomain>
      </StringVectorProperty>

      <StringVectorProperty
        name="sFields"
        label="Fields to Extract"
        initial_string="sFields"
        command="SetParameter"
        animateable="1"
        default_values="cellInputs, readGate, writeGate"
        number_of_elements="1">
        <Documentation></Documentation>
      </StringVectorProperty>




      <!-- Output data type: "vtkTable" -->
      <IntVectorProperty command="SetOutputDataSetType"
                         default_values="19"
                         name="OutputDataSetType"
                         number_of_elements="1"
                         panel_visibility="never">
        <Documentation>The value of this property determines the dataset type
        for the output of the programmable filter.</Documentation>
      </IntVectorProperty>


      <StringVectorProperty
        name="Script"
        command="SetScript"
        number_of_elements="1"
        default_values="&#xA;import vtk&#xA;import numpy&#xA;import vtk.numpy_interface.dataset_adapter as dsa&#xA;&#xA;# parse properties&#xA;s =sFields.replace(',', ' ')&#xA;FieldsToExtract = s.split()&#xA;s = sBlocks.replace(',', ' ')&#xA;BlocksToExtract = map(int, s.split())&#xA;#print CellArrayStatus&#xA;num_connections = len(inputs)&#xA;# wrap input &amp;output data objects using vtk.numpy_interface.dataset_adapter&#xA;for i in range(self.GetNumberOfInputConnections(0)):&#xA;    inputs.append(dsa.WrapDataObject(self.GetInputDataObject(0, i)))&#xA;output = dsa.WrapDataObject(self.GetOutputDataObject(0))&#xA;&#xA;# iterate &amp;extract fields from all input datasets&#xA;for i in range(0, num_connections):&#xA;    for b in BlocksToExtract :&#xA;        for f in FieldsToExtract :&#xA;            if inputs[i].IsA(&quot;vtkCompositeDataSet&quot;): &#xA;                # each block is a vtkMultiBlockDataSet with 1 vtkUnstructuredGrid child&#xA;                block=inputs[i].GetBlock(b).GetBlock(0) &#xA;                #print &quot;------ connection %d block %d array %s ------&quot;% (i,b,f)&#xA;                #print block&#xA;                #print &quot;output.RowData.append(block.GetCellData().GetArray(f), %s.%d.%d&quot;% (f,i,b)&#xA;                output.RowData.append(block.GetCellData().GetArray(f), &quot;%s.%d.%d&quot;% (f,i,b))&#xA;            else:&#xA;                output.RowData.append(inputs[i].GetCellData().GetArray(f),&quot;%s.%d.%d&quot;% (f,i,b))&#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>
 </ProxyGroup>
</ServerManagerConfiguration>
_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

Reply via email to