View Issue Details

IDProjectCategoryView StatusLast Update
0004206Slicer4Core: Scripting (Wrapping, Python)public2018-03-02 11:06
Reporterjcfr Assigned Tohastings.greer  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Product Version 
Target VersionSlicer 4.6.0Fixed in VersionSlicer 4.6.0 
Summary0004206: Scripting: Support use of vtkCollection, and vtkArray as iterable
Description

There are currently no way to do:

for node in slicer.mrmlScene.GetNodes():
print(node)

Or more generally, any method returning a vtkCollection or vtkArray (e.g vtkStringArray) can't be treated as a python iterable.

The good news is that the feature has been integrated in upstream VTK:
https://gitlab.kitware.com/vtk/vtk/merge_requests/1545

It will be available in Slicer either after updating Slicer/VTK (either by cherry-picking the change or creating a new branch based on VTK master).

TagsNo tags attached.

Activities

hastings.greer

hastings.greer

2016-06-09 10:19

developer   ~0013965

A distinction should be made between the vtkArray class tree which includes vtkSparseArray<T> and vtkDenseArray<T>, and the vtkAbstractArray class tree which includes vtkStringArray, vtkIntArray, vtkFloatArray etc.

Confusingly, vtkArrayIterator objects iterate through vtkAbstractArrays, while vtkArrays have no existing iteration protocol.

hastings.greer

hastings.greer

2016-06-09 13:06

developer   ~0013966

The implementation of iterable in the vtk master branch depends on many changes in the wrapping implementation made between slicer's version of vtk and the nightly build of vtk. Cherry picking won't be possible.

jcfr

jcfr

2016-10-12 03:17

administrator   ~0014160

Since the version of VTK used in Slicer has been updated, I am resolving.

Issue History

Date Modified Username Field Change
2016-06-08 23:55 jcfr New Issue
2016-06-08 23:55 jcfr Status new => assigned
2016-06-08 23:55 jcfr Assigned To => hastings.greer
2016-06-09 10:19 hastings.greer Note Added: 0013965
2016-06-09 13:06 hastings.greer Note Added: 0013966
2016-10-12 03:17 jcfr Note Added: 0014160
2016-10-12 03:17 jcfr Status assigned => resolved
2016-10-12 03:17 jcfr Fixed in Version => Slicer 4.6.0
2016-10-12 03:17 jcfr Resolution open => fixed
2018-03-02 11:06 jcfr Status resolved => closed