Forum Navigation
You need to log in to create posts and topics.

problem with script running

H i

I used attached script in ovito 3.2.1 and nothings happens.!!

no opening the ecbox nor selection.

I appreciate if anybody help me.

thanks

Uploaded files:

Hi,

I'm not sure what you are actually trying to do. I'm guessing you run that script from the GUI through "File->Run script" and are expecting the imported file to be visible in the viewports? Then you should at least add a

pipeline.add_to_scene()

statement at the end of your script, see https://www.ovito.org/docs/current/python/modules/ovito_pipeline.php?highlight=add_to_scene#ovito.pipeline.Pipeline.add_to_scene.

Please also have a look at these introductory sections of the scripting manual first:

https://www.ovito.org/docs/current/python/introduction/running.php

https://www.ovito.org/docs/current/python/introduction/overview.php

and especially the section about the pipeline evaluation:

https://www.ovito.org/docs/current/python/modules/ovito_pipeline.php

 

 

yes you are wright . I try to excute the script through GUI and 'run script' option.

and I visualize the pipeline with the command you said (thanks).

but I try to run one of example script on my molecule (hydrogen removing script):

from ovito.io import import_file, export_file
from ovito.modifiers import SelectTypeModifier, DeleteSelectedModifier

pipeline = import_file('C:/Users/neginpardaz/Desktop/ecbox.data', atom_style = 'full')
pipeline.modifiers.append( SelectTypeModifier(property='Particle Type', types={'H'}) )
pipeline.modifiers.append( DeleteSelectedModifier() )
export_file(pipeline, 'output_file.xyz', 'xyz')

that attached (ecbox.data). and I got error :

No particle properties have been selected for export to the XYZ file

I check selection of hydrogen with script generator and it was :

pipeline.modifiers.append(SelectTypeModifier(types = {2}))

then I changed type to {2} instead of {H}

and I get error:

Type '2' does not exist in the type list of property 'Particle Type'

how can I run hydrogen remove script on my molecule(ecbox.data)?

thanks.

For the output formats lammps/dump, xyz, imd and netcdf/amber, you must specify the set of particle properties to export using the columns keyword parameter, e.g.

export_file(pipeline, "output.xyz", "xyz", columns =
  ["Particle Identifier", "Particle Type", "Position.X", "Position.Y", "Position.Z"])

see section "File columns" in the manual: https://www.ovito.org/docs/current/python/modules/ovito_io.php

thanks it works.

but please correct the example script "remove_hydrogens.py" in  https://www.ovito.org/docs/current/python/introduction/running.php

that is :

from ovito.io import import_file, export_file
from ovito.modifiers import SelectTypeModifier, DeleteSelectedModifier

pipeline = import_file('input_file.xyz')
pipeline.modifiers.append( SelectTypeModifier(property='Particle Type', types={'H'}) )
pipeline.modifiers.append( DeleteSelectedModifier() )
export_file(pipeline, 'output_file.xyz', 'xyz')



thanks


Thanks for pointing this out.