MotionView Python Reference Guide

Reference materials for the MotionView Python Language.

Introduction

Starting in HyperWorks v2021, a Python API is available for MotionView.

Through the python API, it is possible to:
  • Customize MotionView
  • Automate repetitive tasks through python scripts
  • Integrate MotionView with other external tools that have a python interface

Why Python?

Python is:
  • Easy to learn and use.
  • Popular among developers with over 250 thousand open source projects in https://pypi.org.
  • Popular in the scientific community, as it is well suited for numerical calculations.
  • Free - there are many publicly available web sites and resources dedicated to teaching Python.
  • Robust - it can also scale to solve complex problems.
  • Flexible - it is extremely well suited for rapid development and prototyping.

MotionView Python Class

The API is provided in a set of classes which represent different MotionView entities.

Properties

Every class has a list of properties which can be set during its instantiation or can be modified after its creation.

Along with the properties, each entity also has functions which can be called on a specific entity.

Properties define the user input values of a MotionView entity, for example:
  • The mass of a Body
  • The CM (center of mass marker) of a Body
  • The friction property of a Joint
The properties can be classified into three categories:
Property Type Description Examples
Keyword Arguments Modifiable data x, y, or z property of a Point class

mass property of a Body class

Instances Instance of another entity cm property of a Body class is an Instance of a Marker class

friction class within a Joint class

Readonly Properties Unmodifiable data ID property of any entity class

Data Types

The MotionView Python API supports the following data types:
Data Type Description
Int Python integer value.
Bool Python bool value.
Double Python float value.
String Python string value.
Enum Python string value that must be one of a specified list of values applicable for an entity attribute.

For example, a type property of a SpringDamper entity can only be one of TorsionSpring or CoilSpring.

Reference Reference to an existing MotionView entity.

For example, Body-cg refers to a Point entity.

Dict Python dict.
File Python string which contains a legal file path.
NumericVector Python list of Doubles.
StringVector Python list of **String** values.
Function Python string which contains a legal solver function enclosed in \`\`.
注: The values assigned to properties should be compatible with a corresponding MotionView property data type.