public static string AddAttValueByName(string AtrName, ModelDoc2 swModel, string Value) { string cfgname2 = swModel.ConfigurationManager.ActiveConfiguration.Name; CustomPropertyManager cpmMdl = swModel.Extension.get_CustomPropertyManager(cfgname2); int outval = 30; string sovVal = ""; // cpmMdl.Set(AtrName, Value); cpmMdl.Add2(AtrName, outval, Value); return(sovVal); }
public void Commit() { #region 00. 提交尺寸 EquationMgr emgr = (EquationMgr)swDoc.GetEquationMgr(); int ic = emgr.GetCount(); for (int i = 0; i < ic; i++) { //在这里想办法只获取全局变量 string s = emgr.get_Equation(i); if (s.Contains("@")) { continue; } s = s.Replace("\"", ""); s = s.Remove(s.IndexOf('=')); s = s.Trim(); s = s.ToUpper(); if (Sizes.ContainsKey(s)) { if (Sizes[s] != _Sizes[s]) { string Equation = JswFunc.FormatEquation(s, Sizes[s].ToString()); emgr.set_Equation(i, Equation); } } else { if (_Sizes.ContainsKey(s)) { emgr.Delete(i); i--; ic--; } } } //foreach (string key in Sizes.Keys) //{ // if (Sizes[key] != _Sizes[key]) // { // JswFunc.SetEquationValueByName(swDoc, key, Sizes[key]); // } //} _Sizes = new Dictionary <string, object>(Sizes); #endregion #region 10. 提交属性 string cfgname2 = swDoc.ConfigurationManager.ActiveConfiguration.Name; CustomPropertyManager cpmMdl = swDoc.Extension.get_CustomPropertyManager(cfgname2); //修改属性 foreach (string key in Attrs.Keys) { if (_Attrs.ContainsKey(key)) { if (Attrs[key] != _Attrs[key]) { cpmMdl.Set(key, Attrs[key]); } } else { //如果该Key在_Attrs中找不到,表示为新增的属性 int outval = 30; string sovVal = ""; // cpmMdl.Set(AtrName, Value); cpmMdl.Add2(key, outval, Attrs[key]); } } //清理已经删除的属性 foreach (string key in _Attrs.Keys) { if (!Attrs.ContainsKey(key)) { //旧属性不在新列表中,表示该属性已被删除。 cpmMdl.Delete(key); } } _Attrs = new Dictionary <string, string>(Attrs); #endregion }
private void SaveAll() { try { int intVal; SwConfig = (Configuration)SwModel.GetConfigurationByName((string)CboxConfigName.SelectedValue); CustomPropertyManager swConfigCustMgr = SwConfig.CustomPropertyManager; intVal = swConfigCustMgr.Add2(TextBox1.Text, (int)swCustomInfoType_e.swCustomInfoText, TextBoxDeaNo.Text); if (intVal == -1) { intVal = swConfigCustMgr.Set(TextBox1.Text, TextBoxDeaNo.Text.Trim()); } intVal = swConfigCustMgr.Add2(TextBox2.Text, (int)swCustomInfoType_e.swCustomInfoText, TextBoxName.Text); if (intVal == -1) { intVal = swConfigCustMgr.Set(TextBox2.Text, TextBoxName.Text.Trim()); } intVal = swConfigCustMgr.Add2(TextBox3.Text, (int)swCustomInfoType_e.swCustomInfoText, TextBoxDesigner.Text); if (intVal == -1) { intVal = swConfigCustMgr.Set(TextBox3.Text, TextBoxDesigner.Text.Trim()); } intVal = swConfigCustMgr.Add2(TextBox4.Text, (int)swCustomInfoType_e.swCustomInfoDate, DatePickerDesignDate.SelectedDate.ToString()); if (intVal == -1) { intVal = swConfigCustMgr.Set(TextBox4.Text, DatePickerDesignDate.SelectedDate.ToString().Trim()); } intVal = SwCustPropMgr.Add2(TextBox5.Text, (int)swCustomInfoType_e.swCustomInfoText, TextBoxDwgNo.Text); if (intVal == 0) { intVal = SwCustPropMgr.Set(TextBox5.Text, TextBoxDwgNo.Text.Trim()); } intVal = SwCustPropMgr.Add2(TextBox6.Text, (int)swCustomInfoType_e.swCustomInfoText, TextBoxDwgName.Text); if (intVal == 0) { intVal = SwCustPropMgr.Set(TextBox6.Text, TextBoxDwgName.Text.Trim()); } intVal = SwCustPropMgr.Add2(TextBox7.Text, (int)swCustomInfoType_e.swCustomInfoText, TextBoxNote.Text); if (intVal == 0) { intVal = SwCustPropMgr.Set(TextBox7.Text, TextBoxNote.Text.Trim()); } //intVal = swCustPropMgr.Set(textBox5.Text, textBoxDwgNo.Text); //intVal = swCustPropMgr.Set(textBox6.Text, textBoxDwgName.Text); //intVal = swCustPropMgr.Set(textBox7.Text, textBoxNote.Text); SwModel.ForceRebuild3(true); TextColorReset(); TextBlock.Text = "写入完成。"; } catch (Exception ex) { throw ex; } //this.Hide(); //System.Threading.Thread th = new System.Threading.Thread(new System.Threading.ThreadStart(msg)); //th.Start(); //System.Threading.Thread.Sleep(1000); //System.Environment.Exit(0); this.Close(); }