[Paraview] Writing IntegrateAttributes to CSV using Python

bart.boonacker at actiflow.com bart.boonacker at actiflow.com
Fri Apr 10 09:34:12 EDT 2009


I tried that as well, still no luck :(

On Fri, 10 Apr 2009 09:21:22 -0400, Utkarsh Ayachit
<utkarsh.ayachit at kitware.com> wrote:
> Can you just try running the paraview from the build directory itself?
> I wouldn't think installation should have anything to do with it, but
> maybe I am wrong.
> 
> Utkarsh
> 
> On Fri, Apr 10, 2009 at 9:19 AM,  <bart.boonacker at actiflow.com> wrote:
>> yes, I did.
>>
>>
>>
>> On Fri, 10 Apr 2009 08:25:44 -0400, Utkarsh Ayachit
>> <utkarsh.ayachit at kitware.com> wrote:
>>> Out of curiosity, did you do a "make install" and are you running from
>>> the installed version of ParaView? If so, just to confirm, you redid
>>> the make install after building, right?
>>>
>>> Utkarsh
>>>
>>> On Fri, Apr 10, 2009 at 4:30 AM,  <bart.boonacker at actiflow.com> wrote:
>>>> Good morning Utkarsh,
>>>>
>>>> Here's the data replied by the import sys and print sys.path
>>>> It shows no old versions. I also included the filters with
>>>> dir(servermanager.filters)
>>>>
>>>> Python 2.5.1 (r251:54863, Dec  6 2008, 10:49:39)
>>>> [GCC 4.2.1 (SUSE Linux)] on linux2
>>>>>>> from paraview.simple import *
>>>>>>> import sys
>>>>>>> print sys.path
>>>> ['/home/bart/bin/lib/paraview-3.5', '/usr/lib/python25.zip',
>>>> '/usr/lib64/python2.5', '/usr/lib64/python2.5/plat-linux2',
>>>> '/usr/lib64/python2.5/lib-tk', '/usr/lib64/python2.5/lib-dynload',
>>>> '/usr/lib64/python2.5/site-packages']
>>>>>>> dir(servermanager.filters)
>>>> ['AlltoN', 'AnnotateTime', 'AppendAttributes', 'AppendDatasets',
>>>> 'AppendGeometry', 'Balance', 'BlockScalars', 'CacheKeeper',
>> 'Calculator',
>>>> 'CellCenters', 'CellDatatoPointData', 'Clean', 'CleantoGrid',
>>>> 'ClientServerMoveData', 'Clip', 'Clip(GenericDatasets)',
>>>> 'ComputeDerivatives', 'Connectivity', 'Contour',
>>>> 'Contour(GenericDatasets)', 'ConvertSelection', 'Crop', 'Curvature',
>>>> 'D3',
>>>> 'Decimate', 'Delaunay2D', 'Delaunay3D', 'Elevation',
>> 'ExtractAttributes',
>>>> 'ExtractBlock', 'ExtractCTHFragments', 'ExtractCTHParts',
>>>> 'ExtractCellsbyRegion', 'ExtractDatasets', 'ExtractEdges',
>>>> 'ExtractLevel',
>>>> 'ExtractSelection', 'ExtractSelection(internal)', 'ExtractSubset',
>>>> 'ExtractSurface', 'ExtractSurface(GenericDatasets)',
>>>> 'FFTofSelectionOverTime', 'FeatureEdges', 'GenerateIds',
>>>> 'GenerateQuadraturePoints', 'GenerateQuadratureSchemeDictionary',
>>>> 'GenerateSurfaceNormals', 'GeometryFilter', 'Glyph',
>>>> 'Glyph(CustomSource)',
>>>> 'Gradient', 'Gradient(Unstructured)', 'GradientMagnitude',
>>>> 'GroupDatasets',
>>>> 'Histogram', 'ImageShrink', 'IntegrateVariables',
>>>> 'InterpolatetoQuadraturePoints', 'IntersectCTHFragments',
>> 'LevelScalars',
>>>> 'LinearExtrusion', 'LoopSubdivision', 'MPIMoveData', 'MaskPoints',
>>>> 'Median', 'MergeBlocks', 'MeshQuality', 'MinMax', 'NormalGlyphs',
>>>> 'OctreeDepthLimit', 'OctreeDepthScalars',
>>>> 'OrderedCompositeDistributor',
>>>> 'Outline', 'Outline(GenericDataSets)', 'Outline(curvilinear)',
>>>> 'OutlineCorners', 'ParticlePathlines', 'ParticleTracer',
>>>> 'PlotGlobalVariablesoverTime', 'PlotOverLine',
'PlotSelectionOverTime',
>>>> 'PointDatatoCellData', 'PolylinetoRectilinearGrid', 'ProbeLocation',
>>>> 'ProcessIdScalars', 'ProgrammableFilter', 'PythonCalculator',
>>>> 'QuadraturePointStatistics', 'QuadricClustering', 'RandomVectors',
>>>> 'RectilinearGridGeometryFilter', 'ReductionFilter', 'Reflect',
>>>> 'ResampleWithDataset', 'Ribbon', 'RotationalExtrusion', 'ScatterPlot',
>>>> 'Shrink', 'Slice', 'Slice(GenericDatasets)', 'Smooth', 'StreamTracer',
>>>> 'StreamTracer(CustomSource)', 'StreamTracer(GenericDatasets)',
>>>> 'Subdivide',
>>>> 'SurfaceFlow', 'SurfaceVectors', 'TableFFT', 'TableToPoints',
>>>> 'TableToStructuredGrid', 'TemporalCache', 'TemporalInterpolator',
>>>> 'TemporalShiftScale', 'TemporalSnaptoTimeStep', 'TemporalStatistics',
>>>> 'Tessellate', 'Tessellator(GenericDatasets)', 'Tetrahedralize',
>>>> 'TextureMaptoCylinder', 'TextureMaptoPlane', 'TextureMaptoSphere',
>>>> 'Threshold', 'Transform', 'TriangleStrips', 'Triangulate', 'Tube',
>>>> 'UpdateSuppressor2', 'Warp(scalar)', 'Warp(vector)', '__class__',
>>>> '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__',
>>>> '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__',
>>>> '__repr__', '__setattr__', '__str__',
>>>>
>>>> Still, a lot of thanks for helping, would love to see it working in a
>>>> while
>>>> :)
>>>>
>>>> Bart
>>>>
>>>> On Thu, 9 Apr 2009 11:04:49 -0400, Utkarsh Ayachit
>>>> <utkarsh.ayachit at kitware.com> wrote:
>>>>> Bart,
>>>>>
>>>>> Make sure your paraview is built as correctly. Then
>>>>> import sys
>>>>> print sys.path
>>>>>
>>>>> Ensure that the path does not include any old version of paraview
>>>>> libraries. If it does then you are ending up import old versions.
>>>>>
>>>>> Utkarsh
>>>>>
>>>>> On Thu, Apr 9, 2009 at 10:27 AM,  <bart.boonacker at actiflow.com>
>>>>> wrote:
>>>>>> hey Utkarsh,
>>>>>>
>>>>>> I'm sorry that my writing was a bit unclear, but I said that I can
>> find
>>>>>> the
>>>>>> .cxx and .h files, but I can't find them in the dir(servermanager)
>>>>>> and
>>>>>> dir(servermanager.filters).
>>>>>>
>>>>>> The dataStamp.cmake contains this, (today indeed):
>>>>>>
>>>>>> # Do not edit!  Generated by kwsysDateStamp.py
>>>>>>
>>>>>> # KWSys version date year component.  Format is CCYY.
>>>>>> SET(KWSYS_DATE_STAMP_YEAR  2009)
>>>>>>
>>>>>> # KWSys version date month component.  Format is MM.
>>>>>> SET(KWSYS_DATE_STAMP_MONTH 04)
>>>>>>
>>>>>> # KWSys version date day component.  Format is DD.
>>>>>> SET(KWSYS_DATE_STAMP_DAY   09)
>>>>>>
>>>>>>
>>>>>> Bart
>>>>>>
>>>>>>
>>>>>> On Thu, 9 Apr 2009 10:16:19 -0400, Utkarsh Ayachit
>>>>>> <utkarsh.ayachit at kitware.com> wrote:
>>>>>>> If there's no Servers/Filters/vtkAttributeDataToTableFilter.h and
>>>>>>> Servers/Filters/vtkAttributeDataToTableFilter.cxx then I am
guessing
>>>>>>> you are not updating correctly. There may be some sticky tags set
>> with
>>>>>>> your CVS checkout. Can you look at
>>>>>>> ParaView3/VTK/Utilities/kwsys/kwsysDataStamp.cmake and verify that
>> the
>>>>>>> date mentioned is indeed today's?
>>>>>>>
>>>>>>> Utkarsh
>>>>>>>
>>>>>>> On Thu, Apr 9, 2009 at 9:39 AM,  <bart.boonacker at actiflow.com>
>>>>>>> wrote:
>>>>>>>> Hello again,
>>>>>>>>
>>>>>>>> I did ran it from the python shell, so that problem is fixed.
>>>>>>>> I just updated the CVS and built the update, but still not
>>>>>>>> AttributeDataToTableFilter :(
>>>>>>>> not in dir(servermanager.filters) nor in dir(servermanager)
>>>>>>>>
>>>>>>>> When looking for files I can find the
>>>> vtkAttributeDataToTableFilter.cxx
>>>>>>>> and
>>>>>>>> .h but this is not available as well.
>>>>>>>>
>>>>>>>> Bart
>>>>>>>>
>>>>>>>>
>>>>>>>> On Thu, 9 Apr 2009 09:21:14 -0400, Utkarsh Ayachit
>>>>>>>> <utkarsh.ayachit at kitware.com> wrote:
>>>>>>>>> Oh, are you running the script through the python shell in the
>>>>>>>>> ParaView client? In that case, sorry, but you don't need the
>>>> Connect()
>>>>>>>>> :). I assumed you were using pvpython.
>>>>>>>>>
>>>>>>>>> Are you sure you built your paraview after updating? I just tried
>>>>>>>>> the
>>>>>>>>> CVS and I indeed have the AttributeDataToTableFilter.
>>>>>>>>>
>>>>>>>>> Utkarsh
>>>>>>>>>
>>>>>>>>> On Thu, Apr 9, 2009 at 9:18 AM,  <bart.boonacker at actiflow.com>
>>>>>>>>> wrote:
>>>>>>>>>> Ok, than that should be the problem I guess;
>>>>>>>>>>
>>>>>>>>>> Here's my "full" script, almost the same as provided before:
>>>>>>>>>>
>>>>>>>>>> from paraview import servermanager as sm
>>>>>>>>>> sm.Connect()
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
###############################################################################################
>>>>>>>>>> # create implicit device to populate Slice
>>>>>>>>>> impPlane =
>>>>>>>>>>
sm.implicit_functions.Plane(registrationGroup='implicit_fuctions')
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
###############################################################################################
>>>>>>>>>>
>>>>>>>>>> caseName = 'Case'
>>>>>>>>>> caseLocation = '/home/bart/Desktop/Test_Python/'
>>>>>>>>>> showScalarBar = 2 #0=none, 1=vertical, 2=horizontal
>>>>>>>>>>
>>>>>>>>>> #read data
>>>>>>>>>> VTKreader01 =
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
sm.sources.LegacyVTKreader(FileNames='/home/bart/Desktop/Test_Python/1/VTK/1_1000.vtk',registrationGroup='sources',registrationName='RR')
>>>>>>>>>>
>>>>>>>>>> Slice_in =
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
sm.filters.Slice(registrationGroup='sources',registrationName='slice02',Input=VTKreader01)
>>>>>>>>>> Slice_inprop = Slice_in.GetProperty('CutFunction')
>>>>>>>>>> domainSlice_in = Slice_inprop.GetDomain('proxy_list')
>>>>>>>>>> domainSlice_in.AddProxy(impPlane.SMProxy)
>>>>>>>>>>
>>>>>>>>>> cutplane_in = impPlane
>>>>>>>>>> cutplane_in.Normal = [0, 1, 0]
>>>>>>>>>> cutplane_in.Offset = 0
>>>>>>>>>> cutplane_in.Origin = [0, 0, 0]
>>>>>>>>>> Slice_in.SliceType= cutplane_in
>>>>>>>>>>
>>>>>>>>>> Calculator01 =
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
sm.filters.Calculator(registrationGroup='sources',registrationName='calculator',Input=Slice_in)
>>>>>>>>>> Calculator01.ResultArrayName = 'Pt'
>>>>>>>>>> Calculator01.Function = '1.225*p+0.5*1.225*mag(U)^2'
>>>>>>>>>> Calculator01.AttributeMode = 1 # 1=pointdata,2=celldata
>>>>>>>>>> Calculator01.VectorVariable = ['U','U','0','1','2']
>>>>>>>>>> Calculator01.ScalarVariable =
>>>>>>>>>> ['p','p','0','U_0','U','0','U_1','U','1','U_2','U','2']
>>>>>>>>>>
>>>>>>>>>> filter1 =
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
sm.filters.IntegrateVariables(registrationGroup='sources',registrationName='Integrator',Input=Calculator01)
>>>>>>>>>>
>>>>>>>>>> ## AttributeDataToTableFilter converts any dataset to a vtkTable
>>>>>>>>>> which
>>>>>>>>>> can
>>>>>>>>>> be
>>>>>>>>>> ## written as a CSV file. One needs to choose which attribute to
>>>> save
>>>>>>>>>> as
>>>>>>>>>> well.
>>>>>>>>>> ## First save points.
>>>>>>>>>> convertor =
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
sm.filters.AttributeDataToTableFilter(Input=filter1,FieldAssociation="Points",AddMetaData=1)
>>>>>>>>>> csvWriter = sm.writers.CSVWriter(Input=convertor)
>>>>>>>>>> csvWriter.FileName =
>>>>>> "/home/bart/Desktop/Test_Python/output.points.csv"
>>>>>>>>>>
>>>>>>>>>> ## this writes the output.
>>>>>>>>>> csvWriter.UpdatePipeline()
>>>>>>>>>>
>>>>>>>>>> ### Now save cells.
>>>>>>>>>> convertor.FieldAssociation="Cells"
>>>>>>>>>> csvWriter = sm.writers.CSVWriter(Input=convertor)
>>>>>>>>>> csvWriter.FileName =
>>>>>>>>>> "/home/bart/Desktop/Test_Python/output.cells.csv"
>>>>>>>>>>
>>>>>>>>>> ### this writes the output.
>>>>>>>>>> csvWriter.UpdatePipeline()
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> when trying to Connect it gives:
>>>>>>>>>> Traceback (most recent call last):
>>>>>>>>>>  File "<string>", line 2, in <module>
>>>>>>>>>>  File
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
"/home/bart/ParaView3-bin/Utilities/VTKPythonWrapping/paraview/servermanager.py",
>>>>>>>>>> line 1861, in Connect
>>>>>>>>>>    raise RuntimeError, "Cannot create a connection through
>>>>>>>>>> python.
>>>>>>>>>> Use
>>>>>>>>>> the
>>>>>>>>>> GUI to setup the connection."
>>>>>>>>>> RuntimeError: Cannot create a connection through python. Use the
>>>>>>>>>> GUI
>>>>>> to
>>>>>>>>>> setup the connection.
>>>>>>>>>>
>>>>>>>>>> Bart
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Thu, 9 Apr 2009 09:13:58 -0400, Utkarsh Ayachit
>>>>>>>>>> <utkarsh.ayachit at kitware.com> wrote:
>>>>>>>>>>> Can you give your full script? If you are not calling Connect()
>> at
>>>>>>>>>>> all, it won't work since Connect() is required.
>>>>>>>>>>>
>>>>>>>>>>> Utkarsh
>>>>>>>>>>>
>>>>>>>>>>> On Thu, Apr 9, 2009 at 9:08 AM,  <bart.boonacker at actiflow.com>
>>>>>>>>>>> wrote:
>>>>>>>>>>>> Utkarsh,
>>>>>>>>>>>>
>>>>>>>>>>>> I used the CVS from yesterday but it returns :
>>>>>>>>>>>>      Traceback (most recent call last):
>>>>>>>>>>>>      File "<string>", line 41, in <module>
>>>>>>>>>>>>      AttributeError: 'PVModule' object has no attribute
>>>>>>>>>>>> 'AttributeDataToTableFilter'
>>>>>>>>>>>>
>>>>>>>>>>>> I have not used the following as the Connect part did not
work,
>>>>>>>> perhaps
>>>>>>>>>>>> thats the cause?
>>>>>>>>>>>> I replaced the sm by servermanager.
>>>>>>>>>>>>       from paraview import servermanager as sm
>>>>>>>>>>>>       sm.Connect()
>>>>>>>>>>>>
>>>>>>>>>>>> Bart
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Thu, 9 Apr 2009 08:55:25 -0400, Utkarsh Ayachit
>>>>>>>>>>>> <utkarsh.ayachit at kitware.com> wrote:
>>>>>>>>>>>>> Bart,
>>>>>>>>>>>>>
>>>>>>>>>>>>> Please cc the mailing list as well so other can use this
>>>>>> information
>>>>>>>>>>>>> as well as respond.
>>>>>>>>>>>>>
>>>>>>>>>>>>> I think one dubious statement I see in your code is:
>>>>>>>>>>>>> ## First save points.
>>>>>>>>>>>>> convertor =
>>>>>>>> sm.filters.AttributeDataToTableFilter(Input=filter1Output,
>>>>>>>>>>>>>   FieldAssociation="Points",
>>>>>>>>>>>>>   AddMetaData=1)
>>>>>>>>>>>>>
>>>>>>>>>>>>> You are setting the input to this filter be the data object
>>>>>> returned
>>>>>>>>>>>>> by using Fetch(). In ParaView python scripts the input to
>>>>>>>>>>>>> filters
>>>>>>>>>>>>> cannot be other data objects, but filters or sources. So, the
>>>>>> proper
>>>>>>>>>>>>> usage would be:
>>>>>>>>>>>>>
>>>>>>>>>>>>> convertor =
>> sm.filters.AttributeDataToTableFilter(Input=filter1,
>>>>>>>>>>>>>   FieldAssociation="Points",
>>>>>>>>>>>>>   AddMetaData=1)
>>>>>>>>>>>>>
>>>>>>>>>>>>> Does that solve the issue? Also creation of the
representation
>>>>>>>>>>>>> is
>>>>>>>>>>>>> not
>>>>>>>>>>>>> necessary unless you are rendering into a view, which doesn't
>>>> seem
>>>>>>>>>>>>> to
>>>>>>>>>>>>> be the case.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Utkarsh
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Thu, Apr 9, 2009 at 8:32 AM,
>>>>>>>>>>>>>  <bart.boonacker at actiflow.com>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>> Dear Utkarsh,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Thank you for your fast replies. I got the CVS version to
>> work,
>>>>>> but
>>>>>>>> I
>>>>>>>>>>>>>> am
>>>>>>>>>>>>>> still having some trouble to rewrite all the filters and
>>>>>> functions.
>>>>>>>>>>>>>> When running my code, see below, Paraview crashes and gives
a
>>>>>>>>>>>>>> Segmentation
>>>>>>>>>>>>>> Fault.
>>>>>>>>>>>>>> I am not a real programming expert, so I tried to neglect
the
>>>>>>>>>>>>>> representations of all filters. This removes the crash, but
>>>> still
>>>>>>>>>>>>>> posses
>>>>>>>>>>>>>> some problem with the code. The code was 1-to-1 copied from
>> the
>>>>>> 3.4
>>>>>>>>>>>>>> version, which probably causes the errors.
>>>>>>>>>>>>>> Is there a way or manual to see the new options and maybe
>>>>>>>> conversions
>>>>>>>>>>>>>> between 3.4 and the CVS version ?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Thanks in advance,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Bart
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Attached code ( I removed all representation code and view
>>>>>>>> settings):
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
###############################################################################################
>>>>>>>>>>>>>> # create implicit device to populate Slice
>>>>>>>>>>>>>> impPlane =
>>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
servermanager.implicit_functions.Plane(registrationGroup='implicit_fuctions')
>>>>>>>>>>>>>> impBox =
>>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
servermanager.implicit_functions.Box(registrationGroup='implicit_fuctions')
>>>>>>>>>>>>>> impSphere =
>>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
servermanager.implicit_functions.Sphere(registrationGroup='implicit_fuctions')
>>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
###############################################################################################
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> caseName = 'Case'
>>>>>>>>>>>>>> caseLocation = '/home/bart/Desktop/Test_Python/'
>>>>>>>>>>>>>> showScalarBar = 2 #0=none, 1=vertical, 2=horizontal
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> #read data
>>>>>>>>>>>>>> VTKreader01 =
>>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
servermanager.sources.LegacyVTKreader(FileNames='/home/bart/Desktop/Test_Python/1/VTK/1_1000.vtk',registrationGroup='sources',registrationName='RR')
>>>>>>>>>>>>>> #repVTKreader01 =
>>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
servermanager.CreateRepresentation(VTKreader01,view,registrationGroup='representations')
>>>>>>>>>>>>>> #repVTKreader01.Visibility = 0
>>>>>>>>>>>>>> #repVTKreader01.Representation = 3
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Slice02 =
>>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
servermanager.filters.Slice(registrationGroup='sources',registrationName='slice02',Input=VTKreader01)
>>>>>>>>>>>>>> cfSlice02 = Slice02.GetProperty('CutFunction')
>>>>>>>>>>>>>> domainSlice02 = cfSlice02.GetDomain('proxy_list')
>>>>>>>>>>>>>> domainSlice02.AddProxy(impPlane.SMProxy)
>>>>>>>>>>>>>> domainSlice02.AddProxy(impBox.SMProxy)
>>>>>>>>>>>>>> domainSlice02.AddProxy(impSphere.SMProxy)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> cutplane02 = impPlane
>>>>>>>>>>>>>> cutplane02.Normal = [0, 1, 0]
>>>>>>>>>>>>>> cutplane02.Offset = 0
>>>>>>>>>>>>>> cutplane02.Origin = [0, 0, 0]
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> #set cutplane
>>>>>>>>>>>>>> Slice02.CutFunction= cutplane02
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Calculator01 =
>>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
servermanager.filters.Calculator(registrationGroup='sources',registrationName='calculator',Input=Slice02)
>>>>>>>>>>>>>> Calculator01.ResultArrayName = 'Pt'
>>>>>>>>>>>>>> Calculator01.Function = '1.225*p+0.5*1.225*mag(U)^2'
>>>>>>>>>>>>>> Calculator01.AttributeMode = 1 # 1=pointdata,2=celldata
>>>>>>>>>>>>>> Calculator01.AddVectorVariable = ['U','U','0','1','2']
>>>>>>>>>>>>>> Calculator01.AddScalarVariable =
>>>>>>>>>>>>>> ['p','p','0','U_0','U','0','U_1','U','1','U_2','U','2']
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> filter1 =
>>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
servermanager.filters.IntegrateAttributes(registrationGroup='sources',registrationName='Integrator',Input=Calculator01)
>>>>>>>>>>>>>> filter1Output = servermanager.Fetch(filter1)
>>>>>>>>>>>>>> #repfilter1 =
>>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>
servermanager.CreateRepresentation(filter1,view,registrationGroup='representations')
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> # From Utkarsh Ayachit:
>>>>>>>>>>>>>> from paraview import servermanager as sm
>>>>>>>>>>>>>> sm.Connect()
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> ## AttributeDataToTableFilter converts any dataset to a
>>>>>>>>>>>>>> vtkTable
>>>>>>>>>>>>>> which
>>>>>>>>>>>>>> can
>>>>>>>>>>>>>> be
>>>>>>>>>>>>>> ## written as a CSV file. One needs to choose which
attribute
>>>>>>>>>>>>>> to
>>>>>>>> save
>>>>>>>>>>>>>> as
>>>>>>>>>>>>>> well.
>>>>>>>>>>>>>> ## First save points.
>>>>>>>>>>>>>> convertor =
>>>>>>>>>>>>>> sm.filters.AttributeDataToTableFilter(Input=filter1Output,
>>>>>>>>>>>>>> FieldAssociation="Points",
>>>>>>>>>>>>>> AddMetaData=1)
>>>>>>>>>>>>>> csvWriter = sm.writers.CSVWriter(Input=convertor)
>>>>>>>>>>>>>> csvWriter.FileName =
>>>>>>>>>>>>>> "/home/bart/Afstuderen/Straight_Auto/output.points.csv"
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> ## this writes the output.
>>>>>>>>>>>>>> csvWriter.UpdatePipeline()
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> ## Now save cells.
>>>>>>>>>>>>>> convertor.FieldAssociation="Cells"
>>>>>>>>>>>>>> csvWriter = sm.writers.CSVWriter(Input=convertor)
>>>>>>>>>>>>>> csvWriter.FileName =
>>>>>>>>>>>>>> "/home/bart/Afstuderen/Straight_Auto/output.cells.csv"
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> ## this writes the output.
>>>>>>>>>>>>>> csvWriter.UpdatePipeline()
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>
>>


More information about the ParaView mailing list