# Set size of StringVectorProperty list at loading of state file

**URL:** https://discourse.paraview.org/t/set-size-of-stringvectorproperty-list-at-loading-of-state-file/845
**Category:** Development
**Created:** [November 5, 2018, 3:04pm UTC](https://discourse.paraview.org/t/set-size-of-stringvectorproperty-list-at-loading-of-state-file/845 "2018-11-05T15:04:36Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![HollowSun0](https://discourse.paraview.org/user_avatar/discourse.paraview.org/hollowsun0/32/431_2.png) [@HollowSun0](https://discourse.paraview.org/u/HollowSun0)
#### Post date: [November 5, 2018, 3:04pm UTC](https://discourse.paraview.org/t/set-size-of-stringvectorproperty-list-at-loading-of-state-file/845/1 "2018-11-05T15:04:36Z")

</div>

Hello,

I’ve been working on a ParaView plugin very recently. In the XML definition, I used the following widget:

```
  <StringVectorProperty name="ParameterNames"
                        command="SetParameterNames"
                        clean_command="ResetParameterNamesToDefault"
                        information_property="ParameterNameInfo"
                        number_of_elements_per_command="1"
                        repeat_command="1"
                        use_index="1"
                        panel_widget="list" >
  </StringVectorProperty>
  
  <StringVectorProperty command="GetDefaultParameterNames"
                        information_only="1"
                        name="ParameterNameInfo"
                        si_class="vtkSIDataArrayProperty" >
  </StringVectorProperty>

```

When I instantiate the filter, its RequestInformation triggers. The RequestInformation extracts a field array containing a string that tells what size the StringVectorProperty must be and what it must contain. The property is then instantly populated.

Now, if I save that state file, disconnect and load the state, when RequestInformation triggers, the field array that must be read is absent, not something I would expect.

The only workaround I’ve found is to store the NumberOfParameters inside an XML property set with panel\_visibility=“never” and populate the property inside RequestData. Any hints?

Thank you very much,  
Patrick Laurin

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [November 5, 2018, 3:09pm UTC](https://discourse.paraview.org/t/set-size-of-stringvectorproperty-list-at-loading-of-state-file/845/2 "2018-11-05T15:09:57Z")

</div>

> [@HollowSun0](#):
>
> The RequestInformation extracts a field array containing a string that tells what size the StringVectorProperty must be and what it must contain.

Are you saying that in `RequestInformation`, you are accessing your input dataset and doing stuff with it? If that’s the case, that’s indeed incorrect. VTK filters cannot expect that their input datasets will be valid when `RequestInformation` is called. When you’re doing this one filter at a time in the ParaView UI, each new filter gets created and updated and hence you end up with an acceptable dataset in the input in `RequestInformation`. That won’t be the case generally.

I’ve recommend the [VTK pipeline primer](https://blog.kitware.com/a-vtk-pipeline-primer-part-1/) series of blogs for more details on the VTK pipeline.

---

<div class="post-metadata">

### Author: ![HollowSun0](https://discourse.paraview.org/user_avatar/discourse.paraview.org/hollowsun0/32/431_2.png) [@HollowSun0](https://discourse.paraview.org/u/HollowSun0)
#### Post date: [November 5, 2018, 3:20pm UTC](https://discourse.paraview.org/t/set-size-of-stringvectorproperty-list-at-loading-of-state-file/845/3 "2018-11-05T15:20:05Z")

</div>

Thank you for your prompt response, Utkarsh. I wasn’t too sure about that. I will read that documentation and adapt.

edit: Propagating new metadata keys downstream seems to be the solution.

Thanks,  
Patrick Laurin

---

<div class="post-metadata">

### Author: ![HollowSun0](https://discourse.paraview.org/user_avatar/discourse.paraview.org/hollowsun0/32/431_2.png) [@HollowSun0](https://discourse.paraview.org/u/HollowSun0)
#### Post date: [November 5, 2018, 9:28pm UTC](https://discourse.paraview.org/t/set-size-of-stringvectorproperty-list-at-loading-of-state-file/845/4 "2018-11-05T21:28:23Z")

</div>

In my source header (ReaderClass.h), I have defined the following key:  
`static vtkInformationIntegerKey* NUMBER_OF_IND_COORDINATES();`

Then, I set that key into my output vtkInformation like this:

```
vtkInformation *outInfo0 = outputVector->GetInformationObject(0);
outInfo0->Set(ReaderClass::NUMBER_OF_IND_COORDINATES(), 9);

```

When I connect a filter onto that output, I can’t retrieve the key that has been stored:

```
vtkInformation *inInfo0 = inputVector[0]->GetInformationObject(0);
std::cout << "Int value: " << inInfo0->Get(ReaderClass::NUMBER_OF_IND_COORDINATES()) << std::endl;

```

Printing inInfo0 gives me the usual keys but not mine.

Am I missing something?

EDIT: Ok, I managed to do it by adding the following line: `request->Append(vtkExecutive::KEYS_TO_COPY(), ReaderClass::NUMBER_OF_IND_COORDINATES());`

Thanks,  
Patrick Laurin

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [November 6, 2018, 12:48pm UTC](https://discourse.paraview.org/t/set-size-of-stringvectorproperty-list-at-loading-of-state-file/845/5 "2018-11-06T12:48:14Z")

</div>

Cool! `KEYS_TO_COPY()` is indeed the way to add custom key. Glad it’s working.
