[Paraview] How to export .x3d files from python script?

Cook, Rich cook47 at llnl.gov
Thu Oct 31 19:30:38 EDT 2013


Problem solved.  There appears to be a bug in the generated output from the "record script" option.

Instead of
try: paraview.simple
except: from paraview.simple import *

the generated code should be
try: paraview.simple.something_in-paraview.simple
except: from paraview.simple import *


On Oct 31, 2013, at 2:45 PM, "Cook, Rich" <cook47 at llnl.gov<mailto:cook47 at llnl.gov>> wrote:

Note:  This is with a client-server setup, data on a linux cluster, rendering on my desktop.  :-)

On Oct 31, 2013, at 2:07 PM, "Cook, Rich" <cook47 at llnl.gov<mailto:cook47 at llnl.gov>>
 wrote:

If you're confused, imagine how I feel!  I had not considered the "magic command" theory.  LOL

There are a bunch of things going on here, so perhaps I just need to try to keep things simple.
I simply tried the command that you gave me and the viewport turned green.

So I exited Paraview and tried to start over.  I connected to the remote server and tried to run all the commands in my stack trace.  How can I do this?  When I open the Python Shell window and just paste commands into it, only the first command is executed.  Do I have paste each line in separately and hit Enter after each one?  That's a major PITA.

I tried clicking "Run Script" and opened the script.  It gave me the error

>>> Traceback (most recent call last):
File "<string>", line 5, in <module>
NameError: name 'VisItMirandaReader' is not defined

This is presumably from the beginning of the script:
try: paraview.simple
except: from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()

plot_raw = VisItMirandaReader( FileName='/nfs/tmp2/rcook/miranda/IRM_512_r1/plot.raw' )

But if I just type these four lines into the Python Shell, they work fine.
Is there an easy way to do this?

My goal is to
1)  read a miranda file
2)  create an isosurface
3)  iterate through time and each timestep save out an x3d file

This seems like it should be simple, but I'm not getting it, probably because I just haven't got a clue how to start.  I figured the traceback would be the logical place to start, but I can't get Paraview to use its own output.

-- Rich

On Oct 31, 2013, at 11:13 AM, Sebastien Jourdain <sebastien.jourdain at kitware.com<mailto:sebastien.jourdain at kitware.com>>
 wrote:

Hum I'm getting confuse.

the RenderView2 was the name of the var in your stack trace.
It is not a magic command.

Seb


On Thu, Oct 31, 2013 at 10:27 AM, Cook, Rich <cook47 at llnl.gov<mailto:cook47 at llnl.gov>> wrote:
Oops, sorry about that.
So when I called
x3dExporter.SetView(RenderView2)
x3dExporter.Write()
the viewport turned green!
It looks like this means that the exporter's view is its output in some sense.
I need to plumb things up so the view goes into the exporter and out comes an x3dExporter.

On Oct 31, 2013, at 8:55 AM, "Cook, Rich" <cook47 at llnl.gov<mailto:cook47 at llnl.gov>>
 wrote:

>>> SetView(RenderView2)
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'SetView' is not defined

On Oct 30, 2013, at 11:33 PM, Sebastien Jourdain <sebastien.jourdain at kitware.com<mailto:sebastien.jourdain at kitware.com>>
 wrote:

Hi Rich,

Maybe the active view is not the one that has your rendering.
You may need to call SetView(RenderView2).

Seb



On Wed, Oct 30, 2013 at 6:41 PM, Cook, Rich <cook47 at llnl.gov<mailto:cook47 at llnl.gov>> wrote:
Arrgh!
I tried the following and the resulting file did not contain my isosurface as created by the below script.  What am I doing wrong here?  Sorry for the stream-of-consciousness posts here…

>>> exporters=servermanager.createModule("exporters")

>>> x3dExporter=exporters.X3DExporter(FileName="test.x3d")
>>> view = GetActiveView()

>>> x3dExporter.SetView(view) # <===== NEW LINE

>>> x3dExporter.Write()


On Oct 30, 2013, at 5:14 PM, "Cook, Rich" <cook47 at llnl.gov<mailto:cook47 at llnl.gov>>
 wrote:

… and immediately got the answer from google:  http://www.paraview.org/pipermail/paraview/2012-May/024921.html

However, I'm still curious as to how the person in question discovered how to do it.  Where is all the good python documentation/lore stored?  The wiki wasn't too helpful to me in that respect, i.e., as a reference, although it has a lot of good ideas/information.

-- Rich

On Oct 30, 2013, at 5:05 PM, "Cook, Rich" <cook47 at llnl.gov<mailto:cook47 at llnl.gov>>
 wrote:

I recorded a script to try to understand how to export a time series of an isosurface as .x3d files so I can muck with them using blender.  But when I look at the script, the crucial bit of exporting the .x3d did not get captured.  Is that part not scriptable?  How can I go about finding out for myself which file formats can be exported from python scripts, if any?
Thanks

Here is the script that got captured:

try: paraview.simple
except: from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()

plot_raw = VisItMirandaReader( FileName='/nfs/tmp2/rcook/miranda/IRM_512_r1/plot.raw' )

AnimationScene2 = GetAnimationScene()
AnimationScene1 = GetAnimationScene()
plot_raw.CellArrays = []
plot_raw.Materials = []
plot_raw.Meshes = ['mesh']
plot_raw.PointArrays = []

AnimationScene2.EndTime = 110.0
AnimationScene2.PlayMode = 'Snap To TimeSteps'

AnimationScene1.EndTime = 110.0
AnimationScene1.PlayMode = 'Snap To TimeSteps'

RenderView2 = GetRenderView()
DataRepresentation4 = Show()
DataRepresentation4.Representation = 'Outline'
DataRepresentation4.ScaleFactor = 51.200000000000003
DataRepresentation4.EdgeColor = [0.0, 0.0, 0.50000762951094835]
DataRepresentation4.SelectionCellFieldDataArrayName = 'density'

plot_raw.CellArrays = ['density']

CellDatatoPointData2 = CellDatatoPointData()

RenderView2.CameraFocalPoint = [255.5, 255.5, -0.5]
RenderView2.CameraClippingRange = [829.67380753909174, 2829.4767488865327]
RenderView2.CameraPosition = [-979.92119013571846, 1113.4340644820502, -820.67547187352602]

DataRepresentation5 = Show()
DataRepresentation5.EdgeColor = [0.0, 0.0, 0.50000762951094835]
DataRepresentation5.SelectionPointFieldDataArrayName = 'density'
DataRepresentation5.SelectionCellFieldDataArrayName = 'density'
DataRepresentation5.Representation = 'Outline'
DataRepresentation5.ScaleFactor = 51.200000000000003

DataRepresentation4.Visibility = 0

Contour2 = Contour( PointMergeMethod="Uniform Binning" )

Contour2.PointMergeMethod = "Uniform Binning"
Contour2.ContourBy = ['POINTS', 'density']
Contour2.Isosurfaces = [2.0]

DataRepresentation6 = Show()
DataRepresentation6.ScaleFactor = 51.200000000000003
DataRepresentation6.EdgeColor = [0.0, 0.0, 0.50000762951094835]
DataRepresentation6.SelectionPointFieldDataArrayName = 'Normals'
DataRepresentation6.SelectionCellFieldDataArrayName = 'density'

AnimationScene2.AnimationTime = 10.0

RenderView2.CameraViewUp = [-0.80853642549145055, -0.58010037415785698, 0.098754263479722132]
RenderView2.CacheKey = 10.0
RenderView2.CameraPosition = [402.40688029765732, -227.93136313665994, -1637.4840153022406]
RenderView2.CameraClippingRange = [1504.1196765479444, 1981.483268233957]
RenderView2.ViewTime = 10.0
RenderView2.RemoteRenderThreshold = 2.0
RenderView2.UseCache = 0
RenderView2.CameraFocalPoint = [255.5, 255.49999999999989, -0.49999999999999883]

Render()

--
✐Richard Cook
✇ Lawrence Livermore National Laboratory
Bldg-453 Rm-4024, Mail Stop L-557
7000 East Avenue,  Livermore, CA, 94550, USA
☎ (office) (925) 423-9605<tel:%28925%29%20423-9605>
☎ (fax) (925) 423-6961<tel:%28925%29%20423-6961>
---
Information Management & Graphics Grp., Services & Development Div., Integrated Computing & Communications Dept.
(opinions expressed herein are mine and not those of LLNL)




--
✐Richard Cook
✇ Lawrence Livermore National Laboratory
Bldg-453 Rm-4024, Mail Stop L-557
7000 East Avenue,  Livermore, CA, 94550, USA
☎ (office) (925) 423-9605<tel:%28925%29%20423-9605>
☎ (fax) (925) 423-6961<tel:%28925%29%20423-6961>
---
Information Management & Graphics Grp., Services & Development Div., Integrated Computing & Communications Dept.
(opinions expressed herein are mine and not those of LLNL)




--
✐Richard Cook
✇ Lawrence Livermore National Laboratory
Bldg-453 Rm-4024, Mail Stop L-557
7000 East Avenue,  Livermore, CA, 94550, USA
☎ (office) (925) 423-9605<tel:%28925%29%20423-9605>
☎ (fax) (925) 423-6961<tel:%28925%29%20423-6961>
---
Information Management & Graphics Grp., Services & Development Div., Integrated Computing & Communications Dept.
(opinions expressed herein are mine and not those of LLNL)




_______________________________________________
Powered by www.kitware.com<http://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



--
✐Richard Cook
✇ Lawrence Livermore National Laboratory
Bldg-453 Rm-4024, Mail Stop L-557
7000 East Avenue,  Livermore, CA, 94550, USA
☎ (office) (925) 423-9605<tel:%28925%29%20423-9605>
☎ (fax) (925) 423-6961<tel:%28925%29%20423-6961>
---
Information Management & Graphics Grp., Services & Development Div., Integrated Computing & Communications Dept.
(opinions expressed herein are mine and not those of LLNL)




--
✐Richard Cook
✇ Lawrence Livermore National Laboratory
Bldg-453 Rm-4024, Mail Stop L-557
7000 East Avenue,  Livermore, CA, 94550, USA
☎ (office) (925) 423-9605<tel:%28925%29%20423-9605>
☎ (fax) (925) 423-6961<tel:%28925%29%20423-6961>
---
Information Management & Graphics Grp., Services & Development Div., Integrated Computing & Communications Dept.
(opinions expressed herein are mine and not those of LLNL)





--
✐Richard Cook
✇ Lawrence Livermore National Laboratory
Bldg-453 Rm-4024, Mail Stop L-557
7000 East Avenue,  Livermore, CA, 94550, USA
☎ (office) (925) 423-9605
☎ (fax) (925) 423-6961
---
Information Management & Graphics Grp., Services & Development Div., Integrated Computing & Communications Dept.
(opinions expressed herein are mine and not those of LLNL)




--
✐Richard Cook
✇ Lawrence Livermore National Laboratory
Bldg-453 Rm-4024, Mail Stop L-557
7000 East Avenue,  Livermore, CA, 94550, USA
☎ (office) (925) 423-9605
☎ (fax) (925) 423-6961
---
Information Management & Graphics Grp., Services & Development Div., Integrated Computing & Communications Dept.
(opinions expressed herein are mine and not those of LLNL)




--
✐Richard Cook
✇ Lawrence Livermore National Laboratory
Bldg-453 Rm-4024, Mail Stop L-557
7000 East Avenue,  Livermore, CA, 94550, USA
☎ (office) (925) 423-9605
☎ (fax) (925) 423-6961
---
Information Management & Graphics Grp., Services & Development Div., Integrated Computing & Communications Dept.
(opinions expressed herein are mine and not those of LLNL)



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20131031/b93652bf/attachment-0001.htm>


More information about the ParaView mailing list