Dear all,
             I want to control a commercial numerical solver CST through
python. Usually,  CST can be controlled using MATLAB. CST accepts both COM
and VBA macros from MATLAB. As VBA is difficult and time consuming to
program, i was successful in connecting the CST through COM interface from
MATLAB. The sample snapshot of the commands are as below:
***********************************************************************
*    cst = actxserver('CSTStudio.application') % to open the CST*
*    mws=cst.OpenFile('D:\Gowrishankar\PDF\cuboid.cst'); %to open a
particular file*
*    a=20;*
*    b=20;*
*    c=72;*
*    %To store the parameters*
*    mws.invoke('StoreParameter','a',a);  %These are the COM interface
commands from MATLAB to CST*
*    mws.invoke('StoreParameter','b',b);*
*    mws.invoke('StoreParameter','c',c);*
*    %To rebuild *
*    invoke(mws,'Rebuild');*

*    %%Setting only the required boudnary conditions only*
*    bound=invoke(mws,'Boundary');     %These are the COM interface
commands from MATLAB to CST*
*    bound.invoke('Zmin','magnetic');*
*    bound.invoke('Zmax','magnetic');*

*    %% Set the frequency range*
*    solver=invoke(mws,'Solver');*
*    invoke(solver,'FrequencyRange',freMin,freMax);*

*    Esolver=invoke(mws,'EigenmodeSolver');*
*    invoke(Esolver,'Reset');*

*    invoke(Esolver,'SetMeshType','Tetrahedral Mesh');*
*    invoke(Esolver,'SetNumberOfModes',noOfMode);*

*    invoke(Esolver,'Start'); %Run the solver*
*    noOfModesCalculated=invoke(Esolver,'GetNumberOfModesCalculated');*
*    for j=1:noOfModesCalculated*
*        eigenFreq(j)=invoke(Esolver,'GetModeFrequencyInHz',j);*
*    end*

*    invoke(mws,'Save'); %Save the file*
*    invoke(mws, 'Quit');  %closes the file*
*    release(mws);     *
*    invoke(cst, 'Quit');   % closes the CST application*
*    release(cst);*
*   dos(['taskkill /F /IM ' '"CST DESIGN ENVIRONMENT.exe"']);*

**************************************************************************
MATLAB commands work perfectly wihtout any fuss.
*I have translated the above code in python but i was able to talk to CST
with only first 2-3 commands i.e*
*********************************
*import win32com.client*
*cst = win32com.client.Dispatch("CSTStudio.Application")*
*#Opens a new CST file*
*mws=cst.OpenFile('D:\Gowrishankar\PDF\cuboid.cst');*

*#mws=cst.NewMWS()*

*###Below this commands i got error or sometimes it didn't give any error
but just it didn't worked*
*mws.StoreParameter('len2',10.1)*
*mwssolver=mws.Solver()*
*mws.Solver.Start()*
*******************************
I tried different online forums for help and i was unsuccessful in getting
any clue how to move forward. Erros messages didnt revealed any
information. I even checked and compared the COM commands used to control
Excel from MATLAB and Python. But, still i am not able to progress any
further. Moreover, the commercial software guys wont help me in doing with
python. Furthermore, i used combrowse.py and make.py to access the
different objects of the interface but they are all hidden for CST. Can
someone suggest me how should i move ahead, are there any examples
available for controlling a windows application through MATLAB and python
so that i can understand the co-relation between the commands between the
two. Any help in this regard is highly appreciated.


Regards,
GOWRISHANKAR.T.H
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to