.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\internal_scripting\emag.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_internal_scripting_emag.py: .. _ref_internal_scripting_emag: E-magnetic ========== This example demonstrates internal scripting E-Mag functionality .. GENERATED FROM PYTHON SOURCE LINES 8-12 .. code-block:: Python import ansys.motorcad.core as pymotorcad mc = pymotorcad.MotorCAD() .. GENERATED FROM PYTHON SOURCE LINES 13-14 Disable pop-up messages .. GENERATED FROM PYTHON SOURCE LINES 14-37 .. code-block:: Python mc.set_variable("MessageDisplayState", 2) # This function is called when "Run" is pressed def main(): pass class emagnetic: def initial(self): mc.display_screen("Scripting") shaft_speed = mc.get_variable("ShaftSpeed") if shaft_speed > 1000: print("Shaft speed is too high. Resetting to 500") mc.set_variable("ShaftSpeed", 500) def final(self): loss_total = mc.get_variable("loss_total") # display total loss rounded to 2dp if available print("total loss is: " + str(round(loss_total, 2))) mc.display_screen("Calculation") .. GENERATED FROM PYTHON SOURCE LINES 38-41 PyMotorCAD Documentation Example -------------------------------------- (Used for the PyMotorCAD Documentation Examples only) .. GENERATED FROM PYTHON SOURCE LINES 41-49 .. code-block:: Python try: from setup_scripts.setup_script import run_emag_demo except ImportError: pass else: run_emag_demo(mc) mc.set_variable("MessageDisplayState", 0) .. rst-class:: sphx-glr-script-out .. code-block:: none 11:32:07 AM : Warning: Licences for different machine types are checked out. You may wish to review your licence configuration. 11:32:14 AM : Loaded script file: emag.py 11:32:15 AM : Python script output: Shaft speed is too high. Resetting to 500 11:32:20 AM : FEA Calculation Time: 3 Seconds 11:32:20 AM : Solving completed 11:32:20 AM : Python script output: total loss is: 144.05 Shaft speed:500 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 20.828 seconds) .. _sphx_glr_download_examples_internal_scripting_emag.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: emag.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: emag.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_