CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Visualization & Post-Processing Software > ParaView

[General] Slice origin as annotation in animation

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By wyldckat

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 20, 2013, 05:47
Question Slice origin as annotation in animation
  #1
New Member
 
Pia Jensen
Join Date: Jul 2013
Location: Denmark
Posts: 3
Rep Power: 13
bozack is on a distinguished road
I am making an animation where I vary the origin of a slice through my gaussian cube data, and would like to have an annotation of what value the X-coordinate of the slice origin is, for each frame.

I have tried using the Python Annotation Filter, but I simply cannot figure out how to get to the slice origin value.

My first guess was something like
Code:
"Slice origin in X = %f" % (XSlicesOrigin[0])
but this does not work at all. How should I do it?
bozack is offline   Reply With Quote

Old   July 21, 2013, 13:07
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings Pia and welcome to the forum!

How exactly are you varying the slice? Because it might be possible to generate the annotation directly in the code where you're doing the slice movement.

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   July 21, 2013, 18:38
Default
  #3
New Member
 
Pia Jensen
Join Date: Jul 2013
Location: Denmark
Posts: 3
Rep Power: 13
bozack is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
How exactly are you varying the slice? Because it might be possible to generate the annotation directly in the code where you're doing the slice.
I'm working in the ParaView GUI (I didn't know that you could get to the code behind that?). I use the animation view and simply choose the slice in the dropdown menu, and afterwards the origin value, and interpolate its value along with the time in the animation.
bozack is offline   Reply With Quote

Old   August 12, 2013, 06:44
Default bump
  #4
New Member
 
Pia Jensen
Join Date: Jul 2013
Location: Denmark
Posts: 3
Rep Power: 13
bozack is on a distinguished road
I'm just bumping this thread again, in the hope that someone can help me?
bozack is offline   Reply With Quote

Old   August 16, 2013, 19:10
Default
  #5
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Pia,

Sorry, but I've been busy for the past few weeks and didn't manage to look into this until now.

And I've been playing around with ParaView 3.98.0 for the past 2 hours or so and the only solution I could manage to figure out was as follows:
  1. Prepare your post-processing case on ParaView 3.98.0 or newer, including an instance of the "Slice" filter and of the "Python Annotation" filter.
  2. Place the following code inside a python script file, e.g. "syncAnnotation.py":
    Code:
    try: paraview.simple
    except: from paraview.simple import *
    paraview.simple._DisableFirstRenderCameraReset()
    
    Slice1 = FindSource("Slice1")
    PythonAnnotation1 = FindSource("PythonAnnotation1")
    PythonAnnotation1.Expression = "'Slice origin in X = %f' % " + str(Slice1.SliceOffsetValues[0])
    
    Render()
    Adjust the names "Slice1" and "PythonAnnotation1" accordingly to your existing session. And also adapt the code for "PythonAnnotation1.Expression" to your liking; since it's based on your first post, it should be easy for you to understand what the code does.
  3. On the menu, click on "Macros -> Add New Macro" and select the file "syncAnnotation.py".
  4. You should now have this macro on the menu "Macros", as well as a button named "synAnnotation" on the Macros toolbar (on/off in the menu "View -> Toolbars -> Macros Toolbars").
  5. Now, whenever you change the time instance, use this macro and it will update the python annotation accordingly.
Here are some of the references I used:
What I've tried:
  1. Tried using a "programmable source" to run the contents of this script, but for some reason it won't reach the currently open session.
  2. Tried to use in the expression of the "Python Annotation" filter to use the following code:
    Code:
    paraview.servermanager.ProxyManager().GetProxy("sources", "Slice1").SliceOffsetValues[0]
    It's the absolute path to the following command:
    Code:
    FindSource("Slice1").SliceOffsetValues[0]
    But the first one fails for the same issue with not being able to connect to the session; and the second fails due to not having access to "paraview.simple" from these programmable filters and sources.
  3. Tried to write an XML proxy plugin, either source or filter, but the more I read the XML files, the more it looked like it would not work, due to how the proxies work. Perhaps I missed something, so here are the references for this idea:
  4. Due to the non-accessible session, I also tried to use a "programmable source" to open a new session, but the problem is that it would require a new session each time it changed the time snapshot... the code I had used was:
    Code:
    from paraview import servermanager
    
    servermanager.Connect('localhost',11111)
    servermanager.ProxyManager().GetProxy("sources", "Slice1").SliceOffsetValues[0]
    Although this required pvserver to have been executed first on another terminal. But this failed because only one session may be connected to a server, which leads to a crash the second time it tries to connect.
  5. Tried to use "--multi-clients" with pvserver, but it would lock up ParaView when I used the code from the attempt #4.


Best regards,
Bruno
akidess likes this.
__________________

Last edited by wyldckat; August 16, 2013 at 19:24. Reason: added attempt #4 and #5
wyldckat is offline   Reply With Quote

Old   January 10, 2017, 11:29
Default
  #6
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30
akidess will become famous soon enough
If you want to modify the origin instead of the offset the code is:

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

Slice1 = FindSource("Slice1")
PythonAnnotation1 = FindSource("PythonAnnotation1")
PythonAnnotation1.Expression = "'Slice origin in X = %f' % " + str(Slice1.SliceType.Origin[0])

Render()
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
akidess is offline   Reply With Quote

Old   July 27, 2018, 05:37
Default
  #7
New Member
 
Christian Jähnel
Join Date: Nov 2016
Posts: 11
Rep Power: 10
ch_jaehnel is on a distinguished road
I know this thread is quit old, but maybe one of you could help me. I initialised this macro, it all worked fine.



But is there a possibility to syncronise the macro while exporting an animation? Yet I would need to click on the macro for every new timestep, which should go automaticly by skipping the timestep.


Thank you for your help!
ch_jaehnel is offline   Reply With Quote

Reply

Tags
annotate, paraview


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to set periodic boundary conditions Ganesh FLUENT 15 November 18, 2020 07:09
Animation Sweep Plane not displaying correctly u2berggeist FLUENT 1 August 26, 2018 21:51
[General] Rotation of a slice beral ParaView 3 January 16, 2018 07:01
Equation for a rotating circle outside the origin mali28 Main CFD Forum 0 November 14, 2014 07:38
[OpenFOAM] ParaFoam: Slice Animation Nucleophobe ParaView 2 August 5, 2012 17:51


All times are GMT -4. The time now is 10:50.