OVITO > Support Forum

Python script slice modifier

(1/2) > >>

Haomin:
Dear all,

I read the documentation of SliceModifier. It doesn't take the 'Align view direction to plane normal' as an argument. I want to render plenty of image with aligning the view direction to plane normal. If anyone has any suggestion on how to implement with the python script?

Thanks,
Haomin

Constanze Kalcher:
Dear Haomin,

just to confirm, your rendering images programmatically and you're asking about the Slice modifier in the Python API, right?
Note that the Slice modifier takes an argument "normal", which is the normal vector of the slicing plane and by default is set to (1,0,0). You can adapt that to your needs, e.g.


--- Code: ---from ovito modifiers import SliceModifier
pipeline.modifiers.append( SliceModifier( normal = ( 1, 1, 2)) )

--- End code ---
https://ovito.org/manual_testing/python/modules/ovito_modifiers.html#ovito.modifiers.SliceModifier

Edit:   You can then set up the viewport’s virtual camera and e.g. control the viewing direction vector like this:


--- Code: ---from ovito.vis import Viewport
vp = Viewport(type = Viewport.Type.Ortho, camera_dir = (1, 1, 2))
vp.zoom_all()
--- End code ---
https://ovito.org/manual_testing/python/modules/ovito_vis.html,


-Constanze

Haomin:
Dear Constanze,

Thanks for your reply. It solves my question.

Haomin

Haomin:
Dear all,

I was trying to adjust my camera position as well as direction for each loop of the rendering using the python API. However, I got this error:

AttributeError: 'ovito.plugins.PyScript.Viewport' object attribute 'camera_dir' is read-only

I am using Ovito 3.0.0. Is anyone know how to solve it?

Thanks,
Haomin

Constanze Kalcher:
Dear Haomin,

please post the code that's causing you this error.

-Constanze

Navigation

[0] Message Index

[#] Next page

Go to full version