PCB genesis自制孔点 Font字体实现方法
一.先看genesis原有Font字體
? ? ? ? 在PCB工程CAM加孔點(diǎn)字體要求時(shí),通常我們直接用Geneis軟件給我們提供了2種孔點(diǎn)字體canned_57與canned_67,但此字體可能不能滿足各個(gè)工廠個(gè)性化需求,比如:孔密度,孔間距,孔形狀分布,如果有一些個(gè)性化需求時(shí)必須得自己可以編輯孔點(diǎn)字體才可以滿足要求,可以奧寶沒有提供這樣的工具給我們,在這里就介紹用genesis自制Font字體實(shí)現(xiàn)方法
?
二.Font字體坐標(biāo)文件制作說明
? ? ?Font字符坐標(biāo)文件放在genesis安裝目錄:C:\genesis\fw\lib\fonts\下,有2個(gè)文件canned_57與canned_67,和孔符坐標(biāo)一樣也是明文坐標(biāo),這里我們又可以借助genesis圖形界面,將Font字體坐標(biāo)讀入genesis,然對(duì)字體坐標(biāo)進(jìn)行編輯,接著再將編輯好的Font字體坐標(biāo)輸出來即可.?
? ?Font字符制作3步曲.
? 1.字體坐標(biāo)讀入==>2.編輯字體坐標(biāo)==>3.字體坐標(biāo)輸出
三.Font字體編輯孔符規(guī)則說明??
? ?1.由于借助Genesis圖形界面編輯Font字體,所以每一層分別帶表對(duì)應(yīng)的Char字符,而在Genesis層名不能使用特殊符號(hào)作為層名,這里采用ID號(hào)作對(duì)應(yīng)關(guān)系作為層名,對(duì)應(yīng)關(guān)系如下表.當(dāng)我們編輯字體坐標(biāo)時(shí),可以通過Char字符找到對(duì)應(yīng)的ID號(hào)層名。
? ? ? ??
? ? ?2.Genesis第1層的層名是rect ,帶表字符Char框架范圍,當(dāng)編輯字體時(shí),孔的中心坐標(biāo)不能超出rect范圍,如超出了可能會(huì)造成字體碰撞在一起,這里編輯字體時(shí)需注意了。
? ? ? ? ??
? ? ?3. 編輯字體比例規(guī)則:【字體寬度】字體寬度與框架寬度 有一個(gè)黃金比例關(guān)系,字體最大坐標(biāo)寬度X比框架范圍X比值為0.72,所以我們?cè)诰庉嬜煮w時(shí)要盡量尊守,并往這個(gè)比例靠籠,【字體高度】無特別要求,盡量保持字體高度與框架高度接近就好了
? ? ? ??
? ??? ? ?4. rect框架零點(diǎn)以左下角為零點(diǎn)位置,編輯字體時(shí)這個(gè)位置不能需隨意整體移動(dòng)的? ?
? ? ? ? ? ??
四.Font字體坐標(biāo)轉(zhuǎn)換關(guān)系說明
? ? ? 這里講一講,Font字體坐標(biāo)文件,Genesis UI界面參數(shù),繪制字體坐標(biāo)圖形? 三者坐標(biāo)轉(zhuǎn)換的計(jì)算公式
?
轉(zhuǎn)換實(shí)例:
?
具體坐標(biāo)轉(zhuǎn)換關(guān)系轉(zhuǎn)換計(jì)算器?http://pcbren.cn/CannedText/
五.C#代碼實(shí)現(xiàn)
? ? ?另一篇文章有介紹不用Genesis孔點(diǎn)坐標(biāo)加點(diǎn)陣字的方法,有興趣可以看一下??PCB Genesis增加點(diǎn)陣字 實(shí)現(xiàn)原理
? ? ?canned_57? ?fonts 字體讀入genesis?
//###canned_57 fonts 字體讀入genesis //1.新建一個(gè)全新的job與step//2.讀取canned_57 fonts 目錄文件// 每一種字體對(duì)應(yīng)genesis一個(gè)層 // rect層:定義字體范圍,字寬與字高范圍定義// 層名ID序號(hào):例如:用1,2,3作為層名,對(duì)應(yīng)字符Char ID號(hào)(由于genesis層名不能以符號(hào)顯示)//3.接著借助genesis對(duì)字體進(jìn)行編輯操作了string HoleFontsInputDirPath = @"C:\genesis\fw\lib\fonts\canned_57";//孔符讀取markers目錄gL RectSizeL = new gL();//rect層 做為字體坐標(biāo)范圍gP OffsetP = new gP(); //rect層 先取X值作為偏移(目前發(fā)現(xiàn)沒作用)List<List<gL>> lineAllList = new List<List<gL>>();List<gL> lineList = new List<gL>();var txtList = File.ReadAllLines(HoleFontsInputDirPath);for (int i = 0; i < txtList.Count(); i++){string LayerName = txtList[i];var arrList = txtList[i].Trim().Replace(" ", " ").Split(' ');string StartsWith = arrList[0];switch (StartsWith){case "CHAR":lineList = new List<gL>();break;case "LINE":gPoint ps = new gPoint(double.Parse(arrList[1]), double.Parse(arrList[2]));gPoint pe = new gPoint(double.Parse(arrList[3]), double.Parse(arrList[4]));double width = double.Parse(arrList[7]) * 1000;gL tempL = new gL(ps, pe, width);tempL.negative = arrList[7] == "N";lineList.Add(tempL);break;case "ECHAR":lineAllList.Add(lineList);break;case "XSIZE":RectSizeL.pe.x = double.Parse(arrList[1]);break;case "YSIZE":RectSizeL.pe.y = double.Parse(arrList[1]);RectSizeL.width = 1;break;case "OFFSET":OffsetP.p.x = double.Parse(arrList[1]);OffsetP.width = 2;break;}}g.COM($"create_layer,layer=rect");g.COM($"affected_layer,name=rect,mode=single,affected=yes");addCOM.line_rect(RectSizeL);addCOM.pad(OffsetP);g.COM($"affected_layer,name=rect,mode=single,affected=no");for (int i = 0; i < lineAllList.Count(); i++){g.COM($"create_layer,layer={i }");g.COM($"affected_layer,name={i },mode=single,affected=yes");for (int j = 0; j < lineAllList[i].Count(); j++){addCOM.line(lineAllList[i]);}g.COM($"affected_layer,name={i},mode=single,affected=no");}var pcbren = "pcbren"; View Code? ? ?canned_57? ?fonts 字體輸出
////###canned_ fonts字體輸出////1.準(zhǔn)備編輯好的字體job////2.依次遍歷genesis所有層,每一層(ID對(duì)應(yīng)一個(gè)Char字符) 并將所有層字體坐標(biāo)合并為一個(gè)文件輸出////輸出需注意兩點(diǎn)////一.輸出孔符的genesis單位要讀入孔符單位要一致(TGZ默認(rèn)數(shù)據(jù)全部用inch存儲(chǔ),保持讀取與輸出統(tǒng)一inch)////二.輸出層順序與層ID號(hào)不能修改,不然會(huì)導(dǎo)致異常////此讀取此為canned_57字符排序,輸出也按此順序輸出string CharList = @"!""#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~";var HoleFontsOutputDirPath = @"C:\Users\Administrator\Desktop\markers\";//孔符輸出markers目錄LayerNameList = g.getLayerNameList(g.STEP, g.JOB);StringBuilder StrLineAll = new StringBuilder();var layer = g.getFEATURES("rect", g.STEP, g.JOB, "inch", true);var xList = layer.Llist.Select(tt => tt.ps.x).Union(layer.Llist.Select(tt => tt.pe.x));var yList = layer.Llist.Select(tt => tt.ps.y).Union(layer.Llist.Select(tt => tt.pe.y));StrLineAll.AppendLine($"XSIZE { (xList.Max() - xList.Min()).ToString("0.000000")}");StrLineAll.AppendLine($"YSIZE { (yList.Max() - yList.Min()).ToString("0.000000")}");StrLineAll.AppendLine($"OFFSET { (layer.Plist[0].p.x).ToString("0.000000") }");StrLineAll.AppendLine("");StrLineAll.AppendLine("");for (int i = 0; i < CharList.Count(); i++){StrLineAll.AppendLine($"CHAR {CharList[i]}");foreach (var line in g.getFEATURES(i.ToString(), g.STEP, g.JOB, "inch", true).Llist){string polarity = line.negative ? "N" : "P";string symbolsStart = line.symbols.StartsWith("r") ? "R" : "S";StrLineAll.AppendLine($"LINE {line.ps.x.ToString("0.000000")} {line.ps.y.ToString("0.000000")} {line.pe.x.ToString("0.000000")} {line.pe.y.ToString("0.000000")} {polarity} {symbolsStart} {(line.width * 0.001).ToString("0.000000")}");}StrLineAll.AppendLine("ECHAR");StrLineAll.AppendLine("");}File.WriteAllText($"{HoleFontsOutputDirPath}{"canned_pcbren"}", StrLineAll.ToString());var pcbren1 = "pcbren"; View Code?六.實(shí)現(xiàn)效果
? ? ?Font坐標(biāo)讀入
?? ? ?Font坐標(biāo)輸出
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/pcbren/p/9906573.html
總結(jié)
以上是生活随笔為你收集整理的PCB genesis自制孔点 Font字体实现方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 梦到被别人亲吻是什么意思
- 下一篇: 梦到渔网破了什么意思