[Paraview] Why does this programmable source not work outside the paraview GUI

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Fri Nov 21 14:35:13 EST 2008


The answer is simple: you are missing the UpdateVTKObjects() call to 
'apply' the change to the property.

If you going to use ...GetProperty("..").SetElement(...) API then after 
the property has been set, one must call proxy.UpdateVTKObjects().

so in your example:
...
pgsrc.GetProperty("Script").SetElement(0, """ ... """)
pgsrc.UpdateVTKObjects()

Alternatively  you can simply do:
pgsrc.Script = """....."

and then you don't have to worry about calling UpdateVTKObjects().

Utkarsh



Louis at M-Tech wrote:
> Hi All,
> 
>  
> 
> Why does this piece of code containing a programmable source not work 
> OUTSIDE the paraview GUI?
> 
>  
> 
> a) When the source is changed to ConeSource() it works (see Label 1 in 
> the code below).
> 
>  
> 
> b) Also when the Script content is pasted inside the paraview GUI 
> scripting editor, it does work – so the script contents itself is ok.
> 
>  
> 
> When the code is run directly from a python command line only an empty 
> graphis window is displayed – as if the script part is faulty.
> 
>  
> 
> Thanks in advance,
> 
> Louis
> 
>  
> 
> HERE IS THE EXAMPLE:
> 
> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> 
> from paraview import servermanager
> 
> connection = servermanager.Connect()
> 
> pgsrc=servermanager.sources.ProgrammableSource()
> 
>  
> 
>  
> 
> pgsrc.GetProperty("Script").SetElement(0, """
> 
>  
> 
> import vtk
> 
> pts=vtk.vtkPoints()
> 
> pts.Initialize()
> 
> pts.InsertNextPoint(0,0,0)
> 
> pts.InsertNextPoint(1,0,.0)
> 
> pts.InsertNextPoint(2,1,0)
> 
> pts.InsertNextPoint(3,3,0.)
> 
>  
> 
> cel=vtk.vtkCellArray()
> 
> cel.Initialize()
> 
> cel.InsertNextCell(4) # number of points
> 
> cel.InsertCellPoint(0)
> 
> cel.InsertCellPoint(1)
> 
> cel.InsertCellPoint(2)
> 
> cel.InsertCellPoint(3)
> 
>  
> 
> output = self.GetOutput()
> 
> output.SetPoints(pts)
> 
> output.SetStrips(cel)
> 
>  
> 
> """)
> 
>  
> 
>  
> 
> view = servermanager.CreateRenderView()
> 
>  
> 
> # This programmable source pgsrc does not display
> 
> rep = servermanager.CreateRepresentation(pgsrc,view)
> 
>  
> 
> # Label 1: This source do display
> 
> #coneSource = servermanager.sources.ConeSource()
> 
> #rep = servermanager.CreateRepresentation(coneSource,view)
> 
>  
> 
>  
> 
> view.StillRender()
> 
> view.ResetCamera()
> 
> view.StillRender()
> 
>  
> 
> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> 
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> ParaView mailing list
> ParaView at paraview.org
> http://www.paraview.org/mailman/listinfo/paraview


More information about the ParaView mailing list