Create a cylinder based on user input

Hi everybody,
I’m new to 3DSlicer so I don’t really know where to begin.
I’m trying to develop a module in order to automatically create a cylinder based on user input.
The idea is that the user selects a radius, then clicks on the point which will be the axis of the cylinder. Once the cylinder is created I want to show it and finally merge it with the previously loaded data.
Any suggestion is greatly appreciated.
Thank you!

I recently needed to do this and I found the easiest method was to use the Markups to Models module included in the slicerIGT extension. This let’s you create a cylinder with at least 2 markup fiducials.

1 Like

Thanks a lot for the info Prashant_Pandey!
One more question: is it possible to call the Markups to Models module from the python interactor?
Based on the user input I created some fiducials in a python script. Now I would like to use these to create a closed surface automatically.

You may also use markups lines or SegmentEditorExtraEffects extension’s Draw Tube effect. What would you like to achieve?

Hello lassoan,
The idea is that the user inserts a fiducial point in the center of the base of the cylinder and chooses a radius. Based on this information I want to automatically create a cylinder so that then I can merge the cylinder with the original volume and export as .stl

How do you merge a cylinder (surface mesh) with a volume? If you do it in Segment Editor for that then Draw Tube effect may be the simplest method.

I’m sorry, I’m new to Slicer and it’s not clear to me what is the simplest way forward.
Based on the fact that I’d like to merge the cylinder (either obtained as surface or volume) with the existing volume in order to 3Dprint the two together, what would you suggest?
Right now I have fiducials placed in a circle on two different levels on the z axis. Is it possible to create a solid cylinder starting from this configuration?
Thank you very much for the patience.

I am sure you can access and use the logic of the Markups To Models in a python script, but I am not sure what the exact function calls are.

For combining the two, I would recommend converting the pertinent structure in your medical volume into a segment using a the ‘segment editor’ module and converting your cylinder model into a segment by importing it as a label map from the ‘segmentations’ module. You can then combine the two label maps and export as a surface model, which you can save as an .stl file to be used with your printer.

Draw tube effect creates a cylinder-shape segment from input markup points, so this seems to be the most direct solution. There are also many examples of running segment editor effects from scripts in the script repository: