private void button_chrono_property_Click(object sender, EventArgs e)
{
ModelDoc2 swModel;
swModel = (ModelDoc2)this.mSWApplication.ActiveDoc;
if (swModel == null)
{
System.Windows.Forms.MessageBox.Show("Please open an assembly and select a part!");
return;
}
SelectionMgr swSelMgr = (SelectionMgr)swModel.SelectionManager;
if (swSelMgr.GetSelectedObjectCount2(-1) == 0)
{
System.Windows.Forms.MessageBox.Show("Please select one or more parts!");
return;
}
/*
//***TEST***
AttributeDef defattr_test = (AttributeDef)this.mSWApplication.DefineAttribute("mytestt");
defattr_test.AddParameter("testpar", (int)swParamType_e.swParamTypeDouble, 0.6, 0);
defattr_test.Register();
Component2 swPart = (Component2)swSelMgr.GetSelectedObject6(1, -1);
ModelDoc2 swPartModel = (ModelDoc2)swPart.GetModelDoc2();
//ModelDoc2 swModel = (ModelDoc2)this.ActiveDoc;
System.Windows.Forms.MessageBox.Show("attach, v CreateInstance5");
SolidWorks.Interop.sldworks.Attribute myattr = defattr_test.CreateInstance5(swModel, swPart, "test_data", 0, (int)swInConfigurationOpts_e.swAllConfiguration);
*/
bool selected_part = false;
for (int isel = 1; isel <= swSelMgr.GetSelectedObjectCount2(-1); isel++)
if ((swSelectType_e)swSelMgr.GetSelectedObjectType3(isel, -1) == swSelectType_e.swSelCOMPONENTS)
{
selected_part = true;
}
if (!selected_part)
{
System.Windows.Forms.MessageBox.Show("Chrono properties can be edited only for parts! Select one or more parts before using it.");
return;
}
// Open modal dialog
EditChBody myCustomerDialog = new EditChBody();
// Update dialog properties properties from the selected part(s) (i.e. ChBody in C::E)
myCustomerDialog.UpdateFromSelection(swSelMgr, ref this.mSWintegration.defattr_chbody); //ref this.mSWintegration.defattr_chconveyor);
// Show the modal dialog
if (myCustomerDialog.ShowDialog() == DialogResult.OK)
{
// If user pressed OK, apply settings to all selected parts (i.e. ChBody in C::E):
myCustomerDialog.StoreToSelection(swSelMgr, ref this.mSWintegration.defattr_chbody);//ref this.mSWintegration.defattr_chconveyor);
}
}