Loading multiple files for a custom Python reader

Sorry I misunderstood.

From a Python-based reader I wrote, here is the method used to ingest files.
Note that I’m using the vtkXdmfReader internally.

    @smproperty.stringvector(name="FileNames",
                                label="File Names",
                                animateable="1",
                                clean_command="RemoveAllFileNames",
                                command="AddFileName",
                                repeat_command="1",
                                number_of_elements="1",
                                panel_visibility="never"
                                )
    @smdomain.filelist()
    @smhint.filechooser(extensions="xmf", file_description="Velodyne Lagrangian XMF files")
    def AddFileName(self, name):

        if name == 'None':
            return

        _ndata = vtkXdmfReader()
        _ndata.CanReadFile(name)
        _ndata.SetFileName(name)
        _ndata.UpdateInformation()

        #-- Timestep stuff
        #- Get timesteps
        executive = self.GetExecutive()
        timesteps = _ndata.GetOutputInformation(0).Get(executive.TIME_STEPS())
        #- Add timestep(s) to internal tracking
        self._timesteps.extend(timesteps)
        self._timesteps = sorted(self._timesteps)

This method will run on all files passed from the file browser dialog.
Later on I use the collected time information like so:

    def RequestInformation(self, request, inInfoVec, outInfoVec):

        executive = self.GetExecutive()
        outInfo = outInfoVec.GetInformationObject(0)
        outInfo.Remove(executive.TIME_STEPS())
        outInfo.Remove(executive.TIME_RANGE())
        timesteps = self._timesteps
        if timesteps != []:
            for t in timesteps:
                outInfo.Append(executive.TIME_STEPS(), t)
            outInfo.Append(executive.TIME_RANGE(), timesteps[0])
            outInfo.Append(executive.TIME_RANGE(), timesteps[-1])

Check out this link:
https://public.kitware.com/pipermail/paraview/2013-September/029316.html

1 Like