Author Topic: Python script modifiers  (Read 301 times)

Carolina

  • Newbie
  • *
  • Posts: 6
Python script modifiers
« on: March 01, 2018, 03:19:50 PM »
Dear Mr. Stukowsky,
thank you for your attention. I have a naive question about the use of Phyton script in Ovito.

I am using the Polyhedral Template Match Analysis and I would like to have a rendering of orientations in RGB scale. I found the Python script you posted in order to render in RGB scale the results of the analysis, I run it but I am not able to visualize the final rendering. The steps I followed:
- opening the graphic interface of OVITO and loading my configuration files
- performing the PTM analysis
- adding a modifier as "Python script", coping your script in the "Edit script" window, run it

Ok, after these passages I add a "Color coding" but I am not able to find the new compute property to plot.

I am really sorry for this really naive question and the lost of your time to answer. Have a nice day,

Carolina

Alexander Stukowski

  • Administrator
  • Sr. Member
  • *****
  • Posts: 395
Re: Python script modifiers
« Reply #1 on: March 01, 2018, 05:49:58 PM »
Carolina,

You don't need the Color Coding modifier. The Python script should directly assign colors to the atoms. Don't you see any colors? Make sure that the "Output - Lattice orientation" option is activated in the PTM modifier. If you still don't see any colors being assigned, please check if the Python script modifier displays any error messages.

Regards,
Alex

Carolina

  • Newbie
  • *
  • Posts: 6
Re: Python script modifiers
« Reply #2 on: March 05, 2018, 09:41:17 AM »
Dear Mr Stukowsky,
thank you for your quick answer. Yes, the 'output -> lattice orientation' is active in the PTM analysis, if not the script would indicate an error (it woud not find the input quaternions for its RGB calculations). SImply, when I run the script nothing happens, no errors, no colours. I just still see the colours associated to the different crystalline structures from PTM analysis (see attached snapshot).

Best,
Carolina

Alexander Stukowski

  • Administrator
  • Sr. Member
  • *****
  • Posts: 395
Re: Python script modifiers
« Reply #3 on: March 05, 2018, 01:58:30 PM »
I just realised that you stumbled over an old documentation bug. The last line of the orientation colouring script has been cut off in the user manual. This error has been fixed some time ago in the development version of OVITO, but it is still present in the documentation of OVITO 2.9.0. I now manually added the missing script line to the online version of the scripting manual:

http://ovito.org/manual/python/introduction/examples.html#example-visualize-local-lattice-orientation

I'm sorry for the confusion.

Carolina

  • Newbie
  • *
  • Posts: 6
Re: Python script modifiers
« Reply #4 on: March 05, 2018, 02:54:40 PM »
ah wonderful, but pay attention I just paste the new line in the script:

 color_property.marray[...] = quaternions_to_colors(orientation_property)

 and I am getting an error now:

The Python script has exited with an error.
invalid character in identifier (<string>, line 53)

Alexander Stukowski

  • Administrator
  • Sr. Member
  • *****
  • Posts: 395
Re: Python script modifiers
« Reply #5 on: March 05, 2018, 03:03:53 PM »
Looks like the manual editing of the HTML page requires some more care. I think I've fixed the problem now. Please try again.

Carolina

  • Newbie
  • *
  • Posts: 6
Re: Python script modifiers
« Reply #6 on: March 05, 2018, 03:14:38 PM »
I was removing the post, now it is working , don't know what was the problem ... you answer too quickly !!!

Thank you a lot, have a nice start of your week!

Carolina