Categories
Code Snippets

Connecting to SolidWorks using c#

Code sample

public bool ConnectToSW(object ThisSW, int cookie)
{
iSwApp = (ISldWorks)ThisSW;
addinID = cookie;

//Setup callbacks
iSwApp.SetAddinCallbackInfo(0, this, addinID);

#region Setup the Command Manager
iCmdMgr = iSwApp.GetCommandManager(cookie);
AddCommandMgr();
#endregion

#region Setup the Event Handlers
SwEventPtr = (SldWorks.SldWorks)iSwApp;
openDocs = new Hashtable();
AttachEventHandlers();
#endregion

#region Setup Property Manager
AddPMP();
#endregion

return true;
}