python整理pads logic原理圖

  1. 打開原理圖,點擊“file”,“export”

    pads logic offpage 標籤對齊方法
  2. 輸出ASCII文件到指定位置,跳出設置框,點擊“select all”,“OK”

    pads logic offpage 標籤對齊方法
    pads logic offpage 標籤對齊方法
  3. 用notepad++或editplus等記事本軟件打開,搜索netnames,儘量不要選擇記事本,因爲notepad++有一個很重要的技巧,能夠同時操作多行,詳見經驗“怎樣在Notepad++中列選”

    pads logic offpage 標籤對齊方法
  4. 每行各項所對應含義爲,netname itemname x y ori just shx shy shori shjust shn fontinfo,

    其中Justification of the text string 

    The value is a bit string as follows: 

    Bit 0 = 0 Left justified or center (X direction) justified Bit 0 = 1 Right justified 

    Bit 1 = 0 Bottom justified or middle (Y direction) justified Bit 1 = 1 Top justified 

    Bit 2 = 0 Left or right justified Bit 2 = 1 Center justified 

    Bit 3 = 0 Bottom or top justified Bit 3 = 1 Middle justified. 

    When text is rotated the definitions for bits 0 and 1 are interchanged.

    pads logic offpage 標籤對齊方法
    pads logic offpage 標籤對齊方法
  5. 5

    把對應值改爲相同的值,在pads logic新建一個空的原理圖,點擊“file”,“import”

    pads logic offpage 標籤對齊方法

更進一步可以編寫腳本,實現自動對齊。

#!/usr/bin/python
# -*- coding: UTF-8 -*-

filepath = input("Please input the filepath:\n(In Powershell you can drag and drop the file!!!)\n")

file = open(filepath,"r")

rows = file.readlines()

lines = []
line = []
flag = 0
data = []
str_data = ""
str_row = ""
for row in rows:
	str_row = row
	if ("*NETNAMES*") in row:
		flag = 1
		print("flag changed: 0--1")
	elif flag == 1 and (("*SHT*") in row  or ("*END*") in row):
		flag = 0
		lines.append(line)
		line = []
		print("flag changed: 1--0")
	elif flag == 1:
		#line.append(row)
		data = row.split()
		if len(data) > 1:
			data[3] = "0"
			data[7] = "40"
			data[11] = "20"
			if data[4] == "90":
				data[2] = "0"
				data[3] = "400"
				data[6] = "-40"
				data[7] = "800"
				data[5] = "8"
				data[8] = "90"
				data[10] = "10"
			elif data[2][0] == "-":
				data[2] = "-400"
				data[6] = "-800"
				data[5] = "9"
				data[10] = "8"
			else:
				data[2] = "400"
				data[6] = "1000"
				data[5] = "8"
				data[10] = "9"
			#if data[0] == "VSYS" or data[0] == "VIO1V8":
				
			if data[0] != "GND":
				str_row = ""
				for d1 in data:
					str_row += (d1 + " ")
				str_row += "\n"
				
	else:
		flag = flag
	str_data += str_row
		
filepath1 = input("Please input the target file:\nBy default, you can press \"Enter\" directly!\nThe file will be rewrited!")
if filepath1 == "":
	filepath1 = filepath

file = open(filepath1,"w")
file.write(str_data)
file.close()

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章