<div dir="ltr"><div>Use the hidden property called Parameters on the Python Filter/Source to pass in information.</div><div><br></div><div><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt">>>> prosrc = ProgrammableSource()</span>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt">>>> prosrc.Script = ("""</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt">... try:</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt">... instring</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt">... except NameError:</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt">... instring = "GOODBYE"</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt">... print instring</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt">... """)</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt">>>> prop = prosrc.GetProperty("Parameters")</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt">>>> prop.SetElement(0, "instring")</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,150,0);font-family:"courier";font-size:8.25pt">1</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt">>>> prop.SetElement(1, "'HELLO'")</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,150,0);font-family:"courier";font-size:8.25pt">1</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt">>>> prosrc.UpdateProperty("Parameters")</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,150,0);font-family:"courier";font-size:8.25pt">True</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt">>>> prosrc.UpdatePipeline()</span></p>
<p style="margin:0px;text-indent:0px"><span style="color:rgb(0,150,0);font-family:"courier";font-size:8.25pt">HELLO</span></p>
<p style="margin:0px;text-indent:0px"><br></p></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature">David E DeMarle<br>Kitware, Inc.<br>R&D Engineer<br>21 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: 518-881-4909</div></div>
<br><div class="gmail_quote">On Wed, Mar 1, 2017 at 3:38 PM, Mauro Fontana <span dir="ltr"><<a href="mailto:fontana.mauro@gmail.com" target="_blank">fontana.mauro@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello<div><br></div><div>Sorry to bother, but I can't seem to find a way (in the mailing list or the documentation) to pass a string as some kind of argument to Programmable Source (using pvpython interpreter). The python "program" needs to load a custom binary format using numpy.fromfile.</div><div><br></div><div>What I've thought is to write a wrapper function. The function should receive a string as argument and then instantiate a programmable filter and execute </div><div>myscript.replace(random_var_<wbr>name, myfilename)</div><div>MyProgrammableSource.Script = myscript</div><div>return MyProgrammableSource</div><div><br></div><div>Where random_var_name is the argument of my numpy.fromfile call. But that doesn't seem very "pythonic". Is there a way to pass a string to the Script without the .replace hack?<br></div><div><br></div><div>Sorry if this is documented, I couldn't find it.</div><div><br></div><div>Cheers,</div><div>Mauro</div></div>
<br>______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" target="_blank" rel="noreferrer">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank" rel="noreferrer">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" target="_blank" rel="noreferrer">http://paraview.org/Wiki/<wbr>ParaView</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=ParaView" target="_blank" rel="noreferrer">http://markmail.org/search/?q=<wbr>ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/paraview" target="_blank" rel="noreferrer">http://public.kitware.com/<wbr>mailman/listinfo/paraview</a><br>
<br></blockquote></div><br></div>