Sphere brush via script

Hi, i can’t find the script to switch to sphere brush (or edit in 3d views as well),
i tried this but it doesen’t seem to work:

    import EditorLib
    paramnode = EditorLib.EditUtil.EditUtil().getParameterNode()
    paramnode.SetParameter('PaintEffect,sphere', '1')

Thanks for any inputs

Please do not use the legacy Editor module but switch to Segment Editor module. Parameter names controlling paint effect are described here. Examples of scripting Segment Editor effects are available here.

Thanks, that worked well, however i got another problem while using this to enable sphere brush; the checkbox on Segment Editor gets “stuck” and doesen’t work as a switch anymore:

editor = slicer.modules.segmenteditor.widgetRepresentation().self().editor
paint = editor.effectByName("Paint")
paint.setParameter("BrushSphere", 1)

As you can see in the code that I linked above, BrushSphere is a “common” parameter (so that the same setting can be used in paint and erase effects) and has to be set accordingly using setCommonParameter. Using setParameter would override the parameter value for a particular effect and so Segment Editor module GUI (that adjusts the common parameter value) would not have an effect anymore.

1 Like

Thanks a lot, it works fine.

1 Like