API Structure#

The structure of the API takes full advantage of the object-oriented nature of python. In msolve, every model entity is a class that derives from a Base class named SolverObject.

Every model entity is equipped with inherited and native attributes that, when defined by the user, can explicitly describe their behavior.

Base Attributes#

There are three attributes that every MotionSolve entity inherits from the SolverObject class and they are described below.

SolverObject attributes#

Name

Description

id

An integer number that is unique among all objects of the same type. If not specified during the creation of a MotionSolve entity, msolve will automatically generate and assign an id to it.

label

A string assigned to an entity, serving as a label. If not specified, label defaults to an empty string.

active

A boolean value that determines whether the entity will be considered by MotionSolve during simulation. The default value of active is True, meaning that the entity will be taken into account by the solver.

Attribute Characterization#

While Python does not require the data type of variables to be declared, this is not desired when defining a language for specifying multibody systems.

For this reason, an msolve attribute is not just a simple python variable. Besides its value, an attribute contains information that establish its characteristics in detail.

These characteristics are described below:

Type

The “property” associated with the attribute. This is a type definition that allows attributes to be initialized and validated. An extended definition of the available properties can be found in the following section.

When an attribute requires multiple instances to be fully determined, Type is followed by an integer in square brackets (eg. Double [3]) that specifies the necessary number of entries. If zero, the number of entries is unrestricted.

Required

A boolean flag that defines if the attribute is required or not.

Default

A value that is assigned to the attribute if not specified by the user.

Modifiable

A boolean flag that defines if the attribute is modifiable by command, meaning that the user can change its value during simulation.

Designable

A boolean flag that defines if the attribute is designable, meaning that it can be used as a Design Variable for Optimization or Design Sensitivity Analysis (DSA).

Base Properties#

In the multibody context, all user-defined inputs to msolve objects have very well defined properties and any value given to any variable must conform to these properties.

The Python Interface for MotionSolve has introduced the concept of a “Property” to encapsulate this notion. Properties define the user settable values of a MotionSolve object.

All attributes have a property. Trying to set an attribute value to an incorrect property type raises an error. For example:

Example#
Part.mass = "A wrong value"

PropertyException: Error setting Part.mass
could not convert string to float: 'A wrong value'

The properties supported by MotionSolve are shown in the table below, along with a brief description.

Properties#

Name

Description

Alias

A property that creates compatibility between objects.

Angles

A set of 3 Double values, used to define the 3-1-3 Euler angles.

Bool

A Boolean value.

Color

A color property. Use Color.colorMap for a list of the available colors.

Double

A double precision value.

Enum

A string value. It must be chosen from a specified list of values.

EnumStr

Multiple string values. They must be chosen from a specified list of values.

Exact

A string value. It specifies a body’s exact fixed position.

Faces

TBD

FileName

A string value. It specifies the location of a file.

Function

A string value. It contains a legal MotionSolve expression or the parameters passed to the user defined subroutine.

Int

An integer value.

Ips

A set of 0, 3 or 6 Double values. It defines the Inertia Tensor.

Location

A set of 3 Double values. It is an instance of the Point class.

Nodes

TBD

Pattern

A string value. It can specify up to a pattern of 10 Boolean values.

Property

The Base class for all the properties.

Reference

A reference to an existing MotionSolve object.

Routine

A string value or a python callable. A DLL/SO name followed by a function name (eg.’DLL::function’) or a callable function.

Script

A string value. The path of the script containing the routine.

Str

A string value.