[Paraview] pv python scripting (UNCLASSIFIED)

Su, Simon M CTR USAF (US) simon.m.su.ctr at mail.mil
Fri Apr 18 15:47:04 EDT 2014


Classification: UNCLASSIFIED
Caveats: NONE

Hello,

Say if I want to get the value of a variable in the data loaded,

>>> reader = GetActiveSource()
>>> reader.ElementVariables
[]
>>> reader.PointData
<paraview.servermanager.FieldDataInformation object at 0x00000000197746A0>
>>> reader.PointVariables
['DISPL', 'VEL']
>>> reader.PointVariables[0]
'DISPL'
>>> reader.PointVariables.Available
['DISPL', 'VEL', 'ACCL']
>>> reader.PointVariables.GetData
<bound method ArrayListProperty.GetData of ['DISPL', 'VEL']>
>>> reader.PointVariables.GetData['DISPL']
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: 'instancemethod' object has no attribute '__getitem__'
>>> reader.PointVariables.GetData(DISPL)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
NameError: name 'DISPL' is not defined
>>> reader.PointVariables.GetData
<bound method ArrayListProperty.GetData of ['DISPL', 'VEL']>
>>>


What is the syntax to get the actual value of the variable, say variable 
DISPL?

Thanks
-simon

-----Original Message-----
From: Casey Goodlett [mailto:casey.goodlett at kitware.com]
Sent: Friday, April 18, 2014 12:37 PM
To: Su, Simon M CTR USAF (US)
Cc: paraview at paraview.org
Subject: Re: [Paraview] pv python scripting

Simon,


Selecting the reader in the pipeline browser and calling GetActiveSource() in 
the python shell should return a reference to the reader.



On Fri, Apr 18, 2014 at 11:39 AM, Su, Simon M CTR USAF (US) 
<simon.m.su.ctr at mail.mil> wrote:


	Hello,

	http://paraview.org/Wiki/ParaView/Python_Scripting has the example on how to 
list the variables in a dataset.

	=============

	>>> reader = ExodusIIReader(FileName='.../can.ex2')
	# These variables are currently selected
	>>> reader.PointVariables
	['DISPL', 'VEL', 'ACCL']
	# These are available in the file
	>>> reader.PointVariables.Available
	['DISPL', 'VEL', 'ACCL']
	# Enable the DISPL array only
	>>> reader.PointVariables = ['DISPL']
	# Force read
	>>> reader.UpdatePipeline()
	# Now check the output. Note: GlobalNodeId is generated automatically by the 
reader.
	>>> reader.PointData[:]
	[Array: GlobalNodeId, Array: PedigreeNodeId, Array: DISPL]
	====================


	If I am doing this in ParaView GUI and I load the can.ex2 data manually and 
then use Tools->Python Shell to get to python, how do I get a list of the 
variable? Who would be the parent of PointVariables.Available? 
<????>.PointVariables.Available ?

	thanks
	-simon




	_______________________________________________
	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






-- 

Casey B. Goodlett, Ph.D.
Technical Leader
Kitware, Inc. - North Carolina Office
http://www.kitware.com
(919) 969-6990 x310

Classification: UNCLASSIFIED
Caveats: NONE


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5633 bytes
Desc: not available
URL: <http://www.paraview.org/pipermail/paraview/attachments/20140418/385aa270/attachment.bin>


More information about the ParaView mailing list