原理图设计时,器件的引脚类型如果定义不恰当,进行DRC检查时,会造成报错。这个错误不至于致命,但有强迫症的你,也许觉得非常不爽。但解除此问题,又费时费力,需要单独修改库文件,再更新原理图。此时,使用此脚本,直接在原理图上对引脚类型有问题的器件的引脚直接修改类型,可以高效解决此问题。本设计定义的快捷键为shift+P,选择引脚后,直接快捷键,会弹出类型对话框,供选择引脚类型。
当前脚本放入X:\Cadence\SPB_16.6\tools\capture\tclscripts\capAutoLoad\XXX\目录,其中XXX为处定义的文件夹
思路来源于官网。
上代码:
# reference https://community.cadence.com/cadence_technology_forums/pcb-design/f/allegro-x-capture-cis/58258/problem-with-tcl-code-to-change-pintype-on-symbol-within-a-schematic
package require Tcl 8.4
namespace eval ::PinTypeModifyApp {} {
RegisterAction "PinType Modify online" "::PinTypeModifyApp::Enabler" "Shift+P" "::PinTypeModifyApp::PinTypeWininit" "Schematic"
variable selectedOption 7
variable symbolPin
variable lInst
variable pinFound 0
}
proc ::PinTypeModifyApp::Enabler { } {
set result 0
set lObj [lindex [GetSelectedObjects] 0]
set lObjType [$lObj GetObjectType]
if {$lObjType == $::DboBaseObject_PORT_INSTANCE_SCALAR} {
set result 1
}
return $result
}
proc ::PinTypeModifyApp::PinTypeWininit { } {
wm withdraw .
toplevel .pinTypeWin
wm attributes .pinTypeWin -toolwindow 1
wm attributes .pinTypeWin -topmost 1
wm title .pinTypeWin "Pin type select -by jadystone"
wm geometry .pinTypeWin -300+250
# $::DboValue_DBO_IN 0
# $::DboValue_IO 1
# $::DboValue_DBO_OUT 2
# $::DboValue_OC 3
# $::DboValue_PAS 4
# $::DboValue_HIZ 5
# $::DboValue_OE 6
# $::DboValue_POWER 7
labelframe .pinTypeWin.frame -text "Pin type" -borderwidth 2 -relief ridge
radiobutton .pinTypeWin.frame.rdbtnSel0 -text "0. INPUT" -variable ::PinTypeModifyApp::selectedOption -value 0
radiobutton .pinTypeWin.frame.rdbtnSel1 -text "1. IO" -variable ::PinTypeModifyApp::selectedOption -value 1
radiobutton .pinTypeWin.frame.rdbtnSel2 -text "2. OUTPUT" -variable ::PinTypeModifyApp::selectedOption -value 2
radiobutton .pinTypeWin.frame.rdbtnSel3 -text "3. Open Collector" -variable ::PinTypeModifyApp::selectedOption -value 3
radiobutton .pinTypeWin.frame.rdbtnSel4 -text "4. Passive" -variable ::PinTypeModifyApp::selectedOption -value 4
radiobutton .pinTypeWin.frame.rdbtnSel5 -text "5. HiZ" -variable ::PinTypeModifyApp::selectedOption -value 5
radiobutton .pinTypeWin.frame.rdbtnSel6 -text "6. Open Emitter" -variable ::PinTypeModifyApp::selectedOption -value 6
radiobutton .pinTypeWin.frame.rdbtnSel7 -text "7. Power" -variable ::PinTypeModifyApp::selectedOption -value 7
button .pinTypeWin.button -text "Ok" -command {
::PinTypeModifyApp::PinTypeModify
if {$::PinTypeModifyApp::pinFound} {
$::PinTypeModifyApp::symbolPin SetPinType $::PinTypeModifyApp::selectedOption
$::PinTypeModifyApp::symbolPin MarkModified
$::PinTypeModifyApp::lInst MarkModified
}
destroy .pinTypeWin
}
grid .pinTypeWin.frame -row 0 -column 0 -padx 15 -pady 10
grid .pinTypeWin.frame.rdbtnSel0 -row 0 -column 0 -sticky w
grid .pinTypeWin.frame.rdbtnSel1 -row 1 -column 0 -sticky w
grid .pinTypeWin.frame.rdbtnSel2 -row 2 -column 0 -sticky w
grid .pinTypeWin.frame.rdbtnSel3 -row 3 -column 0 -sticky w
grid .pinTypeWin.frame.rdbtnSel4 -row 4 -column 0 -sticky w
grid .pinTypeWin.frame.rdbtnSel5 -row 5 -column 0 -sticky w
grid .pinTypeWin.frame.rdbtnSel6 -row 6 -column 0 -sticky w
grid .pinTypeWin.frame.rdbtnSel7 -row 7 -column 0 -sticky w
grid .pinTypeWin.button -row 1 -column 0 -padx 10 -pady 10
}
proc ::PinTypeModifyApp::PinTypeModify { } {
set lStatus [DboState]
set lNullObj NULL
set lSelObjs [GetSelectedObjects]
set lPin [lindex $lSelObjs 0]
set ::PinTypeModifyApp::lInst [$lPin GetOwner ]
set lPinName [DboTclHelper_sMakeCString]
$lPin GetPinName $lPinName
set PinnameStr [DboTclHelper_sGetConstCharPtr $lPinName]
puts "PinnameStr=$PinnameStr"
#Convert PartInst to PlacedInst
set lPlacedInst [DboPartInstToDboPlacedInst $::PinTypeModifyApp::lInst]
#Get DboLibPart from the Placed Inst, 此为关键点,只有libPart才能修改
set lPart [$lPlacedInst GetPart $lStatus]
# scan DboSymbolPinsIter through pins of instance
set ::PinTypeModifyApp::pinFound 0
set lpinIter [$lPart NewPinsIter $lStatus]
if {$lpinIter != $lNullObj} {
#get 1st pin handle
set lPin [$lpinIter NextPin $lStatus]
while {$lPin !=$lNullObj} {
set lPinName [DboTclHelper_sMakeCString]
$lPin GetPinName $lPinName
set PinName [DboTclHelper_sGetConstCharPtr $lPinname]
puts "PinName=$PinName"
if {$PinnameStr == $PinName} {
set ::PinTypeModifyApp::pinFound 1
set ::PinTypeModifyApp::symbolPin $lPin
break
}
set lPin [$lpinIter NextPin $lStatus]
}
delete_DboSymbolPinsIter $lpinIter
}
}