Author Topic: Jump to a specific frame  (Read 95 times)

armitatz

  • Newbie
  • *
  • Posts: 2
Jump to a specific frame
« on: July 22, 2019, 08:38:50 PM »
Hi,

I try to run the following script. I want to compute a simple quantity in the last frame but for some reason ovito always calculats the first frame. Is there a way to jump to a specific frame?

Even if I put the output = pipeline.compute(1) after the import command I still get the same results.

I use the latest  version 3.0.0 den 419.

kind regards

Andrew

script...

Code: [Select]
from ovito.modifiers import *
from ovito.pipeline import StaticSource, Pipeline
from ovito.data import DataCollection, SimulationCell, Particles
from ovito.io import import_file, export_file

pipeline = import_file("G:/Temp/cluster/tr3.gsd")

pipeline.modifiers.append(CreateBondsModifier(cutoff = 2.7))

modif2=ComputePropertyModifier(output_property = 'bl',expressions = ['BondLength'],operate_on="bonds")
pipeline.modifiers.append(modif2)

modifier = HistogramModifier(bin_count=200, property='bl',operate_on="bonds")
pipeline.modifiers.append(modifier)
output = pipeline.compute(1)

export_file(pipeline, "G:/Temp/cluster/bl4.txt", "txt/series", key="histogram[bl]")
« Last Edit: July 22, 2019, 10:34:30 PM by Constanze Kalcher »

armitatz

  • Newbie
  • *
  • Posts: 2
Re: Jump to a specific frame
« Reply #1 on: July 22, 2019, 10:21:58 PM »
got it!

I used

Code: [Select]
from ovito import dataset

pipeline = import_file("G:/Temp/cluster/tr3.gsd")
#output = pipeline.compute(1)
dataset.anim.current_frame=1
« Last Edit: July 22, 2019, 10:36:02 PM by Constanze Kalcher »

Constanze Kalcher

  • Administrator
  • Sr. Member
  • *****
  • Posts: 301
Re: Jump to a specific frame
« Reply #2 on: July 22, 2019, 10:50:27 PM »
Hi,
yes the reason for this is that by default, only the current animation frame (frame 0 by default) is exported by the function. To export a different frame, you can pass the frame keyword parameter to the export_file() function. Alternatively, you can export all frames of the current animation sequence at once by passing multiple_frames=True.
See manual entry for ovito.io.export_file() in the scripting reference.
https://ovito.org/manual_testing/python/modules/ovito_io.html#ovito.io.export_file
-Constanze