Mechanism Viewer Tutorial (Python 2)

NameLocation
Mechanism Viewer<Vortex Studio Installation Folder>\tutorials\Python\VortexPython2\PyMechanismViewer\PyMechanismViewer.py

This tutorial provide an example of creating a custom Vortex, akin to simapp.exe in python 2.

This application is meant to run as a standalone Vortex application.

It shows how to create a simple VxApplication and load content.

It also shows how to create an application setup in code.

It is the python 2 equivalent of the C++ Mechanism Viewer Tutorial without the additional keyboard extensions. These extensions cannot be written in python but they could be moved to a plugin and added to a setup.

Application


The application support 3 commands line arguments:

  • --help, shows what to do
  • --config: The setup file for the application. If none is provided, one is created.
  • --content: Content (scene, mechanism etc) to load. The user is invited to use a scene from the demo scenes package.
    • Some mechanism can also be used, but a terrain must be provided of the object will fall forever.

The main function creates a VxApplication, load a setup file or add some basic extensions and module. The setup will be saved as defaultConfig_PyMechanismViewer.vxc for reuse in the same folder of the executable.

It adds the callback to trigger the application to end when 3d windows are closed.

It then loads the content and run the application until closed.


See Vortex Studio SDK Advanced - Creating an Application for more details about making a Vortex Application

See Vortex Studio SDK - Python 2 Scripting for more details about using Python.

Using the tutorial

  1. Run the script with python 2
    1. Provide a content file using argument –content
    2. A setup file can be provided with --config.
      1. If none is provided, one will be created to provide minimal functionality. 
        1. It will be saved as defaultConfig_PyMechanismViewer.vxc in the same folder of the executable. Use the editor to inspect it.
      2. A good example would be to provide <Vortex Studio Installation Folder>\resources\config\simapp.vxc, which is a good example for a standalone Vortex process.
  2. If the setup provide a main 3d view, the content should be visible.
  3. To go into detail, debug the project and follow the code execution step by step.