Exemple #1
0
        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 = (SolidWorks.Interop.sldworks.SldWorks)iSwApp;
            openDocs   = new Hashtable();
            AttachEventHandlers();
            #endregion

            #region Setup Sample Property Manager
            AddPMP();
            #endregion

            return(true);
        }
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            solidworks  = (ISldWorks)ThisSW;
            addinCookie = cookie;

            //Setup callbacks
            solidworks.SetAddinCallbackInfo(0, this, addinCookie);

            #region Setup the Command Manager
            _commandManager = solidworks.GetCommandManager(cookie);
            AddCommandMgr();
            #endregion

            #region Setup the Event Handlers
            addin = (SolidWorks.Interop.sldworks.SldWorks)solidworks;
            documentsEventsRepo = new Hashtable();
            //this will be called only the first time the addin is loaded
            //this method will attached events to all documents that open after the addin is loaded.
            AttachSwEvents();
            //Listen for events on all currently open docs
            //we need to call this method here because sometimes user fires the addin while he has some documents open already
            //there are events that will attach event handlers to all documents but until those events are fired this call to the method will suffice
            AttachEventsToAllDocuments();
            #endregion

            #region Setup Sample Property Manager
            AddPMP();
            #endregion

            return(true);
        }
Exemple #3
0
 public RuningSolidWorkInfoModel(SolidWorks.Interop.sldworks.SldWorks app)
 {
     swApp = app;
     if (swApp != null)
     {
         _SolidWorksResult = "获取到SolidWorks进程";
     }
     else
     {
         _SolidWorksResult = "未获取到Solid Works进程";
         return;
     }
     RevisionVersion = swApp.RevisionNumber();
 }
Exemple #4
0
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            try
            {
                iSwApp  = (ISldWorks)ThisSW;
                addinID = cookie;

                //docMgr = new CAD3dSW.Controler.Model(iSwApp, "", string.Empty);
                //Setup callbacks
                iSwApp.SetAddinCallbackInfo(0, this, addinID);

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

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

                #region Setup Sample Property Manager
                AddPMP();
                #endregion

                //System.Text.StringBuilder temp = new System.Text.StringBuilder(5);
                //GetPrivateProfileString("Control", "AutoLoad", "0", temp, 5, System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
                //if (temp.ToString() == "1")
                //{
                //    RunCADworkstation();
                //}
                RunCADworkstation();
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
                throw;
            }


            return(true);
        }
Exemple #5
0
        /// <summary>
        /// Attach the wrapper to solidworks
        /// </summary>
        /// <exception cref="Exception"></exception>
        public static void Attach()
        {
            try
            {
                _solidWorks = (SldWorks)Marshal.GetActiveObject("SldWorks.Application");
            }
            catch (Exception)
            {
                try
                {
                    Type invAppType = Type.GetTypeFromProgID("SldWorks.Application");

                    _solidWorks         = (SldWorks)System.Activator.CreateInstance(invAppType);
                    _solidWorks.Visible = true;
                }
                catch (Exception exception)
                {
                    throw new Exception("Unable to get or start Solidworks");
                }
            }
        }
Exemple #6
0
        // This method is called by SolidWorks when bhe add-in is loaded.
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            // The add-in stores the SolidWorks application pointer in a global variable.
            iSwApp = (ISldWorks)ThisSW;
            // The add-in stores the cookie in a global variable.
            addinID = cookie;

            // Setup callbacks
            // The add-in uses this method to send SolidWorks a pointer to itself.
            // It also sends the cookie back to create custom menus and custom toolbars.
            iSwApp.SetAddinCallbackInfo(0, this, addinID);

            #region Setup the Command Manager
            // Setup the Command Manager
            // The Command Manager is used to create custom menus and custom toolbars in the SolidWorks user interface.
            iCmdMgr = iSwApp.GetCommandManager(cookie);
            // 自定义函数
            AddCommandMgr();
            #endregion

            #region Setup the Event Handlers
            // Setup the Event Handlers
            SwEventPtr = (SolidWorks.Interop.sldworks.SldWorks)iSwApp;
            openDocs   = new Hashtable();
            // The Event handlers are added.
            // 自定义函数
            AttachEventHandlers();
            #endregion

            #region Setup Sample Property Manager
            // Setup Sample Property Manager
            // A custom PropertyManagerPage is created.
            // 自定义函数
            AddPMP();
            #endregion

            // The add-in inform SolidWorks that this method was successful.
            return(true);
        }
Exemple #7
0
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            iSwApp  = (ISldWorks)ThisSW;
            addinID = cookie;

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



            #region
            AddTaskPanel();
            #endregion

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



            return(true);
        }
Exemple #8
0
        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 = (SolidWorks.Interop.sldworks.SldWorks)iSwApp;
            openDocs = new Hashtable();
            AttachEventHandlers();
            #endregion

            #region Setup Sample Property Manager
            AddPMP();
            #endregion

            return true;
        }
Exemple #9
0
        // This method is called by SolidWorks when bhe add-in is loaded.
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            // The add-in stores the SolidWorks application pointer in a global variable.
            iSwApp = (ISldWorks)ThisSW;
            // The add-in stores the cookie in a global variable.
            addinID = cookie;

            // Setup callbacks
            // The add-in uses this method to send SolidWorks a pointer to itself.
            // It also sends the cookie back to create custom menus and custom toolbars.
            iSwApp.SetAddinCallbackInfo(0, this, addinID);

            #region Setup the Command Manager
            // Setup the Command Manager
            // The Command Manager is used to create custom menus and custom toolbars in the SolidWorks user interface.
            iCmdMgr = iSwApp.GetCommandManager(cookie);
            // �Զ��庯��
            AddCommandMgr();
            #endregion

            #region Setup the Event Handlers
            // Setup the Event Handlers
            SwEventPtr = (SolidWorks.Interop.sldworks.SldWorks)iSwApp;
            openDocs = new Hashtable();
            // The Event handlers are added.
            // �Զ��庯��
            AttachEventHandlers();
            #endregion

            #region Setup Sample Property Manager
            // Setup Sample Property Manager
            // A custom PropertyManagerPage is created.
            // �Զ��庯��
            AddPMP();
            #endregion

            // The add-in inform SolidWorks that this method was successful.
            return true;
        }
Exemple #10
0
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            iSwApp = (ISldWorks)ThisSW;
            addinID = cookie;

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

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

            #region Taskpane setup
            Taskpanesetup();
            #endregion

            return true;
        }