CreateSWSaveAttribute(SldWorks swApp, ModelDoc2 model, string name) { SolidWorks.Interop.sldworks.Attribute existingAttribute = FindSWSaveAttribute(model, name); if (existingAttribute != null) { return(existingAttribute); } int ConfigurationOptions = (int)swInConfigurationOpts_e.swAllConfiguration; int Options = 0; AttributeDef saveConfigurationAttributeDef; saveConfigurationAttributeDef = swApp.DefineAttribute(URDF_CONFIGURATION_SW_ATTRIBUTE_NAME); saveConfigurationAttributeDef.AddParameter( "data", (int)swParamType_e.swParamTypeString, 0, Options); saveConfigurationAttributeDef.AddParameter( "name", (int)swParamType_e.swParamTypeString, 0, Options); saveConfigurationAttributeDef.AddParameter( "date", (int)swParamType_e.swParamTypeString, 0, Options); saveConfigurationAttributeDef.AddParameter( "exporterVersion", (int)swParamType_e.swParamTypeDouble, SERIALIZATION_VERSION, Options); saveConfigurationAttributeDef.Register(); SolidWorks.Interop.sldworks.Attribute saveExporterAttribute = saveConfigurationAttributeDef.CreateInstance5( model, null, URDF_CONFIGURATION_SW_ATTRIBUTE_NAME, Options, ConfigurationOptions); return(saveExporterAttribute); }
CreateSWSaveAttribute(SldWorks swApp, ModelDoc2 model, string name) { SolidWorks.Interop.sldworks.Attribute existingAttribute = FindSWSaveAttribute(model, name); if (existingAttribute != null) { return(existingAttribute); } int ConfigurationOptions = (int)swInConfigurationOpts_e.swAllConfiguration; int Options = 0; AttributeDef saveConfigurationAttributeDef; saveConfigurationAttributeDef = swApp.DefineAttribute(UrdfConfigurationSwAttributeName); saveConfigurationAttributeDef.AddParameter( "data", (int)swParamType_e.swParamTypeString, 0, Options); saveConfigurationAttributeDef.AddParameter( "name", (int)swParamType_e.swParamTypeString, 0, Options); saveConfigurationAttributeDef.AddParameter( "date", (int)swParamType_e.swParamTypeString, 0, Options); saveConfigurationAttributeDef.AddParameter( "exporterVersion", (int)swParamType_e.swParamTypeDouble, SerializationVersion, Options); saveConfigurationAttributeDef.Register(); SolidWorks.Interop.sldworks.Attribute saveExporterAttribute = saveConfigurationAttributeDef.CreateInstance5( model, null, UrdfConfigurationSwAttributeName, Options, ConfigurationOptions); return(saveExporterAttribute); }
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; }
public AssemblyExportForm(SldWorks SwApp, LinkNode node, ExportHelper exporter) { Application.ThreadException += new ThreadExceptionEventHandler(ExceptionHandler); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledException); InitializeComponent(); swApp = SwApp; BaseNode = node; ActiveSWModel = swApp.ActiveDoc; Exporter = exporter; AutoUpdatingForm = false; jointBoxes = new Control[] { textBoxJointName, comboBoxAxis, comboBoxJointType, textBoxAxisX, textBoxAxisY, textBoxAxisZ, textBoxJointX, textBoxJointY, textBoxJointZ, textBoxJointPitch, textBoxJointRoll, textBoxJointYaw, textBoxLimitLower, textBoxLimitUpper, textBoxLimitEffort, textBoxLimitVelocity, textBoxDamping, textBoxFriction, textBoxCalibrationFalling, textBoxCalibrationRising, textBoxSoftLower, textBoxSoftUpper, textBoxKPosition, textBoxKVelocity }; linkBoxes = new Control[] { textBoxInertialOriginX, textBoxInertialOriginY, textBoxInertialOriginZ, textBoxInertialOriginRoll, textBoxInertialOriginPitch, textBoxInertialOriginYaw, textBoxVisualOriginX, textBoxVisualOriginY, textBoxVisualOriginZ, textBoxVisualOriginRoll, textBoxVisualOriginPitch, textBoxVisualOriginYaw, textBoxIxx, textBoxIxy, textBoxIxz, textBoxIyy, textBoxIyz, textBoxIzz, textBoxMass, domainUpDownRed, domainUpDownGreen, domainUpDownBlue, domainUpDownAlpha, comboBoxMaterials, textBoxTexture }; List <TextBox> numericTextBoxes = new List <TextBox>() { textBoxAxisX, textBoxAxisY, textBoxAxisZ, textBoxJointX, textBoxJointY, textBoxJointZ, textBoxJointPitch, textBoxJointRoll, textBoxJointYaw, textBoxLimitLower, textBoxLimitUpper, textBoxLimitEffort, textBoxLimitVelocity, textBoxDamping, textBoxFriction, textBoxCalibrationFalling, textBoxCalibrationRising, textBoxSoftLower, textBoxSoftUpper, textBoxKPosition, textBoxKVelocity, textBoxInertialOriginX, textBoxInertialOriginY, textBoxInertialOriginZ, textBoxInertialOriginRoll, textBoxInertialOriginPitch, textBoxInertialOriginYaw, textBoxVisualOriginX, textBoxVisualOriginY, textBoxVisualOriginZ, textBoxVisualOriginRoll, textBoxVisualOriginPitch, textBoxVisualOriginYaw, textBoxIxx, textBoxIxy, textBoxIxz, textBoxIyy, textBoxIyz, textBoxIzz, textBoxMass, textBoxMimicMultiplier, textBoxMimicOffset, }; foreach (TextBox textBox in numericTextBoxes) { textBox.KeyPress += NumericalTextBoxKeyPress; } saveConfigurationAttributeDef = SwApp.DefineAttribute(Serialization.URDF_CONFIGURATION_SW_ATTRIBUTE_NAME); int Options = 0; saveConfigurationAttributeDef.AddParameter( "data", (int)swParamType_e.swParamTypeString, 0, Options); saveConfigurationAttributeDef.AddParameter( "name", (int)swParamType_e.swParamTypeString, 0, Options); saveConfigurationAttributeDef.AddParameter( "date", (int)swParamType_e.swParamTypeString, 0, Options); saveConfigurationAttributeDef.AddParameter( "exporterVersion", (int)swParamType_e.swParamTypeDouble, 1.0, Options); saveConfigurationAttributeDef.Register(); }
/// <summary> /// Static method to define SolidWorks attributes required by StoreModel ojbects /// Must be called when the addin is loaded /// </summary> /// <param name="app">The solidworks app</param> public static void DefineAttributes(SldWorks app) { stringDataAttribute = app.DefineAttribute("gism_stringAttr"); stringDataAttribute.AddParameter("name", (int)swParamType_e.swParamTypeString, 0, 0); stringDataAttribute.AddParameter("value", (int)swParamType_e.swParamTypeString, 0, 0); stringDataAttribute.Register(); doubleDataAttribute = app.DefineAttribute("gsim_doubleAttr"); doubleDataAttribute.AddParameter("name", (int)swParamType_e.swParamTypeString, 0, 0); doubleDataAttribute.AddParameter("value", (int)swParamType_e.swParamTypeDouble, 0, 0); doubleDataAttribute.Register(); }