Add Custom Fields to vtkObjects (Display Names)

Is there a good way to add an id / name / displayName field to vtkObjects? For instance I’d like to know the name of the vtkLookupTable I’m using or the vtkActor I’m manipulating. I’ve tried a few different things, but haven’t found a solution. I guess one way would be to extend the objects, but I’m not sure how that would work with the rest of the library?

The background on this is that I’d like to derive my app state from the vtk objects I’m using in the scene without having to keep up a lot of parallel state. Not sure I’m thinking about things the right way…

Thanks in advance for any help you can provide!

You can use the .set({ name: xxx, id: yyy, displayName: zzz}, true) assuming none of your key would conflict with the vtkObject properties. And get them using .get('name', 'id', 'displayName') => { name: xxx, id: yyy, displayName: zzz}

1 Like

@Sebastien_Jourdain so this isn’t working for me, maybe a bug. Please see this screenshot of me trying to set a parameter name while stepping through the program.

It looks like the property is persisted, but the value is undefined? Please let me know if it’d be helpful for me to open an issue on Github.

@Sebastien_Jourdain not sure if this was fixed in one of the recent releases or I was just using it improperly before, but it’s now working for me. Thanks very much!

1 Like

Thanks for reporting back. I guess I missed your previous message on Feb 10.

1 Like