<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div id="yiv814675626"><div><div style="background-color: rgb(255, 255, 255); " class="yui_3_2_0_15_134002898000951"><div id="yiv814675626yui_3_2_0_15_134002860023348" style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span id="yiv814675626yui_3_2_0_15_134002860023381">Thank you Seb,</span></div><div id="yiv814675626yui_3_2_0_15_134002860023395" style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span id="yiv814675626yui_3_2_0_15_134002860023381">For your first question : Yes, I succeeded in using my SimpleImageThreshold in Python Shell.</span></div><div id="yiv814675626yui_3_2_0_15_1340028600233154" style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span
 id="yiv814675626yui_3_2_0_15_134002860023381">Here is my script in Python Shell:</span></div><div id="yiv814675626yui_3_2_0_15_1340028600233169" style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br><span id="yiv814675626yui_3_2_0_15_134002860023381"></span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; color: rgb(0, 0, 191); font-weight: bold; " id="yiv814675626yui_3_2_0_15_1340028600233170"><span id="yiv814675626yui_3_2_0_15_134002860023381">reader = OpenDataFile('/path/to/my/file.mhd');</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; color: rgb(0, 0, 191); font-weight: bold; " id="yiv814675626yui_3_2_0_15_1340028600233187"><span id="yiv814675626yui_3_2_0_15_134002860023381">GetDisplayProperties();</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; color:
 rgb(0, 0, 191); font-weight: bold; " id="yiv814675626yui_3_2_0_15_1340028600233190"><span id="yiv814675626yui_3_2_0_15_134002860023381">ColorAttributeType ='POINT_DATA';</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; color: rgb(0, 0, 191); font-weight: bold; " id="yiv814675626yui_3_2_0_15_1340028600233197"><span id="yiv814675626yui_3_2_0_15_134002860023381">SetDisplayProperties(Representation='Volume',ColorArrayName='MetaImage');</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; color: rgb(0, 0, 191); font-weight: bold; " id="yiv814675626yui_3_2_0_15_1340028600233210"><span id="yiv814675626yui_3_2_0_15_134002860023381">Render();</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; color: rgb(0, 0, 191); font-weight: bold; " id="yiv814675626yui_3_2_0_15_1340028600233215"><br><span
 id="yiv814675626yui_3_2_0_15_134002860023381"></span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; color: rgb(0, 0, 191); font-weight: bold; " id="yiv814675626yui_3_2_0_15_1340028600233216"><span id="yiv814675626yui_3_2_0_15_134002860023381">reader2=SimpleImageThreshold(reader);</span></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; color: rgb(0, 0, 191); font-weight: bold; " id="yiv814675626yui_3_2_0_15_1340028600233221"><span id="yiv814675626yui_3_2_0_15_134002860023381">SetDisplayProperties(Representation='Volume',ColorArrayName='ImageScalars');</span></div><div id="yiv814675626yui_3_2_0_15_1340028600233246" style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span id="yiv814675626yui_3_2_0_15_134002860023381"><span style="color:rgb(0, 0, 191);font-weight:bold;">Render();</span></span></div><div
 id="yiv814675626yui_3_2_0_15_1340028600233256" style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br><span id="yiv814675626yui_3_2_0_15_134002860023381"></span></div><div id="yiv814675626yui_3_2_0_15_1340028600233257" style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span id="yiv814675626yui_3_2_0_15_134002860023381">For the second part :</span></div><div id="yiv814675626yui_3_2_0_15_1340028600233257" style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span>I have the following errors when I tried in different ways:</span></div><div id="yiv814675626yui_3_2_0_15_1340028600233257" style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">var reader = paraview.OpenDataFile('path/to/my/file.mhd');</div><div
 id="yiv814675626yui_3_2_0_15_1340028600233257" style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">ST = paraview.plugins.SimpleImageThreshold;</div><div id="yiv814675626yui_3_2_0_15_1340028600233257" style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div id="yiv814675626yui_3_2_0_15_1340028600233257" style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span style="font-weight: bold; color: rgb(192, 0, 0);">ST.SimpleImageThreshold(proxy) :&nbsp;</span></div><div id="yiv814675626yui_3_2_0_15_1340028600233257" style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span style="font-weight: bold; color: rgb(192, 0, 0);">error : </span><span style="font-weight: bold; color: rgb(0, 0, 255);">proxy not defined</span></div><div id="yiv814675626yui_3_2_0_15_1340028600233257"
 style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div id="yiv814675626yui_3_2_0_15_1340028600233257" style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span style="color: rgb(192, 0, 0); font-weight: bold;">ST.SimpleImageThreshold(reader)</span></div><div id="yiv814675626yui_3_2_0_15_1340028600233257" style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><pre style="word-wrap: break-word; white-space: pre-wrap; "><span style="color: rgb(192, 0, 0); font-weight: bold;">error:</span><span style="color: rgb(0, 0, 191);">Traceback (most recent call last):
  File "&lt;jsonrpc&gt;", line 146, in handle_request
TypeError: SimpleImageThreshold() takes exactly 1 argument (3 given)</span></pre><pre style="word-wrap: break-word; white-space: pre-wrap; "><span style="color: rgb(192, 0, 0); font-weight: bold;">ST.SimpleImageThreshold({proxy:reader});</span></pre></div><div id="yiv814675626yui_3_2_0_15_1340028600233257" style="font-size: 12pt; "><span><pre style="font-family: 'times new roman', 'new york', times, serif; word-wrap: break-word; white-space: pre-wrap; "><span style="color: rgb(192, 0, 0); font-weight: bold; font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">Error: </span><span style="color: rgb(0, 0, 191);">Traceback (most recent call last):
  File "&lt;jsonrpc&gt;", 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'</span></pre></span></div></div></div></div><span style="white-space: pre-wrap; font-size: 12pt; ">when I use : </span><br><span style="white-space: pre-wrap; font-size: 12pt; ">var reader2 = ST.SimpleImageThreshold(proxy);</span><br><span style="white-space: pre-wrap; font-size: 12pt; ">var reader2 = ST.SimpleImageThreshold(reader);</span><br><span style="white-space: pre-wrap; font-size: 12pt; ">var reader2 = ST.SimpleImageThreshold({proxy:reader});</span><br><div><div style="background-color: rgb(255, 255, 255); " class="yui_3_2_0_15_134002898000951"><div style="font-size: 12pt; "><span><pre style="word-wrap: break-word; white-space: pre-wrap; "><span style="font-family: 'times new roman', 'new york', times, serif; ">Same errors as above.</span></pre><pre style="word-wrap: break-word; white-space: pre-wrap; "><span style="font-family: 'times new roman', 'new york', times,
 serif;">I think that I have to be more precise in SimpleImageThreshold.py but I don't have any clue.</span></pre><pre style="word-wrap: break-word; white-space: pre-wrap; "><span style="font-family: 'times new roman', 'new york', times, serif;">Thank you very much Seb</span></pre></span></div></div></div><div><div style="background-color: rgb(255, 255, 255); font-family: 'times new roman', 'new york', times, serif; "><div style="font-size: 12pt; "><span><pre style="font-family: 'times new roman', 'new york', times, serif; word-wrap: break-word; white-space: pre-wrap; "><span style="color: rgb(0, 0, 191);"><br></span></pre></span></div><div id="yiv814675626yui_3_2_0_15_1340028600233260" style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span id="yiv814675626yui_3_2_0_15_134002860023381">I followed your advice. Here is my <a target="_blank"
 href="http://simpleimagethreshold.py/">SimpleImageThreshold.py</a> to be sure :</span></div><div id="yiv814675626yui_3_2_0_15_1340028600233260" style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span><br></span></div><div id="yiv814675626yui_3_2_0_15_1340028600233260"><span style="color: rgb(0, 0, 191); font-weight: bold;"><div id="yiv814675626yui_3_2_0_15_1340028600233260">from paraview.simple import *</div><div id="yiv814675626yui_3_2_0_15_1340028600233260">import os</div><div id="yiv814675626yui_3_2_0_15_1340028600233260">import threading</div><div id="yiv814675626yui_3_2_0_15_1340028600233260"><br></div><div id="yiv814675626yui_3_2_0_15_1340028600233260">def SimpleImageThreshold(proxy):</div><div id="yiv814675626yui_3_2_0_15_1340028600233260">&nbsp; &nbsp;servermanager.ActiveConnection.Modules.filters.SimpleImageThreshold(proxy)</div><div id="yiv814675626yui_3_2_0_15_1340028600233260">&nbsp;
 &nbsp;</div><div id="yiv814675626yui_3_2_0_15_1340028600233260">def createSimpleThresholdView():</div><div id="yiv814675626yui_3_2_0_15_1340028600233260">&nbsp; &nbsp;global dp</div><div id="yiv814675626yui_3_2_0_15_1340028600233260">&nbsp; &nbsp;dp = GetDisplayProperties()</div><div id="yiv814675626yui_3_2_0_15_1340028600233260">&nbsp; &nbsp;dp.LookupTable = MakeBlueToRedLT(37.35,276)</div><div id="yiv814675626yui_3_2_0_15_1340028600233260">&nbsp; &nbsp;dp.ColorAttributeType = 'POINT_DATA'</div></span></div><div style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span id="yiv814675626yui_3_2_0_15_134002860023381"><br></span></div><div style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><span id="yiv814675626yui_3_2_0_15_134002860023381"><br></span></div><div style="color: rgb(0, 0, 0); font-family: 'times new roman', 'new york', times, serif;
 font-size: 12pt; "><br id="yiv814675626yui_3_2_0_15_134002860023351"></div>  <div class="yiv814675626yui_3_2_0_15_134002860023354" id="yiv814675626yui_3_2_0_15_134002860023356" style="color: rgb(0, 0, 0); font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "> <div class="yiv814675626yui_3_2_0_15_134002860023361" style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> Sebastien Jourdain &lt;sebastien.jourdain@kitware.com&gt;<br> <b><span style="font-weight:bold;">To:</span></b> Alex &lt;tuanha_it0306@yahoo.com&gt; <br><b><span style="font-weight:bold;">Cc:</span></b> "paraview@paraview.org" &lt;paraview@paraview.org&gt; <br> <b><span style="font-weight:bold;">Sent:</span></b> Monday, June 18, 2012 1:46 PM<br> <b><span style="font-weight:bold;">Subject:</span></b> Re: [Paraview] Utilisation of
 plugin ParaView in ParaViewWeb<br> </font> </div> <br>
Hi Alex,<br><br>First of all, you should be able to remove those lines, they are not<br>needed in your case.<br><br>&gt; import os<br>&gt; import threading<br>&gt;<br>&gt; &nbsp;LoadPlugin('.../vtkSimpleImageThreshold/bin/libSimpleImageThresholdSMPlugin.so',True)<br>&gt; # server<br><br>Then my question will be: Did you managed inside the Python shell of<br>ParaView to call manually the load plugin and to instantiate your<br>filter the way you are doing it in ParaViewWeb ?<br><br>&gt; And, one more question. How can we define SimpleImageThreshold() in .py file<br>&gt; so that they can act like a real filter? Take in an image, do<br>&gt;&nbsp; his work, and we have an image thresholded as ouput?<br>&gt;<br>&gt; Reason : when I called reader2 = ST.SimpleImageThreshold({proxy}); log file<br>&gt; :<br>&gt;<br>&gt; Traceback (most recent call last):<br>&gt;&nbsp;  File "&lt;jsonrpc&gt;", line 144, in handle_request<br>&gt; TypeError: SimpleImageThreshold()
 takes no arguments (1 given)<br><br>to solve that issue you need to change your python plugin so the<br>method will look like that:<br><br>def SimpleImageThreshold(proxy):<br>&nbsp; &nbsp; ....SimpleImageThreshold(proxy)<br><br>and in JavaScript that will be<br><br>ST.SimpleImageThreshold(proxy);<br><br>note that I've removed the {}.<br><br>Seb<br><br><br> </div> </div>  </div></div></div></body></html>