Hi,
What is the best strategy in this case depends on whether the data for the "Aspherical Shape" property should be loaded from the input file or is to be generated on the fly after loading. From the scripts you posted I read that you want to assign the same aspherical shape (0.5,2.,0.5) to all particles. Is that right?
Let's assume you want to set the aspherical shape property for all particles to the same uniform value. In this case, the
Compute Property modifier is your best choice. You can use it to set the component values of the "Aspherical Shape" particle property to specific values such as 0.5, 2.0 and 0.5.
There are different ways to apply this modifier: You could do it by hand within the GUI and enter the values for the three components. But then you would have to do this every time you are loading a new simulation file. One way to simplify this step is to define a
modifier preset. Then setting the aspherical shape takes just one or two clicks.
The third option is to use scripting commands. Since the
Compute Property modifier is already doing the job of setting the property for you, you won't need to write a user-defined Python modifier. You only need to insert an instance of the
ComputePropertyModifier into the current data pipeline.
When you run
ovito (not
ovitos) from the terminal with the --help command line option, you will see that it supports the --exec option, which lets you execute arbitrary Python commands after program startup. We can use it to insert the
ComputePropertyModifier after the simulation file has been loaded:
ovito --exec "import ovito; from ovito.modifiers import ComputePropertyModifier; ovito.dataset.selected_node.modifiers.append(ComputePropertyModifier(output_property='Aspherical Shape', expressions=['0.5','2.0','0.5']))" <datafile>
Alternatively, you can put these script commands into a .py file and use the --script command line option to execute the script file on program startup. The effect is the same as if you would manually choose
Run Script File from the menu in the GUI.
-Alex