User guide#

PyMotorCAD provides Python access to Motor-CAD. The RPC-based MotorCAD API allows you to create a Motor-CAD instance on a local machine or connect to an existing instance on a remote machine over HTTP. Using the many methods available in this API’s single class, you can create scripts for fully controlling and automating Motor-CAD without using the GUI.

Additionally, Motor-CAD scripts can be used via the internal Scripting tab within Ansys Motor-CAD or externally.

Using PyMotorCAD scripts internally#

Motor-CAD is installed with an internal Python interpreter that includes a stable version of PyMotorCAD. This Python package is based around the MotorCAD() Python object. Each individual MotorCAD() object represents an instance of Motor-CAD.

For more information on using PyMotorCAD via the internal Scripting tab in Motor-CAD, see Motor-CAD internal Scripting tab.

Using PyMotorCAD scripts externally#

PyMotorCAD can be added to any Python installation and used to control Motor-CAD from the command line or via scripts from a Python IDE of your choice. For more information on using PyMotorCAD with an external Python installation, see Adding to external python and contributing.

PyMotorCAD can also be used in MATLAB, for information on this, see PyMotorCAD scripting in MATLAB.

Backwards compatibility with old scripts#

Altering old scripts for use with PyMotorCAD is straightforward and allows the user to take advantage of the improvements offered by PyMotorCAD over the previous Motor-CAD communication method (ActiveX). For information on converting ActiveX scripts to use PyMotorCAD, see Backwards compatibility with old scripts.