CNCSIMULATOR.COM  

Home
CncSimulator Info

Downloads
Petrol Station
Support
Developers Corner
User Forum
Products
 
DEVELOPERS CORNER

DEVELOPERS CORNER

Interpreter development:

See the Interpreter page

Plugin development:

Here is a description of how to use the CncSimulator Plug-in SDI in Microsoft Visual C++

 

  • Download the SDI zip file and unpack the files in a folder in you source directory. We suggest that you name it “CncSimPluginInterface”.
     

  • Run the “MFC AppWizard (DLL)” and name the new project. (E.g. “MyPlugin”)
     

  • Accept the defaults and click “Finish”.
     

  • In the beginning of your main cpp file put a include statement for the cncsimplugin.h in your plug-in folder.

 

#include "\msdev\Projects\CncSimPluginInterface\cncsimplugin.h"

 

  • Go to “Project Settings” and the Link tab.
     

  • Enter the path to the cncsimplugininterface.lib under “Object/Library modules”.
     

\msdev\Projects\ CncSimPluginInterface\cncsimplugininterface.lib

 

Note! There is a debug library to use when debuging. The name of it is cncsimplugininterface_d.lib. There is also a testprogram that you can use when testing and debugging your plugin. The name of this program is 'PluginTest.exe'. A good idéa is to copy the plugintest.exe to your debug folder and the enter its name under 'program settings' - 'debug' - 'executable for debug session'.
 

  • Change the extension of your output file under “Output file name” to mpl. This is the extension the CncSimulator recognizes as plug-ins.

 

 

  • Create one or more functions that you want to be able to start from the CncSimulator plug-in menu. In this example, let us say that the name of the function is “MyFunc” and that the name that should be shown in the plug-in menu is “My plug-in”. Note that the function(s) must return an int of value 0. (Reserved for future implementations).
     

  • Put EXTC and ENDEXTC before and after your function(s). Also put DLL_DECL before the function. 

 

EXTC

DLL_DECL int MyFunc()

{

                      AFX_MANAGE_STATE(AfxGetStaticModuleState());

                      AfxMessageBox(“Hello World!”);             

                      return 0;

}

ENDEXTC

 

  • Now, alter the constructor and create a destructor looking like this:

 

CMyPluginApp:: CMyPluginApp ()

{

                      addDLLfunc("MyFunc","My Plug-in");

                      // note: one for each exported function

}

 

CMyPluginApp::~ CMyPluginApp ()

{

                      PluginCleanUp();

                      // this is important!

}

 

  • Compile and correct eventual errors.
     

  • Finally, copy your mpl file to the CncSimulator plug-ins folder. Start the CncSimulator and go to the plug-in menu. You should see “My Plug-in” there and be able to run it.

The SDI also contains two functions for getting and returning CNC buffer data to and from the CncSimulator.

 

To get the active CNC code from the simulator, create an CString object and call the getInBuffer function with it.

 

Then you can manipulate the data and send it back using the sendBackData function.

 

DLL_DECL void getInBuffer(CString &data);

data               the cncbuffer

 

DLL_DECL void sendBackData(CString &data, double x=0, double y=0, double z=0, double inx=0, bool rad=false, bool turn=false , bool paste=false, bool partsize=false);

 

data the CString containing the data you want to send back to the CncSimulator editor.
x,y,z part settings after the plug-in ends
inx inner diameter if it is a turning part
rad set to true if the data contains turning coordinates with radius values (else diameter values)
turn set to true if the returning data is for turning machines
paste set to true if you want to insert the data at the cursor, else the data will be replaced
partsize set to true if you want to change the size of the part on return

 


Remember to share your great plug-in with others! You can mail it with a brief description to staff@cncsimulator.com and we will put it up on our webpage together with your name. You may also consider posting information about your plug-in in the user forum for others to see.  

 

 

Home | Info | Downloads | Petrol | Using inch | Support | Developers | Forum | Products