<div dir="ltr">A key can only be constructed once per session (i.e. once per program execution).<div>So it seems that you should be able to make a module that defines your keys,</div><div>or use vtkInformationKeyLookup.Find(name, location) to verify that the key</div><div>doesn't already exist before you create it.</div><div><br><div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 3, 2017 at 6:06 PM, scotsman60 <span dir="ltr"><<a href="mailto:doug@beachmailing.com" target="_blank">doug@beachmailing.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">David,<br>
<br>
Thanks for this suggestion - unfortunately it doesn't seem to work.<br>
<br>
I have never found recreating a key with exactly the same parameters to work<br>
and (I think there's a post on here about this). I always introspect the<br>
vtkInformation object, get the keys and then use the keys recovered form the<br>
vtkInformation to get the values,<br>
<br>
info = self.mesh.GetCellData().<wbr>GetArray(i).GetInformation()<br>
<br>
info_iterator = vtk.vtkInformationIterator()<br>
info_iterator.SetInformation(<wbr>info)<br>
info_iterator.InitTraversal ()<br>
<br>
key = info_iterator.GetCurrentKey()<br>
<br>
quantity= info.Get(key)<br>
<br>
<br>
<br>
David Gobbi wrote<br>
<span class="gmail-">> Before you load the data, re-make the keys so that VTK will register them<br>
> as valid keys:<br>
><br>
> quantity_key = keys.MakeKey(vtk.<wbr>vtkInformationStringKey, "Quantity", "1")<br>
> increment_key = keys.MakeKey(vtk.<wbr>vtkInformationIntegerKey, "Increment",<br>
> "2")<br>
> # the keys are defined now, so you should be able to load the data<br>
><br>
><br>
</span>> On Sun, Dec 3, 2017 at 4:00 PM, scotsman60 <<br>
<br>
> doug@<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
> > wrote:<br>
><br>
>> Hello!!<br>
>><br>
>> I'm using the Python API to vtk and I'm unable to import custom<br>
>> vtkInformation from a vtkUnstructuredGrid.<br>
>><br>
>> First of all I'm associating custom information to CellData in a<br>
>> vtkUnstructuredGrid using the following code - where self.mesh is the<br>
>> vtkUnstructuredGrid<br>
>><br>
>> #Add the information keys<br>
>> info = densityScalars.GetInformation(<wbr>)<br>
>><br>
>> # First the Quantity type<br>
>> quantity_key = keys.MakeKey(vtk.<wbr>vtkInformationStringKey, "Quantity",<br>
>> "1")<br>
>> quantity_key.Set(info, "Topology Density")<br>
>><br>
>> #Now the Increment number<br>
>> increment_key = keys.MakeKey(vtk.<wbr>vtkInformationIntegerKey,<br>
>> "Increment",<br>
>> "2")<br>
>> increment_key.Set(info, increment)<br>
>><br>
>><br>
>> #Add the array to the mesh<br>
>> self.mesh.GetCellData().<wbr>AddArray(densityScalars)<br>
>><br>
>><br>
>> Later I save the vtkUnstructuredGrid using vtkUnstructuredGridWriter,<br>
>> then<br>
>> Import it into a new Python session (Basically my program uses the<br>
>> vtkUnstructuredGrid as its persistence mechanism.........)<br>
>><br>
>> When I read the grid using vtkUnstructuredGridReader I get a whole bunch<br>
>> of<br>
>> warnings from vtk<br>
>><br>
>> Warning: In ..\IO\Legacy\vtkDataReader.<wbr>cxx, line 2668<br>
>> vtkUnstructuredGridReader (00000000044D7520): Could not locate key<br>
>> 2::Increment. Is the module<br>
>> in which it is defined linked?<br>
>><br>
>> Warning: In ..\IO\Legacy\vtkDataReader.<wbr>cxx, line 2907<br>
>> vtkUnstructuredGridReader (00000000044D7520): Ignoring line in<br>
>> INFORMATION block: DATA 1<br>
>><br>
>> Warning: In ..\IO\Legacy\vtkDataReader.<wbr>cxx, line 2668<br>
>> vtkUnstructuredGridReader (00000000044D7520): Could not locate key<br>
>> 2::Increment. Is the module<br>
>> in which it is defined linked?<br>
>><br>
>> Warning: In ..\IO\Legacy\vtkDataReader.<wbr>cxx, line 2907<br>
>> vtkUnstructuredGridReader (00000000044D7520): Ignoring line in<br>
>> INFORMATION block: DATA 2<br>
>><br>
>> Warning: In ..\IO\Legacy\vtkDataReader.<wbr>cxx, line 2668<br>
>> vtkUnstructuredGridReader (00000000044D7520): Could not locate key<br>
>> 1::Quantity. Is the module in<br>
>> which it is defined linked?<br>
>><br>
>> Warning: In ..\IO\Legacy\vtkDataReader.<wbr>cxx, line 2907<br>
>> vtkUnstructuredGridReader (00000000044D7520): Ignoring line in<br>
>> INFORMATION block: DATA<br>
>> Topology%20Density<br>
>><br>
>><br>
>> Any ideas on what's going on here?<br>
>><br>
>> Thanks in advance,<br>
>><br>
>> Doug<br>
>><br></div></div></blockquote></div></div></div></div></div>