How do I use unknown structures of TagGroups in dm-script in python?
TagGroups are widely used in DigitalMicrograph. But how do I travel through them in python? How do I get all available tag names?
In normal dm-script there are functions like TagGroupGetTagLabel() and TagGroupGetTagType(). One can use a for-loop to check the structure. But there is not a single function in the python wrapper class Py_TagGroup to get information about the labels. Also the examples never deal with unknown TagGroups.
I have a very simple problem: I want to use (show, modify, check, save, ...) the tags from an image. But I don't know the tag names.
img = camera.AcquireImage()
tg = img.GetTagGroup()
But now what? I don't know anything about this TagGroup. TagGroups are not iterable so I cannot use them in for-loops. I can get their length but I can only access data at indices. And that only if I know the datatype. Neither can I get the type nor the label.
So again: How can I travel through TagGroups in python in dm-script? How can I get the structure?
The Python module
execdmscripton GitHUB with (version ≥ 1.1.4) supports convertingPy_TagGroups to pythondicts orlists. So the following code works for me:1
execdmscript.convert_from_taggroup()uses the persistent tags anddm-scriptcode for this. It involves saving thePy_TagGroupto the global tags. Sincedm-scriptcode can travel throughTagGroups, the strucutre of theTagGroupis analyzed by executingdm-scriptcode from the python interpreter. The results are saved to the persistent tags again. Then the structure is read from the global tags with python and adictorlistcan be created from it.