# Use python to turn on visibility for model to model distance scalars and color bars

**URL:** https://discourse.slicer.org/t/use-python-to-turn-on-visibility-for-model-to-model-distance-scalars-and-color-bars/41295
**Category:** Support
**Created:** [January 26, 2025, 7:30pm UTC](https://discourse.slicer.org/t/use-python-to-turn-on-visibility-for-model-to-model-distance-scalars-and-color-bars/41295 "2025-01-26T19:30:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![evaherbst](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/evaherbst/32/65595_2.png) [@evaherbst](https://discourse.slicer.org/u/evaherbst)
#### Post date: [January 26, 2025, 7:30pm UTC](https://discourse.slicer.org/t/use-python-to-turn-on-visibility-for-model-to-model-distance-scalars-and-color-bars/41295/1 "2025-01-26T19:30:38Z")

</div>

Hello,

I am called the ModeltoModel distance module in Slicer with Python to batch run the distance calculations of several pairs of models.

Is there a way in Python automatically turn on visibility of the scalars from the model-to-model distance and also the heat map bars?

Thank you!

---

<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: [January 29, 2025, 11:17am UTC](https://discourse.slicer.org/t/use-python-to-turn-on-visibility-for-model-to-model-distance-scalars-and-color-bars/41295/2 "2025-01-29T11:17:12Z")

</div>

You need to get the display node of the model node and apply the settings you want on the display node. For example for turning on scalar visibility you can call this function:

> <https://github.com/Slicer/Slicer/blob/main/Libs/MRML/Core/vtkMRMLDisplayNode.h#L393>

This snippet is for showing scalar bar for volumes. I don’t know if this works for model scalars, but I’d start here  
[https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html#show-color-legend-for-a-volume-node](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#show-color-legend-for-a-volume-node)

---

<div class="post-metadata">

### Author: ![evaherbst](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/evaherbst/32/65595_2.png) [@evaherbst](https://discourse.slicer.org/u/evaherbst)
#### Post date: [February 11, 2025, 9:34am UTC](https://discourse.slicer.org/t/use-python-to-turn-on-visibility-for-model-to-model-distance-scalars-and-color-bars/41295/3 "2025-02-11T09:34:52Z")

</div>

Thank you very much! I will test this
