Hi all,
I am trying to automate the “Draw Tube” effect in Segment Editor using Python, but I am stuck at two points:
-
How to pass an existing centerline to the effect programmatically (similar to setting
"Radius"
or"Interpolation"
viasetParameter()
). -
How to trigger the “Import” button automatically via code after setting the parameters.
Here is what I have so far:
segmentEditorWidget = slicer.modules.segmenteditor.widgetRepresentation().self().editor
segmentEditorWidget.setActiveEffectByName("Draw tube")
effect = segmentEditorWidget.activeEffect()
effect.setParameter("Radius", 0.3)
effect.setParameter("Interpolation", "CARDINAL_SPLINE") # or "LINEAR"
I want to fully automate the workflow: use an existing MarkupsCurveNode as the centerline, generate the tube segment, and “import” it, without any manual interaction.
Could someone please advise:
-
What is the correct parameter name for passing a centerline to the Draw Tube effect?
-
How can I simulate clicking the Import button programmatically in Python?
-
Why does setting
"Interpolation"
update the GUI but"Radius"
does not, and how should I set the radius properly so the interface updates as well?
Thank you in advance!