<div dir="ltr">Now that sounds (reads) much better and cleaner.<div><br></div><div>Thanks for your time and your response David.</div><div><br></div><div>Cheers</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Mar 2, 2017 at 1:06 PM David E DeMarle <<a href="mailto:dave.demarle@kitware.com">dave.demarle@kitware.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_msg">Use the hidden property called Parameters on the Python Filter/Source to pass in information.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">>>> prosrc = ProgrammableSource()</span>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">>>> prosrc.Script = ("""</span></p>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">... try:</span></p>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">...      instring</span></p>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">... except NameError:</span></p>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">...      instring = "GOODBYE"</span></p>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">... print instring</span></p>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">... """)</span></p>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">>>> prop = prosrc.GetProperty("Parameters")</span></p>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">>>> prop.SetElement(0, "instring")</span></p>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><span style="color:rgb(0,150,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">1</span></p>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">>>> prop.SetElement(1, "'HELLO'")</span></p>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><span style="color:rgb(0,150,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">1</span></p>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">>>> prosrc.UpdateProperty("Parameters")</span></p>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><span style="color:rgb(0,150,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">True</span></p>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><span style="color:rgb(0,0,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">>>> prosrc.UpdatePipeline()</span></p>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><span style="color:rgb(0,150,0);font-family:"courier";font-size:8.25pt" class="gmail_msg">HELLO</span></p>
<p style="margin:0px;text-indent:0px" class="gmail_msg"><br class="gmail_msg"></p></div></div><div class="gmail_extra gmail_msg"><br clear="all" class="gmail_msg"><div class="gmail_msg"><div class="m_128395479482841962gmail_signature gmail_msg" data-smartmail="gmail_signature">David E DeMarle<br class="gmail_msg">Kitware, Inc.<br class="gmail_msg">R&D Engineer<br class="gmail_msg">21 Corporate Drive<br class="gmail_msg">Clifton Park, NY 12065-8662<br class="gmail_msg">Phone: <a href="tel:(518)%20881-4909" value="+15188814909" class="gmail_msg" target="_blank">518-881-4909</a></div></div>
<br class="gmail_msg"><div class="gmail_quote gmail_msg"></div></div><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg">On Wed, Mar 1, 2017 at 3:38 PM, Mauro Fontana <span dir="ltr" class="gmail_msg"><<a href="mailto:fontana.mauro@gmail.com" class="gmail_msg" target="_blank">fontana.mauro@gmail.com</a>></span> wrote:<br class="gmail_msg"></div></div><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">Hello<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">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 class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">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 class="gmail_msg">myscript.replace(random_var_name, myfilename)</div><div class="gmail_msg">MyProgrammableSource.Script = myscript</div><div class="gmail_msg">return MyProgrammableSource</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">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 class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Sorry if this is documented, I couldn't find it.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Cheers,</div><div class="gmail_msg">Mauro</div></div>
<br class="gmail_msg"></blockquote></div></div><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<br class="gmail_msg">
Powered by <a href="http://www.kitware.com" rel="noreferrer" class="gmail_msg" target="_blank">www.kitware.com</a><br class="gmail_msg">
<br class="gmail_msg">
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" class="gmail_msg" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br class="gmail_msg">
<br class="gmail_msg">
Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" rel="noreferrer" class="gmail_msg" target="_blank">http://paraview.org/Wiki/ParaView</a><br class="gmail_msg">
<br class="gmail_msg">
Search the list archives at: <a href="http://markmail.org/search/?q=ParaView" rel="noreferrer" class="gmail_msg" target="_blank">http://markmail.org/search/?q=ParaView</a><br class="gmail_msg">
<br class="gmail_msg">
Follow this link to subscribe/unsubscribe:<br class="gmail_msg">
<a href="http://public.kitware.com/mailman/listinfo/paraview" rel="noreferrer" class="gmail_msg" target="_blank">http://public.kitware.com/mailman/listinfo/paraview</a><br class="gmail_msg">
<br class="gmail_msg"></blockquote></div><br class="gmail_msg"></div>
</blockquote></div>