[Paraview] Using PythonProgrammableFilter as a reader

Jan Brezina jan.brezina at tul.cz
Sun Oct 12 14:00:33 EDT 2014


Hi,

I'm trying to use vtkPythonProgrammableFilter to implement a reader in
Python. The problem is in passing the filename (form the filebrowser
dialog) to the python script (the RequestData script). I need a method
in vtkPythonProgrammableFilter with one char * argument that can behave
like SetFileName(char *) to set this method to command property in the
XML file. Unfortunately, this scheme is not compatible with SetParameter
methods of vtkPythonProgrammableFilter. Finally, I find a hack using the
method SetProgressText (from vtkAlgorithm) instead of SetFileName. So my
XML looks like:

<ServerManagerConfiguration>
  <ProxyGroup name="sources">
    <SourceProxy name="EGrid Reader"
		 class="vtkPythonProgrammableFilter"
		 label="EGrid Reader">
      <StringVectorProperty
            name="FileName"
            animateable="0"
            command="SetProgressText"
            number_of_elements="1"
            panel_visibility="advanced">
        <FileListDomain name="files"/>
      </StringVectorProperty>
      <IntVectorProperty command="SetOutputDataSetType"
                         default_values="4"
                         name="OutputDataSetType"
                         number_of_elements="1"
                         panel_visibility="never">
      </IntVectorProperty>
      <StringVectorProperty
        name="Script"
        command="SetScript"
        number_of_elements="1"
        default_values="print self.GetProgressText()"
        panel_visibility="advanced">
        <Hints>
         <Widget type="multi_line"/>
       </Hints>
      </StringVectorProperty>
      <Hints>
        <ReaderFactory extensions="egrid"
                       file_description="Eclipse mesh File Format" />
     </Hints>
    </SourceProxy>
  </ProxyGroup>
</ServerManagerConfiguration>

Is there a beter way how to pass the filename to the script? If not,
could a SetFileName method be implemented in vtkPythonProgrammableFilter
that simply calls

SetParameter("FileName", the_path)

?

Thank you for a help,
Jan

-- 
------------------------
Mgr. Jan Brezina, Ph. D.
Technical University in Liberec, New technologies institute
http://www.nti.tul.cz/cz/WikiUser:Jan.Brezina

-- 
------------------------
Mgr. Jan Brezina, Ph. D.
Technical University in Liberec, New technologies institute
http://www.nti.tul.cz/cz/WikiUser:Jan.Brezina


More information about the ParaView mailing list