# Set slice intersection doesn't work

**URL:** <https://discourse.slicer.org/t/set-slice-intersection-doesnt-work/14534>\
**Category:** Development\
**Created:** [November 10, 2020, 10:13pm UTC](https://discourse.slicer.org/t/set-slice-intersection-doesnt-work/14534 "2020-11-10T22:13:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [November 10, 2020, 10:13pm UTC](https://discourse.slicer.org/t/set-slice-intersection-doesnt-work/14534/1 "2020-11-10T22:13:56Z")

</div>

This works on the python console:

```auto
nodes = slicer.util.getNodesByClass('vtkMRMLSliceCompositeNode')
for node in nodes:#Corrected this line and the one below because of bad indentation
  node.SetSliceIntersectionVisibility(True)

```

But if I append it to the onEntry function of my extension it doesn’t work. Why does this happen?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 10, 2020, 10:19pm UTC](https://discourse.slicer.org/t/set-slice-intersection-doesnt-work/14534/2 "2020-11-10T22:19:04Z")

</div>

When you enter your module, `enter()` method is called, not `onEntry`. Indentation in your code snippet is also incorrect (second line should be indent level should be the same as the first). If these hints don’t help then set up a debugger and place a breakpoint in the method and inspect what is happening exactly when the method is executed.

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [November 10, 2020, 10:48pm UTC](https://discourse.slicer.org/t/set-slice-intersection-doesnt-work/14534/3 "2020-11-10T22:48:47Z")

</div>

Hi Andras. Thanks for your answer. I took your advice of using Code to debug and I tried it in this case but I didn’t had success finding the cause of this error (I checked that the code executes not too early like the other day).

Here it is the line that is causing trouble if you want to check it out:

> <https://github.com/mauigna06/PedicleScrewSimulator/blob/d4dc0c67de9b0e0e6d750511456617289d86ae33/PedicleScrewSimulator/PedicleScrewSimulatorWizard/ScrewStep.py#L854>

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 11, 2020, 3:51pm UTC](https://discourse.slicer.org/t/set-slice-intersection-doesnt-work/14534/4 "2020-11-11T15:51:54Z")

</div>

> [@mau\_igna\_06](#):
>
> `nodes = slicer.util.getNodesByClass('vtkMRMLSliceCompositeNode')`

Do you mean you get an error message when you run this line?  
What is the error message?

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [November 11, 2020, 8:22pm UTC](https://discourse.slicer.org/t/set-slice-intersection-doesnt-work/14534/5 "2020-11-11T20:22:07Z")

</div>

When I said error I refer to an unexpected behaviour (that is: nothing happens).  
The problem is when I execute those lines nothing happens and it should show the slice intersections.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 11, 2020, 10:22pm UTC](https://discourse.slicer.org/t/set-slice-intersection-doesnt-work/14534/6 "2020-11-11T22:22:21Z")

</div>

Take advantage of your debugger. Step through your code, see how many composite nodes it finds. Add breakpoints to all the lines in all the files where `SetSliceIntersectionVisibility` is called (maybe after you enable visibility somewhere else it gets disabled). Add breakpoints at various other places in the code and iterate through the composite nodes and see if intersection visibility is still enabled - you should be able then find what makes the intersections hidden.

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [November 12, 2020, 5:56pm UTC](https://discourse.slicer.org/t/set-slice-intersection-doesnt-work/14534/7 "2020-11-12T17:56:24Z")

</div>

Thank you Andras. I was able to find the problem: The onEntry function of Step5 was called before it was needed on the onExit function of Step4 so then the changes I setted up were being overwritten
