# Set Dynamic Modeler Attributes with python

**URL:** <https://discourse.slicer.org/t/set-dynamic-modeler-attributes-with-python/31376>\
**Category:** Support\
**Created:** [August 26, 2023, 10:47am UTC](https://discourse.slicer.org/t/set-dynamic-modeler-attributes-with-python/31376 "2023-08-26T10:47:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Caetox](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/caetox/32/17513_2.png) [@Caetox](https://discourse.slicer.org/u/Caetox)\
**Post date:** [August 26, 2023, 10:47am UTC](https://discourse.slicer.org/t/set-dynamic-modeler-attributes-with-python/31376/1 "2023-08-26T10:47:28Z")

</div>

I am using the Dynamic Modeler Module in my python script.  
For the ROI Cut Tool, I set the input model, input ROI and output model and so far this works perfectly.  
But I want the surface to be capped. In the Dynamic Modeler widget there is an option “Cap surface” with a checkbox. How can I set this attribute with python?  
I figured out how to set the attributes:

> dynamicModelerNode.SetAttribute(“ROICut.CapSurface”, \_ )

but what value do i need to put to make it work? It only takes a string.

I tried finding the attributes with their possible values like this:

> roiCutTool = slicer.vtkSlicerDynamicModelerROICutTool()  
> for i in range(roiCutTool.GetNumberOfInputParameters()):  
> print(roiCutTool.GetNthInputParameterAttributeName(i))  
> print(roiCutTool.GetNthInputParameterName(i))  
> print(roiCutTool.GetNthInputParameterPossibleValues(i))  
> print(roiCutTool.GetNthInputParameterDescription(i))

but for the possible values of ROICut.CapSurface, it returns None.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [August 28, 2023, 9:34am UTC](https://discourse.slicer.org/t/set-dynamic-modeler-attributes-with-python/31376/2 "2023-08-28T09:34:48Z")

</div>

This should work:

```auto
dynamicModelerNode.SetAttribute('ROICut.CapSurface', '1')

```

FYI the way I found it out was that I printed the content of the ROI cut parameter node. It gave me this:

```auto
>>> print(dynamicModelerNode)
vtkMRMLDynamicModelerNode (0000026506838D10)
  ID: vtkMRMLDynamicModelerNode1
  ClassName: vtkMRMLDynamicModelerNode
  Name: ROI cut
  Debug: false
  MTime: 278225
  Description: (none)
  SingletonTag: (none)
  HideFromEditors: false
  Selectable: true
  Selected: false
  UndoEnabled: false
  Attributes:
    ROICut.CapSurface:1
  Node references:
    ROICut.InputModel: (none)
    ROICut.InputROI: (none)
    ROICut.OutputNegativeModel: (none)
    ROICut.OutputPositiveModel: (none)
  ToolName: ROI cut
  ContinuousUpdate: false

```
