Hi Alex, sorry to say that but you did not properly read what I wrote...
I've ask you if the following line worked in ParaView python: severmanager.ActiveConnection.Modules.filters.SimpleImageThreshold() Anyway, to solve the issue related to the number of arguments, you should be able to do that: var reader2 = ST.SimpleImageThreshold( [reader] ); And all that is assuming your initial issue where your proxy defined inside your plugin is finally properly found. Which I still don't know if it is the case or not. Seb On Mon, Jun 18, 2012 at 10:33 AM, Alex <[email protected]> wrote: > Thank you Seb, > For your first question : Yes, I succeeded in using my SimpleImageThreshold > in Python Shell. > Here is my script in Python Shell: > > reader = OpenDataFile('/path/to/my/file.mhd'); > GetDisplayProperties(); > ColorAttributeType ='POINT_DATA'; > SetDisplayProperties(Representation='Volume',ColorArrayName='MetaImage'); > Render(); > > reader2=SimpleImageThreshold(reader); > SetDisplayProperties(Representation='Volume',ColorArrayName='ImageScalars'); > Render(); > > For the second part : > I have the following errors when I tried in different ways: > var reader = paraview.OpenDataFile('path/to/my/file.mhd'); > ST = paraview.plugins.SimpleImageThreshold; > > ST.SimpleImageThreshold(proxy) : > error : proxy not defined > > ST.SimpleImageThreshold(reader) > > error:Traceback (most recent call last): > File "<jsonrpc>", line 146, in handle_request > TypeError: SimpleImageThreshold() takes exactly 1 argument (3 given) > > ST.SimpleImageThreshold({proxy:reader}); > > Error: Traceback (most recent call last): > File "<jsonrpc>", line 144, in handle_request > File "/home/thtran/PV/workdir/plugins/SimpleImageThreshold.py", line 11, > in SimpleImageThreshold > > servermanager.ActiveConnection.Modules.filters.SimpleImageThreshold(proxy) > AttributeError: 'PVModule' object has no attribute 'SimpleImageThreshold' > > when I use : > var reader2 = ST.SimpleImageThreshold(proxy); > var reader2 = ST.SimpleImageThreshold(reader); > var reader2 = ST.SimpleImageThreshold({proxy:reader}); > > Same errors as above. > > I think that I have to be more precise in SimpleImageThreshold.py but I > don't have any clue. > > Thank you very much Seb > > > I followed your advice. Here is my SimpleImageThreshold.py to be sure : > > from paraview.simple import * > import os > import threading > > def SimpleImageThreshold(proxy): > > servermanager.ActiveConnection.Modules.filters.SimpleImageThreshold(proxy) > > def createSimpleThresholdView(): > global dp > dp = GetDisplayProperties() > dp.LookupTable = MakeBlueToRedLT(37.35,276) > dp.ColorAttributeType = 'POINT_DATA' > > > > ________________________________ > From: Sebastien Jourdain <[email protected]> > To: Alex <[email protected]> > Cc: "[email protected]" <[email protected]> > Sent: Monday, June 18, 2012 1:46 PM > > Subject: Re: [Paraview] Utilisation of plugin ParaView in ParaViewWeb > > Hi Alex, > > First of all, you should be able to remove those lines, they are not > needed in your case. > >> import os >> import threading >> >> >> LoadPlugin('.../vtkSimpleImageThreshold/bin/libSimpleImageThresholdSMPlugin.so',True) >> # server > > Then my question will be: Did you managed inside the Python shell of > ParaView to call manually the load plugin and to instantiate your > filter the way you are doing it in ParaViewWeb ? > >> And, one more question. How can we define SimpleImageThreshold() in .py >> file >> so that they can act like a real filter? Take in an image, do >> his work, and we have an image thresholded as ouput? >> >> Reason : when I called reader2 = ST.SimpleImageThreshold({proxy}); log >> file >> : >> >> Traceback (most recent call last): >> File "<jsonrpc>", line 144, in handle_request >> TypeError: SimpleImageThreshold() takes no arguments (1 given) > > to solve that issue you need to change your python plugin so the > method will look like that: > > def SimpleImageThreshold(proxy): > ....SimpleImageThreshold(proxy) > > and in JavaScript that will be > > ST.SimpleImageThreshold(proxy); > > note that I've removed the {}. > > Seb > > _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Follow this link to subscribe/unsubscribe: http://www.paraview.org/mailman/listinfo/paraview
