Show/Hide Toolbars

MESYS Calculation Software

Navigation: General > COM Interface

Using the COM server

Scroll Prev Top Next More

The COM server can be used to call functions within the MESYS software from other programs.

A simple example in a VisualBasic function:

Public Sub test()

Dim mesys As MesysCOM

Set mesys = New MesysCOM

Dim rbc As MesysRBC

 

Set rbc = mesys.createRBC

Dim d As Long

Dim pmax As Double

 

Call rbc.setVarInt("inputType", 2)

Call rbc.setVarInt("Z", 12)

Call rbc.setVarDouble("Dw", 5)

Call rbc.setVarDouble("Dpw", 50)

Call rbc.setVarDouble("Fy", 1000)

Call rbc.setVarDouble("ni", 500)

 

result = rbc.Calculate

Call rbc.showReport("c:/temp/report.pdf")

Call rbc.getVarDouble("pmax", pmax)

Call rbc.getVarInt("Z", d)

Call rbc.calculateBearing(True, 0, True, 1000, True, 0, False, 0, False, 0, 500, 0, 20, 20)

Call rbc.getVarDouble("pmax", pmax)

Set rbc = Nothing

Set mesys = Nothing

 

End Sub

 

And here the same example in Python using the members with variants as [in, out] parameters do not work from python:

import comtypes.client

 

mesys = comtypes.client.CreateObject("MesysCOM64.MesysCOM")

rbc = mesys.createRBC()

rbc.setVar("inputType", 2)

rbc.setVar("Z", 12)

rbc.setVar("Dw", 5)

rbc.setVar("Dpw", 50)

rbc.setVar("Fy", 1000)

rbc.setVar("ni", 500)

rbc.calculate()

rbc.showReport("c:/temp/report.pdf")

pmax = rbc.getVar("pmax")

z = rbc.getVar("Z")

rbc.calculateBearing(True, 0, True, 1000, True, 0, False, 0, False, 0, 500, 0, 20, 20)

pmax2 = rbc.getVar("pmax")

stiffness = rbc.getStiffnessMatrixAsVector();

rbc = None

mesys = None

 

The server provides the interface MesysCOM which can be used to create calculation modules. Available methods are:

void setLanguage([in] BSTR p_lang);
Pass language as two characters ("de", "en", "fr", "es", "tr", "ko", "zh", "ja")

int getVersion();
Returns version in format yyyymm.

MesysRBC* createRBC();
Create bearing calculation module without user interface.

MesysSHAFT* createSHAFT();
Create shaft calculation module without user interface.

MesysHERTZ* createHERTZ();
Create Hertz stress calculation module without user interface.

MesysBALLSCREW* createBALLSCREW();
Create ball screw calculation module without user interface.

MesysGUIRBC* createGUIRBC();
Create bearing calculation module with user interface.

MesysGUIHERTZ* createGUIHERTZ();
Create hertz stress calculation module with user interface.

MesysGUISHAFT* createGUISHAFT();
Create shaft calculation module with user interface.

MesysGUIBALLSCREW* createGUIBALLSCREW();
Create ball screw calculation module with user interface.

 

The interfaces MesysRBC, MesysSHAFT and others without GUI create calculation modules without user interface. MesysGUIRBC, MesysGUISHAFT are calculation modules with user interface.

General methods for all calculation modules are:

VARIANT_BOOL calculate();
Run calculation.

VARIANT_BOOL loadFile([in] BSTR p_filename);
Load file.

VARIANT_BOOL saveFile([in] BSTR p_filename);
Save calculation file.

VARIANT_BOOL generateReport([in] BSTR p_filename);
Generate a report into the filename.

VARIANT_BOOL showReport([in] BSTR p_filename);
Generate the report into the filename and call a program to view it.

VARIANT_BOOL generateSpecialReport([in] BSTR p_type, [in] BSTR p_filename);

Generate a special report into the filename. Use type as "resultTables" for result tables.

VARIANT_BOOL generateImage([in] BSTR p_imageID, [in] BSTR p_filename, [in] int p_dpi, [in] int p_widthinMM, [in] int p_heightinMM);
Generate an image and save it as file.

VARIANT_BOOL setVarDouble([in] BSTR p_name, [in] double p_value);
Set variable to double value.

VARIANT_BOOL setVarBool([in] BSTR p_name, [in] VARIANT_BOOL p_value);
Set variable to boolean value.

VARIANT_BOOL setVarInt([in] BSTR p_name, [in] int p_value);
Set variable to integer value.

VARIANT_BOOL setVarString([in] BSTR p_name, [in] BSTR p_value);
Set variable to character value.

VARIANT_BOOL getVarDouble([in] BSTR p_name, [in,out] double *p_value);
Read back double variable.

VARIANT_BOOL getVarBool([in] BSTR p_name, [in,out] VARIANT_BOOL *p_value);
Read back boolean variable.

VARIANT_BOOL getVarInt([in] BSTR p_name, [in,out] int *p_value);
Read back integer variable.

VARIANT_BOOL getVarString([in] BSTR p_name, [in,out] BSTR *p_value);
Read back character variable.

VARIANT_BOOL setVar([in] BSTR p_name, [in] VARIANT p_value);
Set variable using variant

VARIANT getVar([in] BSTR p_name);
Get variable using variant

VARIANT_BOOL resizeArray([in] BSTR p_name, [in] int p_count);
Resize array variable

 

 

Additional methods for bearing calculation:

 

VARIANT_BOOL calculateBearing([in] VARIANT_BOOL p_enterFx, [in] double p_Fx_or_Ux, [in] VARIANT_BOOL p_enterFy, [in] double p_Fy_or_Uy, [in] VARIANT_BOOL p_enterFz, [in] double p_Fz_or_Uz, [in] VARIANT_BOOL p_enterMy, [in] double p_My_or_Ry, [in] VARIANT_BOOL p_enterMz, [in] double p_Mz_or_Rz, [in] double p_ni, [in] double p_ne, [in] double p_Ti, [in] double p_Te);
Run bearing calculation with given loading.

VARIANT_BOOL setupLoadSpectrum([in] int p_count, [in] VARIANT_BOOL p_enterFx, [in] VARIANT_BOOL p_enterFy, [in] VARIANT_BOOL p_enterFz, [in] VARIANT_BOOL p_enterMy, [in] VARIANT_BOOL p_enterMz);
Setup load spectrum definition.

VARIANT_BOOL setLoadSpectrumLoad([in] int p_loadCase, [in] double p_frequency, [in] double p_Fx_or_Ux, [in] double p_Fy_or_Uy, [in] double p_Fz_or_Uz, [in] double p_My_or_Ry, [in] double p_Mz_or_Rz, [in] double p_ni, [in] double p_ne, [in] double p_Ti, [in] double p_Te, [in] double p_TOil);
Set load spectrum load for each load case

VARIANT_BOOL selectBearingFromDatabase([in] BSTR p_manufacturer, [in] BSTR p_bearingName);
Selects a bearing based on name and manufacturer from the database

VARIANT_BOOL getStiffnessMatrix([in,out] double *p_c11, [in,out] double *p_c12, [in,out] double *p_c13, [in,out] double *p_c14, [in,out] double *p_c15, [in,out] double *p_c21, [in,out] double *p_c22, [in,out] double *p_c23, [in,out] double *p_c24, [in,out] double *p_c25, [in,out] double *p_c31, [in,out] double *p_c32, [in,out] double *p_c33, [in,out] double *p_c34, [in,out] double *p_c35, [in,out] double *p_c41, [in,out] double *p_c42, [in,out] double *p_c43, [in,out] double *p_c44, [in,out] double *p_c45, [in,out] double *p_c51, [in,out] double *p_c52, [in,out] double *p_c53, [in,out] double *p_c54, [in,out] double *p_c55);
Reads back the bearing stiffness matrix with units N, Nm, mm, rad. The order of rows and columns is like in the report ux, uy, uz, ry, rz.

SAFEARRAY(VARIANT) getStiffnessMatrixAsVector();
Reads back the bearing stiffness matrix  as vector with units N, Nm, mm, rad. The order of the elements is per row.

 

Additional methods for ball screw calculation:

 

VARIANT_BOOL calculateBallScrew([in] VARIANT_BOOL p_enterFx, [in] double p_Fx_or_Ux, [in] VARIANT_BOOL p_enterFy, [in] double p_Fy_or_Uy, [in] VARIANT_BOOL p_enterFz, [in] double p_Fz_or_Uz, [in] double p_Rx, [in] VARIANT_BOOL p_enterMy, [in] double p_My_or_Ry, [in] VARIANT_BOOL p_enterMz, [in] double p_Mz_or_Rz, [in] double p_ni, [in] double p_ne, [in] double p_Ti, [in] double p_Te);
Run ball screw calculation with given loading

VARIANT_BOOL setupLoadSpectrum([in] int p_count, [in] VARIANT_BOOL p_enterFx, [in] VARIANT_BOOL p_enterFy, [in] VARIANT_BOOL p_enterFz, [in] VARIANT_BOOL p_enterMy, [in] VARIANT_BOOL p_enterMz);
Setup load spectrum definition

VARIANT_BOOL setLoadSpectrumLoad([in] int p_loadCase, [in] double p_frequency, [in] double p_Fx_or_Ux, [in] double p_Fy_or_Uy, [in] double p_Fz_or_Uz, [in] double p_Rx, [in] double p_My_or_Ry, [in] double p_Mz_or_Rz, [in] double p_ni, [in] double p_ne, [in] double p_Ti, [in] double p_Te);
Sets load spectrum load for each load case

VARIANT_BOOL getStiffnessMatrix([in,out] double *p_c11, [in,out] double *p_c12, [in,out] double *p_c13, [in,out] double *p_c14, [in,out] double *p_c15, [in,out] double *p_c21, [in,out] double *p_c22, [in,out] double *p_c23, [in,out] double *p_c24, [in,out] double *p_c25, [in,out] double *p_c31, [in,out] double *p_c32, [in,out] double *p_c33, [in,out] double *p_c34, [in,out] double *p_c35, [in,out] double *p_c41, [in,out] double *p_c42, [in,out] double *p_c43, [in,out] double *p_c44, [in,out] double *p_c45, [in,out] double *p_c51, [in,out] double *p_c52, [in,out] double *p_c53, [in,out] double *p_c54, [in,out] double *p_c55);
Reads back the stiffness matrix with units N, Nm, mm, rad. The order of rows and columns is like in the report ux, uy, uz, ry, rz.

SAFEARRAY(VARIANT) getStiffnessMatrixAsVector();
Reads back the bearing stiffness matrix  as vector with units N, Nm, mm, rad. The order of the elements is per row.

 

Additional methods for the shaft calculation:

VARIANT_BOOL importREXS([in] BSTR p_path);
Import system in REXS format

void resizeLoadSpectrum([in] int p_count);
Resize load spectrum, which needs to be active.

VARIANT_BOOL setLoadSpectrumElement([in] int p_id, [in] BSTR p_component, [in] int p_index, [in] double p_value);
Set data for load spectrum element

VARIANT_BOOL setPosition([in] int p_id, [in] double p_position);
Set position for force or support

SAFEARRAY(VARIANT) getShaftIds();
Get list of shaft IDs

SAFEARRAY(VARIANT) getForceIds();
Get list of force IDs

SAFEARRAY(VARIANT) getSupportIds();
Get list of support IDs

SAFEARRAY(VARIANT) getSectionIds();
Get list of section IDs

SAFEARRAY(VARIANT) getBearingIds();
Get list of bearing IDs

SAFEARRAY(VARIANT) getBallscrewIds();
Get list of ballscrew IDs

SAFEARRAY(VARIANT) getGroupIds();
Get list of group IDs

SAFEARRAY(VARIANT) getElasticPartIds();
Get list of elastic part IDs

int getShaftIdByName([in] BSTR p_name);
Get ID for first shaft with given name. Returns zero if not found.

int getForceIdByName([in] BSTR p_name);
Get ID for first force with given name. Returns zero if not found.

int getSupportIdByName([in] BSTR p_name);
Get ID for first support with given name. Returns zero if not found.

int getSectionIdByName([in] BSTR p_name);
Get ID for first section with given name. Returns zero if not found.

int getBearingIdByName([in] BSTR p_name);
Get ID for first bearing with given name. Returns zero if not found.

int getBallscrewIdByName([in] BSTR p_name);
Get ID for first ballscrew with given name. Returns zero if not found.

int getElasticPartIdByName([in] BSTR p_name);
Get ID for first elastic part with given name. Returns zero if not found.

BSTR getName([in] int p_id);
Get element name for ID

VARIANT getIDVar([in] int p_id, [in] BSTR p_name);
Get variable for element with given ID

VARIANT_BOOL setIDVar([in] int p_id, [in] BSTR p_name, [in] VARIANT p_value);
Set variable for element with given ID

VARIANT_BOOL resizeIDArray([in] int p_id, [in] BSTR p_name, [in] int p_count);
Resize array variable for element with given ID

MesysRBC* getBearingModule([in] int p_id);
Get bearing calculation for given ID as copy

VARIANT_BOOL setBearingModule([in] int p_id, [in] MesysRBC* p1);
Set bearing calculation for given ID

MesysBALLSCREW* getBallScrewModule([in] int p_id);
Get ballscrew calculation for given ID as copy

VARIANT_BOOL setBallScrewModule([in] int p_id, [in] MesysBALLSCREW* p1);
Set ballscrew calculation for given ID
 

Each calculation module with GUI provides following methods:

void showWindow();
Show user interface.

void hideWindow();
Hide user interface.

void exec();
Show user interface and process events until the window is closed.

void setLanguage([in] BSTR p_lang);
Pass language as two characters ("de", "en", "fr", "es", "tr", "ko", "zh", "jp")

MesysModule* getCalcModule();
Get the calculation module from the user interface.

void setCalcModule(MesysModule*);
Set the calculation module for the user interface.

 

The names for variables of the calculation modules are the same as provided for the custom report templates. Currently the use for the shaft calculation is limited as additional functions for changing loads and supports are missing.