# Modify Wrap Solidify values with Python

**URL:** <https://discourse.slicer.org/t/modify-wrap-solidify-values-with-python/42519>\
**Category:** Support\
**Tags:** segmentation, python\
**Created:** [April 10, 2025, 12:58pm UTC](https://discourse.slicer.org/t/modify-wrap-solidify-values-with-python/42519 "2025-04-10T12:58:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kalman](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@Kalman](https://discourse.slicer.org/u/Kalman)\
**Post date:** [April 10, 2025, 12:58pm UTC](https://discourse.slicer.org/t/modify-wrap-solidify-values-with-python/42519/1 "2025-04-10T12:58:40Z")

</div>

Hi! I have a question regarding accessing the **Wrap Solidify** extension through scripting - in a certain step it uses predefined values to perform a wrapping on the active segment. (I’m using Slicer version 5.8.1)

**Background:** I have tried many different approaches in the coding, but I couldn’t find a way to modify the slider values through the Python console. I attach a basic script below to show how it was given to the console.

**The issue:** What I have found, that even though the parameters were given directly, the execution still uses those values which are shown in the UI window of the wrap solidify.

**The question** : what should be modified to be able to change the individual floating value parameters?

Thank you for your help!

```auto
segmentEditorWidget.setActiveEffectByName("Wrap Solidify")
effect = segmentEditorWidget.activeEffect()

if not effect:
    raise RuntimeError("❌ Wrap Solidify effect not found!")

effect.setParameter("region", "largestCavity")
effect.setParameter("splitCavities", True)
effect.setParameter("splitCavitiesDiameterMm", 2.0)  
effect.setParameter("smoothingFactor", 0.3)       
effect.setParameter("oversamplingFactor", 1.0)    
effect.setParameter("numberOfIterations", 1)     
effect.setParameter("outputType", "newSegment")      
effect.setParameter("saveIntermediateResults", False)

effect.self().onApply()

print("Wrap Solidify applied with predefined parameters.")
slicer.app.processEvents()

```

 ![wrap_img](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/d/2d707d3cecd3678021a291e5dc50354707c4d5ab.jpeg)

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [April 10, 2025, 1:17pm UTC](https://discourse.slicer.org/t/modify-wrap-solidify-values-with-python/42519/2 "2025-04-10T13:17:27Z")

</div>

Pass strings to `setParameter`, ex `str(1)`.

---

<div class="post-metadata">

**Author:** ![Kalman](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@Kalman](https://discourse.slicer.org/u/Kalman)\
**Post date:** [April 10, 2025, 1:27pm UTC](https://discourse.slicer.org/t/modify-wrap-solidify-values-with-python/42519/3 "2025-04-10T13:27:24Z")

</div>

Dear @chir.set,

Thank you for the quick response! I have tried it (script attached), but the program still uses those values written in the UI boxes and not the one given via the Python script.

What is your suggestion?

```auto
segmentEditorWidget.setActiveEffectByName("Wrap Solidify")
effect = segmentEditorWidget.activeEffect()

if not effect:
    raise RuntimeError("❌ Wrap Solidify effect not found!")

effect.setParameter("region", "largestCavity")
effect.setParameter("splitCavities", True)
effect.setParameter("splitCavitiesDiameterMm", str(2.0))  
effect.setParameter("smoothingFactor", str(0.3))       
effect.setParameter("oversamplingFactor", str(1.0))    
effect.setParameter("numberOfIterations", str(1))     
effect.setParameter("outputType", "newSegment")      
effect.setParameter("saveIntermediateResults", False)

effect.self().onApply()

print("Wrap Solidify applied with predefined parameters.")
slicer.app.processEvents()

```

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [April 10, 2025, 1:51pm UTC](https://discourse.slicer.org/t/modify-wrap-solidify-values-with-python/42519/4 "2025-04-10T13:51:02Z")

</div>

You can poke the right parameter names in `SegmentEditorWrapSolidifyLib/SegmentEditorEffect.py`.

For example, `splitCavitiesDiameterMm` should have been `splitCavitiesDiameter`.

---

<div class="post-metadata">

**Author:** ![Kalman](https://avatars.discourse-cdn.com/v4/letter/k/59ef9b/32.png) [@Kalman](https://discourse.slicer.org/u/Kalman)\
**Post date:** [April 10, 2025, 1:58pm UTC](https://discourse.slicer.org/t/modify-wrap-solidify-values-with-python/42519/5 "2025-04-10T13:58:55Z")

</div>

@chir.set: Thank you very much! I’ve checked the source, revised it accordingly, and now it works fine!

I paste below the updated script for those who has similar issues that they could see the corrected version:

```auto
segmentEditorWidget.setActiveEffectByName("Wrap Solidify")
effect = segmentEditorWidget.activeEffect()

effect.setParameter("region", "largestCavity")
effect.setParameter("splitCavities", str(True))
effect.setParameter("splitCavitiesDiameter", str(2.0))
effect.setParameter("smoothingFactor", str(0.3))
effect.setParameter("remeshOversampling", str(1.0))
effect.setParameter("shrinkwrapIterations", str(1))
effect.setParameter("outputType", "newSegment")
effect.setParameter("saveIntermediateResults", str(False))

effect.self().onApply()

print("Wrap Solidify applied with corrected parameters.")
slicer.app.processEvents()

```
