private static void GetAndSetDrawingNo(IModelDoc2 modDoc) { string fileName; string pattern; string drawingNoEnd; string drawingNoPre; fileName = modDoc.GetTitle(); //去除后缀 fileName = fileName.Substring(0, fileName.LastIndexOf(".")); //正则提取5位图号 pattern = "((a|A)?[0-9]{3,5})(a|A)?$"; drawingNoEnd = Regex.Match(fileName, pattern).Value; //从配置文件获取前缀 drawingNoPre = ConfigurationManipulate.GetConfigValue("图号前缀"); //将提取的5位图号写入自定义属性 if (drawingNoEnd != "") { modDoc.AddCustomInfo("图号", "文字", drawingNoPre + drawingNoEnd); modDoc.set_CustomInfo("图号", drawingNoPre + drawingNoEnd); } else { modDoc.AddCustomInfo("图号", "文字", "外购件"); modDoc.set_CustomInfo("图号", "外购件"); } }
public dynamic RandomColorValues(dynamic materialPropertyValues) { Random random = new Random(); float red = 0, green = 0, blue = 0; int dyeMode; dyeMode = Convert.ToInt16(ConfigurationManipulate.GetConfigValue("颜色增益")); while (red < 0.4 & green < 0.4 & blue < 0.6) { red = ((float)random.Next(0, 256)) / 256; green = ((float)random.Next(0, 256)) / 256; blue = ((float)random.Next(0, 256)) / 256; } if (dyeMode > 127) { red = (255 - dyeMode) / 128 * (1 - red) + red; green = (255 - dyeMode) / 128 * (1 - green) + green; blue = (255 - dyeMode) / 128 * (1 - blue) + blue; } else if (dyeMode < 127) { red = red * dyeMode / 128; green = green * dyeMode / 128; blue = blue * dyeMode / 128; } return(materialPropertyValues); }
private void GetAndSetDrawingNo(IModelDoc2 modDoc) { string fileName; string pattern; string drawingNoEnd; string drawingNoPre; ICustomPropertyManager cPropertyMan; SolidWorks.Interop.sldworks.Configuration configuration; configuration = modDoc.ConfigurationManager.ActiveConfiguration; cPropertyMan = modDoc.Extension.get_CustomPropertyManager(configuration.Name); fileName = modDoc.GetTitle(); //去除后缀 fileName = fileName.Substring(0, fileName.LastIndexOf(".")); //正则提取5位图号 pattern = "((a|A)?[0-9]{3,5})(a|A)?$"; drawingNoEnd = Regex.Match(fileName, pattern).Value; //从配置文件获取前缀 drawingNoPre = ConfigurationManipulate.GetConfigValue("图号前缀"); //将提取的5位图号写入自定义属性 cPropertyMan.Delete("图号"); if (drawingNoEnd != "") { cPropertyMan.Add2("图号", 30, drawingNoPre + drawingNoEnd); } else { cPropertyMan.Add2("图号", 30, "外购件"); } }
private void button1_Click(object sender, EventArgs e) { ConfigurationManipulate.SetConfigValue("图号前缀", this.textBox1.Text); ConfigurationManipulate.SetConfigValue("颜色增益", this.trackBar1.Value.ToString()); this.Close(); }
public Form1() { InitializeComponent(); this.textBox1.Text = ConfigurationManipulate.GetConfigValue("图号前缀"); this.trackBar1.Value = Convert.ToInt16(ConfigurationManipulate.GetConfigValue("颜色增益")); }