Change active markup list (open curve) from another module, and control-click to add new points

Hello, I have several objects whose visualizations in Slicer are represented by the new Open Curve markups. From my module, I would like to be able to select which Open Curve is currently active and click to add new points to that currently active curve by clicking on the slice views (or 3D view). I can currently achieve this in a roundabout way by switching to the Markups module, selecting the curve node in the List selector at the top, then clicking the “Create and Place Open Curve” button along the top. I want to be able achieve this without changing away from my module. I found slicer.modules.markups.logic().SetActiveListID(), but I haven’t been able to make this work. The corresponding GetActiveListID() function returns a MRML id string like ‘vtkMRMLMarkupsCurveNode24’ but supplying a string like that to SetActiveListID in the python interactor fails with error
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: SetActiveListID argument 1: method requires a VTK object

Supplying a curve node as the argument does not throw an error, but also doesn’t seem to change the active list.


OK, I just discovered that actually supplying a curve node DOES seem to change the active list, but the change is not reflected in the GUI view. I suspect I need a call to something like updateGuiFromMRML() somewhere, but I can’t find how to do that call. I’ll keep looking, but if someone knows how to do that, I would be appreciative.

These examples probably do what you need:

Thank you. These are helpful references. I am still not sure why the Markups module GUI view is not updated when I set the active list ID, but it’s not actually very important for my purposes, so I am no longer pursuing it. I appreciate the help, thanks!