[Paraview] Mimicking the 'set view plane direction' GUI buttons in Python script

Adriano Gagliardi agagliardi at ara.co.uk
Thu Jul 9 04:50:05 EDT 2009


Thanks for that. I'll give it a try today. I've executed the script using
the built python shell and what appears to be happening is my screen appears
as I'd like it, then almost immediately it resets itself to a standard view.
Here are the last few lines of my script:

//======================================
##set camera
cam = GetActiveCamera()

cam.SetFocalPoint( (point1[0]+point2[0])/2.0, (point1[1]+point2[1])/2.0,
point1[2])
foc = cam.GetFocalPoint()
print foc

cam.SetPosition(point1[0]*-50, foc[1], foc[2])
print cam.GetPosition()

cam.SetViewUp(0,0,1)

print cam.GetViewUp()
print cam.GetViewPlaneNormal()

cam.Zoom(10)

Render()
//=======================================

Is it possible Render() calls ResetCamera()? 

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

Adriano Gagliardi MEng PhD
Project Scientist
Computational Aerodynamics
Aircraft Research Association Ltd.
Manton Lane
Bedford

Tel: 01234 32 4644
E-mail: agagliardi at ara.co.uk
Url: www.ara.co.uk 
-----Original Message-----
From: pat marion [mailto:pat.marion at kitware.com] 
Sent: 08 July 2009 16:08
To: agagliardi at ara.co.uk
Cc: paraview at paraview.org
Subject: Re: [Paraview] Mimicking the 'set view plane direction' GUI buttons
in Python script

I'm not quite sure this is available in 3.5, but there is a new way to set
camera properties.  Instead of setting them on the camera, try setting them
on the view:

view = GetActiveView()
view.CameraPosition = [-15, 10, 0]
view.CameraFocalPoint = [0, 10, 0]
view.CameraViewUp = [0 ,0, 1]

All settable properties for the view can be printed:

for p in view.ListProperties():
    if not view.GetProperty(p).GetInformationOnly(): print p

Pat

On Wed, Jul 8, 2009 at 7:07 AM, Adriano Gagliardi<agagliardi at ara.co.uk>
wrote:
> I am trying to write a simple few lines of Python code to mimick the 
> view plane direction buttons available in the GUI, but I'm finding 
> some of the commands don't seem to accept my input. The version of 
> Paraview is 3.5.0 and I'm using paraview.simple. For example:
>
> cam = GetActiveCamera()
>
> cam.SetPosition(-15,10,0) #works
> cam.GetPosition()               #works ( -15.0, 10.0, 0.0)
> Render()
>
> cam.SetFocalPoint(0,10,0)       #works
> cam.GetFocalPoint()             #works ( 0.0, 10.0, 0.0)
> Render()
>
> cam.GetViewUp()
> (0.0, 1.0, 0.0)
> cam.SetViewUp(0,0,1)    #error
> Traceback (most recent call last):
>  File "<console>", line 1, in ?
> TypeError: 'list' object is not callable cam.SetViewUp = (0,0,1) 
> #appears to have accepted it
> cam.GetViewUp()
> (0.0, 1.0, 0.0)         #does not update the view
>
> Do I need to update to the latest dev version to get this working? It 
> appears to work fine with the old Paraview-python API.
>
> ===================================
>
> Adriano Gagliardi MEng PhD
> Project Scientist
> Computational Aerodynamics
> Aircraft Research Association Ltd.
> Manton Lane
> Bedford
>
> Tel: 01234 32 4644
> E-mail: agagliardi at ara.co.uk
> Url: www.ara.co.uk
>
>
> ---------------------------
> This email contains information that is private and confidential and is
intended only for the addressee.  If you are not the intended recipient
please delete it and notify us immediately by e-mailing the sender.
> Note: All email sent to or from this address may be accessed by someone
other than the recipient, for system management and security reasons.
> Aircraft Research Association Ltd.  Registered in England, 
> Registration No 503668 Registered Office: Manton Lane, Bedford MK41 
> 7PF England VAT No GB 196351245
>
>
> _______________________________________________
> 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
>


---------------------------
This email contains information that is private and confidential and is intended only for the addressee.  If you are not the intended recipient please delete it and notify us immediately by e-mailing the sender.
Note: All email sent to or from this address may be accessed by someone other than the recipient, for system management and security reasons.
Aircraft Research Association Ltd.  Registered in England, Registration No 503668 Registered Office: Manton Lane, Bedford MK41 7PF England VAT No GB 196351245




More information about the ParaView mailing list