程式語言:Tcl
Orcad 官方文件
GitHub 範例
功能:可用 Tcl 語言控制 Orcad
得到 Parts 的 attributes
得到 wire attributes
其他範例可參考官方文件的 3.2.2~3.2.28.6
Welcome to the Tclers Wiki!
Orcad 官方文件
GitHub 範例
功能:可用 Tcl 語言控制 Orcad
執行方法
View->Toolbar->Command Window Menu查詢指令
- 查詢
- info command *xxx*
- 印出目前動作指令
- SetOptionBool Journaling TRUE
SetOptionBool DisplayCommands TRUE - 記錄動作過程的指令
- Macro -> record
Macro -> configure -> saveas
基本介紹
- Design Database Object Model
- 使用於電路
- Library Database Object Model
- 使用於 library
- Database class hierarchy
- 查詢指令必須連同繼承的一併查詢,才足夠完整
例如:DboLib
info commands DboLib_* 和 info commands DboBaseObject_* - 基本
- 變數
- 賦值
- 名字前不用加上 $
- set x 20
- 印值
- 名字前需加上 $
- puts $x
- command 中的 subcommand
- [subcommand]
- puts [set x 20]
- 可多個,不限定個數
- 字串
- puts "xxx $abc"
後者的 $abc 將被當作變數替換掉 - puts {xxx $abc}
當作 raw data 直接輸出 xxx $abc - List
- 賦值:list xxx yyy
- set ls [list "Cadence Design" Systems]
- 長度:llength $ls
- puts [llength $ls]
- 第 n 個的值:lindex $ls n
- puts [lindex $ls 0]
- 數學
- expr
- puts [expr $j-$i]
- expr abs($x)
- 可參考 expr function
- 自定函數
- proc
- proc mul {i j} {
expr {$i*$j}
} - 輸入變數前不用加上 $
- if、foreach、proc 等的大括號 { 必須在同一行,不然會出錯
- Tcl 版本
- puts $tcl_version
- 呼叫的方法
- command_with_classname $object <parameters>
- DboLib_GetName $lLib $lName
- $object command_without_classname <parameters>
- $lLib GetName $lName
- 字串轉換
- set lName [DboTclHelper_sMakeCString]
- 因大部分的指令參數皆為 CString,需進行轉換
- puts [DboTclHelper_sGetConstCharPtr $lName]
- 要印出時,還得再轉換回來
- 內建的轉換函式
- DboTclHelper_sMakeLOGFONT
- DboTclHelper_sMakeBitmap
- DboTclHelper_sMakeBitMapData
- DboTclHelper_sMakeDboValue
- DboTclHelper_sMakeStdVector
- DboTclHelper_sMakeInt
- DboTclHelper_sMakeStdStr
- DboTclHelper_sMakeCPoint
- DboTclHelper_sMakeCString
- DboTclHelper_sMakeDboValueType
- DboTclHelper_sMakeCRect
- DboTclHelper_sGetCRectTopLeft
- DboTclHelper_sGetCPointX
- DboTclHelper_sGetCPointY
- DboTclHelper_sGetVectorSize
- DboTclHelper_sGetConstCharPtr
- DboTclHelper_sGetCRectBottomRight
- DboTclHelper_sGetConstCharPtrFromVector
- source {xxx.tcl}
- 執行 tcl script
- set lSelObjs [GetSelectedObjects]
- 得到選取的物件
- RegisterAction <Label> <Enabler> <Accel> <Callback> <ViewType>
- 註冊指令至右鍵 more
- <Label>
- 顯示的名字
- <Enabler>
- Enable 的條件
- <Accel>
- 快捷鍵
- <Callback>
- 執行的 function
- <ViewType>
- 指定可作用的 View,例: Schematic, PM, Empty; Value
RegisterAction "Context-Aware Rotate" "::capGUIUtils::capCARotateEnabler" "Ctrl+R" "::capGUIUtils::capCARotate" "Schematic
- # get the name
- set lName [DboTclHelper_sMakeCString]
- $lInst GetName $lName
- # get the location point
- set lLocation [$lInst GetLocation $lStatus]
- # get the location x
- set lStartx [DboTclHelper_sGetCPointX $lLocation]
- # get the location y
- set lStarty [DboTclHelper_sGetCPointY $lLocation]
- # get the source library name
- set lLibName [DboTclHelper_sMakeCString]
- $lInst GetSourceLibName $lLibName
- # get the device designator
- set lDeviceDesignator [DboTclHelper_sMakeCString]
- $lInst GetReferenceDesignator $lDeviceDesignator
- # get the rotation
- set lRot [$lInst GetRotation $lStatus]
- #get the contents lib name
- set lContentsLibName [DboTclHelper_sMakeCString]
- $lInst GetContentsLibName $lContentsLibName
- # get the contents view name
- set lContentsViewName [DboTclHelper_sMakeCString]
- $lInst GetContentsViewName $lContentsViewName
- # get the contents view type
- set lType [$lInst GetContentsViewType $lStatus]
- # get the primitive type
- set lPrimitiveType [$lInst GetIsPrimitiveProp $lStatus]
- # get the part value
- set lValue [DboTclHelper_sMakeCString]
- $lInst GetPartValue $lValue
- # get the reference
- set lReferenceName [DboTclHelper_sMakeCString]
- $lInst GetReference $lReferenceName
- # get the bounding box on the page
- set lBBox [$lInst GetOffsetBoundingBox $lStatus]
- # get the top-left of the bbox
- set lTopLeft [DboTclHelper_sGetCRectTopLeft $lBBox]
- # get the bottom-right of the bbox
- set lBottomRight [DboTclHelper_sGetCRectBottomRight $lBBox]
- # get the x1
- set lStartx [DboTclHelper_sGetCPointX $lTopLeft]
- # get the y1
- set lStarty [DboTclHelper_sGetCPointY $lTopLeft]
- # get the x2
- set lEndx [DboTclHelper_sGetCPointX $lBottomRight]
- # get the y2
- set lEndy [DboTclHelper_sGetCPointY $lBottomRight]
- # get the name
- set lName [DboTclHelper_sMakeCString]
- $ lWire GetName $lName
- # get the net name
- set lNetName [DboTclHelper_sMakeCString]
- $lWire GetNetName $lNetName
- # get the start point
- set lStart [$lWire GetStartPoint $lStatus]
- set lStartx [DboTclHelper_sGetCPointX $lStart]
- set lStarty [DboTclHelper_sGetCPointY $lStart]
- # get the end point
- set lEnd [$lWire GetEndPoint $lStatus]
- set lEndx [DboTclHelper_sGetCPointX $lEnd]
- set lEndy [DboTclHelper_sGetCPointY $lEnd]
- # get the color
- set lColor [$lWire GetColor $lStatus]
- # get the net
- set lNet [$lWire GetNet $lStatus]
程式碼
Custom_Launch.tcl
放到右鍵執行
放到右鍵執行
showProperty.tcl
顯示所有的 Property
顯示所有的 Property
replaceGlobalPower.tcl
取代 Global Power 改為命名的線
取代 Global Power 改為命名的線
AddNetsToParts.tcl
將 Parts 的 Pin 畫上線
將 Parts 的 Pin 畫上線
controlDBC.tcl
控制 Database
控制 Database
參考
Tcl/Tk 教學文件Welcome to the Tclers Wiki!
留言
張貼留言