[Paraview] using user selected cells in the python shell

Richardson CFD garcfd at gmail.com
Sat Apr 22 03:25:52 EDT 2017


managed to achieve it using the following (python shell) code:

from paraview.simple import *

####extract
ExtractSelection()
Show()

####filter
trans_prog_filter = ProgrammableFilter()
RenameSource("Translate", trans_prog_filter)
trans_prog_filter.Script = """
pdi = self.GetInput()
pdo =  self.GetOutput()
newPoints = vtk.vtkPoints()
numPoints = pdi.GetNumberOfPoints()
for i in range(0, numPoints):
    coord = pdi.GetPoint(i)
    x, y, z = coord[:3]
    x = x - 1.0
    y = y + 0.0
    z = z + 0.0
    newPoints.InsertPoint(i, x, y, z)
pdo.SetPoints(newPoints)
"""
Show()

-- 
Richardson CFD
http://richardsoncfd.weebly.com<div
id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br />
<table style="border-top: 1px solid #D3D4DE;">
	<tr>
        <td style="width: 55px; padding-top: 13px;"><a
href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail"
target="_blank"><img
src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif"
width="46" height="29" style="width: 46px; height: 29px;" /></a></td>
		<td style="width: 470px; padding-top: 12px; color: #41424e;
font-size: 13px; font-family: Arial, Helvetica, sans-serif;
line-height: 18px;">Virus-free. <a
href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail"
target="_blank" style="color: #4453ea;">www.avast.com</a>
		</td>
	</tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1"
height="1"></a></div>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Capture.PNG
Type: image/png
Size: 65705 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview/attachments/20170422/0322d66d/attachment.png>


More information about the ParaView mailing list