# Update 3D view if node changes

**URL:** <https://discourse.slicer.org/t/update-3d-view-if-node-changes/7530>\
**Category:** Development\
**Created:** [July 11, 2019, 1:48pm UTC](https://discourse.slicer.org/t/update-3d-view-if-node-changes/7530 "2019-07-11T13:48:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![fpsiddiqui91](https://avatars.discourse-cdn.com/v4/letter/f/53a042/32.png) [@fpsiddiqui91](https://discourse.slicer.org/u/fpsiddiqui91)\
**Post date:** [July 11, 2019, 1:48pm UTC](https://discourse.slicer.org/t/update-3d-view-if-node-changes/7530/1 "2019-07-11T13:48:18Z")

</div>

Hello Slicer Developers,

I am quite new to slicer and still in exploring stage. I have developed a small application in which a track can be generated from the given markup

Then I changed the coordinates of the markup simply by

`Preformatted text`markups.SetNthFiducialPositionFromArray(markups.GetNumberOfFiducials() - 1, newCord)`Preformatted text`

Now I want to change the coodinates of the markup in a loop which can easily be done.

The problem is the 3D view is not updating at each iteration after updating the markup Node? is there any command to update the 3D view while the processing the loop.

Thank you

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 11, 2019, 3:28pm UTC](https://discourse.slicer.org/t/update-3d-view-if-node-changes/7530/2 "2019-07-11T15:28:09Z")

</div>

Slicer is event driven, so rendering only happens when all events have been processed. So you can either call processEvents, like in ScreenCapture, or you can set up a timer to make your changes like in Rock mode for the viewer.

> <https://github.com/Slicer/Slicer/blob/21dc780a216f077bdd080fdc64073ccf6b5356e0/Modules/Scripted/ScreenCapture/ScreenCapture.py#L831>

> <https://github.com/commontk/CTK/blob/cccef11c938cc946789ddb25ccc613287a33c56e/Libs/Visualization/VTK/Widgets/ctkVTKRenderView.cpp#L166-L192>

---

<div class="post-metadata">

**Author:** ![fpsiddiqui91](https://avatars.discourse-cdn.com/v4/letter/f/53a042/32.png) [@fpsiddiqui91](https://discourse.slicer.org/u/fpsiddiqui91)\
**Post date:** [July 12, 2019, 7:34am UTC](https://discourse.slicer.org/t/update-3d-view-if-node-changes/7530/4 "2019-07-12T07:34:05Z")

</div>

Thank you for your response, it kind of worked for me.

Is there any option in Slicer for dynamic update? My project needs some heavy computations which might need some time for the processing, is there any way that my module keeps on processing meanwhile user can interact in the rendering window?

Thank you for your help

---

<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:** [July 12, 2019, 12:33pm UTC](https://discourse.slicer.org/t/update-3d-view-if-node-changes/7530/5 "2019-07-12T12:33:17Z")

</div>

You can put your computation into a CLI module, which can run in the background. See a Python example here: [https://github.com/lassoan/SlicerPythonCLIExample](https://github.com/lassoan/SlicerPythonCLIExample)

---

<div class="post-metadata">

**Author:** ![fpsiddiqui91](https://avatars.discourse-cdn.com/v4/letter/f/53a042/32.png) [@fpsiddiqui91](https://discourse.slicer.org/u/fpsiddiqui91)\
**Post date:** [July 12, 2019, 1:50pm UTC](https://discourse.slicer.org/t/update-3d-view-if-node-changes/7530/6 "2019-07-12T13:50:14Z")

</div>

Thank you Lassoan, This is exactly what I needed.

Thanks alot

---

<div class="post-metadata">

**Author:** ![fpsiddiqui91](https://avatars.discourse-cdn.com/v4/letter/f/53a042/32.png) [@fpsiddiqui91](https://discourse.slicer.org/u/fpsiddiqui91)\
**Post date:** [July 24, 2019, 5:14pm UTC](https://discourse.slicer.org/t/update-3d-view-if-node-changes/7530/7 "2019-07-24T17:14:35Z")

</div>

Hello Lassoan,

I am trying to impelment my own CLI module within my python script. My aim is to run my computation on CLI in the background as you have suggested.  
I need a guidance on it.

The basic workflow goes like this:

```
cliNode =slicer.cli.runSync(CLItest(), parameters=param)

```

And my CLItest() class is given as:

```
class CLItest(ScriptedLoadableModuleLogic):
  def logic(self):
    a = testVariables()
    for i in range(0,100):
       a.var1=a.var1+1
       print (a.var1)

print("cliTesttttt")

def name(self):
  pass

class testVariables(ScriptedLoadableModuleLogic):
    var1 = 0

```

This program will just print 0 to 100 numbers. it worked fine.

Now I want to give my DWI node as an input to my cli module for further processing.  
Can you guide me with it?

Are there any easy approach to do it.

Thanks

---

<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:** [July 24, 2019, 8:18pm UTC](https://discourse.slicer.org/t/update-3d-view-if-node-changes/7530/8 "2019-07-24T20:18:11Z")

</div>

Here is an example Python CLI module that does DWI processing: [https://github.com/SlicerDMRI/SlicerDMRI/tree/master/Modules/CLI/ExtractDWIShells](https://github.com/SlicerDMRI/SlicerDMRI/tree/master/Modules/CLI/ExtractDWIShells)
