ChronoEngine_SwAddin.SWIntegration.ConnectToSW C# (CSharp) Method

ConnectToSW() public method

public ConnectToSW ( object ThisSW, int Cookie ) : bool
ThisSW object
Cookie int
return bool
        public bool ConnectToSW(object ThisSW, int Cookie)
        {
            //System.Windows.Forms.MessageBox.Show("Add-in: ConnectToSW");
            try
            {
            mSWApplication = (SldWorks)ThisSW;
            mSWCookie = Cookie;
            bool result = mSWApplication.SetAddinCallbackInfo(0, this, Cookie);

            // Attributes register

            defattr_chbody = (AttributeDef)mSWApplication.DefineAttribute("chrono_ChBody");
            defattr_chbody.AddParameter("friction",             (int)swParamType_e.swParamTypeDouble, 0.6, 0);
            defattr_chbody.AddParameter("rolling_friction",     (int)swParamType_e.swParamTypeDouble, 0, 0);
            defattr_chbody.AddParameter("spinning_friction",    (int)swParamType_e.swParamTypeDouble, 0, 0);
            defattr_chbody.AddParameter("restitution",          (int)swParamType_e.swParamTypeDouble, 0, 0);
            defattr_chbody.AddParameter("collision_on",         (int)swParamType_e.swParamTypeDouble, 1, 0);
            defattr_chbody.AddParameter("collision_margin",     (int)swParamType_e.swParamTypeDouble, 0.01, 0);
            defattr_chbody.AddParameter("collision_envelope",   (int)swParamType_e.swParamTypeDouble, 0.03, 0);
            defattr_chbody.AddParameter("collision_family",     (int)swParamType_e.swParamTypeDouble, 0, 0);
            defattr_chbody.Register();
            /*
            defattr_chconveyor = (AttributeDef)moSWApplication.DefineAttribute("chrono_ChConveyor");
            defattr_chconveyor.AddParameter("conveyor_speed",   (int)swParamType_e.swParamTypeDouble, 1.0, 0);
            defattr_chconveyor.Register();
            */

            // Register the taskpane
            this.UISetup();

            // Event register: here is an example of how to do...
            SldWorks moSWApplication = (SldWorks)mSWApplication;
            moSWApplication.ActiveDocChangeNotify += new DSldWorksEvents_ActiveDocChangeNotifyEventHandler(test_event_ActiveDocChangeNotify);
            moSWApplication.ActiveModelDocChangeNotify += new DSldWorksEvents_ActiveModelDocChangeNotifyEventHandler(test_event_ActiveModelDocChangeNotify);
            }
            catch (Exception ex)
            {
            System.Windows.Forms.MessageBox.Show("ConnectToSW failed! " + ex.Message);
            }

            return true;
        }