赞
踩
本文目标是搭建Capture CIS 17.4环境下的TCL脚本环境。使用的是ActiveTCL,Capture推荐使用8.4版本TCL,本文使用的为Active TCL 8.6。
先上链接:
假设用户已经正确安装Capture,在下载完Active TCL后,默认安装,在Windows开始菜单中能看到新增的三个程序:tkcon、Wish、Tclsh。接下来我们需要修改Capture的有关文档,具体步骤如下:
如果你对Cadence的安装根目录拥有写入权限,你需要修改capinit.tcl文件,该文件位于路径<Cadence Installation Root>\tools\capture\tclscripts。定位到capGetTclTkHome并取消以下语句的注释。
# return [file normalize {TCL/Tk_install_root}]
大括号内需要指定到ActiveTcl的安装目录。例如return [file normalize {C:/TCL}] 。注意这一操作将会影响这台电脑上使用Cadence的所有用户。
如果你未拥有Cadence的安装根目录的写入权限,你需要定位%HOME%环境变量对应的目录,在该目录下创建子目录。%HOME%\cdssetup\capture
在创建了以上目录后,你需要复制capinit.tcl 文件到新建目录并按照第一步修改capinit.tcl。
打开Capture并在Capture Command Window中输入以下命令:
- package require Tk
- toplevel .new
这两条命令会启动tk并弹出带有"new"标题的窗口。
官方提供了部分脚本代码可供学习参考。
- #package require TCL 8.6
- #package require DboTclWriteBasic 16.3.0
打开Capture进入Capture Command Window,使用source命令加载该脚本: source [file normalize {<file_path_to_capSyncPropPCBFootprint.tcl>}]
其中需要将<file_path_to_capSyncPropPCBFootprint.tcl>替换成实际的存放路径。新建Demo,创建Page,并增加/修改其中的内容。在Capture Command Window中键入
capSyncPropPCBFootprint::syncActiveDesign ReportAllDiffs
在Capture Command Window中会报告更新信息。
- #/
- # WARRANTY: NONE. THIS PROGRAM WAS WRITTEN AS "SHAREWARE" AND IS AVAILABLE AS IS
- # AND MAY NOT WORK AS ADVERTISED IN ALL ENVIRONMENTS. THERE IS NO
- # SUPPORT FOR THIS PROGRAM
- # NOTE: YOU ARE STRONGLY ADVISED TO BACKUP YOUR DESIGN
- # BEFORE RUNNING THIS PROGRAM
- # TCL file: capSyncPropPCBFootprint.tcl
- # contains OrCAD Capture Sync PCB Footprint procedures
- #/
- #package require TCL 8.4
- #package require DboTclWriteBasic 16.3.0
- package provide capSyncPropPCBFootprint 1.0
-
- namespace eval ::capSyncPropPCBFootprint {
- namespace export syncActiveDesign
- namespace export syncDesign
- variable mOldDiffs [list]
- variable mNewDiffs [list]
- }
- proc ::capSyncPropPCBFootprint::clearList { pList } {
- set pList [lreplace $pList 0 end]
- return $pList
- }
- proc ::capSyncPropPCBFootprint::visitPlacedInst { pPlacedInst pMode } {
- set lStatus [DboState]
- set lNullObj NULL
- variable mOldDiffs
- variable mNewDiffs
- set lCachedPCBFootprintNameStr [DboTclHelper_sMakeCString]
- set lPCBFootprintNameStr [DboTclHelper_sMakeCString]
- set lRefDesStr [DboTclHelper_sMakeCString]
- set lCachedPackage [$pPlacedInst GetPackage $lStatus]
- $lCachedPackage GetPCBFootprint $lCachedPCBFootprintNameStr
- $pPlacedInst GetPCBFootprint $lPCBFootprintNameStr
- set lCachedPCBFootprintName [DboTclHelper_sGetConstCharPtr $lCachedPCBFootprintNameStr]
- set lPCBFootprintName [DboTclHelper_sGetConstCharPtr $lPCBFootprintNameStr]
- if { $lCachedPCBFootprintName != "" } {
- if { $lPCBFootprintName != $lCachedPCBFootprintName} {
- $pPlacedInst GetReferenceDesignator $lRefDesStr
- set lOldSearchIndex [lsearch $mOldDiffs $pPlacedInst]
- if { $pMode == "ReportAllDiffs"} {
- lappend mOldDiffs $pPlacedInst
- set lMessage [concat $pMode " : PCB Footprint Mismatch :
- " [DboTclHelper_sGetConstCharPtr $lRefDesStr] " :
- " $lPCBFootprintName " --> " $lCachedPCBFootprintName]
- set lMessageStr [DboTclHelper_sMakeCString $lMessage]
- DboState_WriteToSessionLog $lMessageStr
- puts [DboTclHelper_sGetConstCharPtr $lMessageStr]
- }
- if { $pMode == "ReportNewDiffs"} {
- if { $lOldSearchIndex == -1} {
- lappend mNewDiffs $pPlacedInst
- set lMessage [concat $pMode " : PCB Footprint Mismatch:
- " [DboTclHelper_sGetConstCharPtr $lRefDesStr] " :
- " $lPCBFootprintName " --> " $lCachedPCBFootprintName]
- set lMessageStr [DboTclHelper_sMakeCString $lMessage]
- DboState_WriteToSessionLog $lMessageStr
- puts [DboTclHelper_sGetConstCharPtr $lMessageStr]
- }
- }
- set lNewSearchIndex [lsearch $mNewDiffs $pPlacedInst]
- if { $pMode == "UpdateNewDiffs"} {
- if { $lNewSearchIndex != -1} {
- $pPlacedInst SetPCBFootprint $lCachedPCBFootprintNameStr
- $pPlacedInst MarkModified
- set lMessage [concat $pMode " : PCB Footprint Changed :
- " [DboTclHelper_sGetConstCharPtr $lRefDesStr] " :
- " $lPCBFootprintName " --> " $lCachedPCBFootprintName]
- set lMessageStr [DboTclHelper_sMakeCString $lMessage]
- DboState_WriteToSessionLog $lMessageStr
- puts [DboTclHelper_sGetConstCharPtr $lMessageStr]
- }
- }
- if { $pMode == "UpdateAllDiffs"} {
- $pPlacedInst SetPCBFootprint $lCachedPCBFootprintNameStr
- $pPlacedInst MarkModified
- set lMessage [concat $pMode " : PCB Footprint Changed :
- " [DboTclHelper_sGetConstCharPtr $lRefDesStr] " :
- " $lPCBFootprintName " --> " $lCachedPCBFootprintName]
- set lMessageStr [DboTclHelper_sMakeCString $lMessage]
- DboState_WriteToSessionLog $lMessageStr
- puts [DboTclHelper_sGetConstCharPtr $lMessageStr]
- }
- }
- }
- $lStatus -delete
- return
- }
- proc ::capSyncPropPCBFootprint::visitPageInsts { pPage pMode } {
- set lStatus [DboState]
- set lPartInstIter [$pPage NewPartInstsIter $lStatus]
- set lPartInst [$lPartInstIter NextPartInst $lStatus]
- set lNullObj NULL
- while {$lPartInst!=$lNullObj} {
- set lPlacedInst [DboPartInstToDboPlacedInst $lPartInst]
- if {$lPlacedInst != $lNullObj} {
- visitPlacedInst $lPlacedInst $pMode
- }
- set lPartInst [$lPartInstIter NextPartInst $lStatus]
- }
- delete_DboPagePartInstsIter $lPartInstIter
- $lStatus -delete
- return
- }
- proc ::capSyncPropPCBFootprint::visitPages { pSchematic pMode } {
- set lStatus [DboState]
- set lPagesIter [$pSchematic NewPagesIter $lStatus]
- set lPage [$lPagesIter NextPage $lStatus]
- set lNullObj NULL
- while {$lPage!=$lNullObj} {
- visitPageInsts $lPage $pMode
- set lPage [$lPagesIter NextPage $lStatus]
- }
- delete_DboSchematicPagesIter $lPagesIter
- $lStatus -delete
- return
- }
- proc ::capSyncPropPCBFootprint::visitSchematics { pDesign pMode } {
- set lStatus [DboState]
- set lSchematicIter [$pDesign NewViewsIter $lStatus $::IterDefs_SCHEMATICS]
- set lSchematic [$lSchematicIter NextView $lStatus]
- set lNullObj NULL
- while { $lSchematic!= $lNullObj} {
- set lObj [DboViewToDboSchematic $lSchematic]
- visitPages $lObj $pMode
- set lSchematic [$lSchematicIter NextView $lStatus]
- }
- delete_DboLibViewsIter $lSchematicIter
- $lStatus -delete
- return
- }
- # pMode = ReportAllDiffs | ReportNewDiffs | UpdateAllDiffs | UpdateNewDiffs
- proc ::capSyncPropPCBFootprint::syncActiveDesign { pMode } {
- set lMessage "---------------------------------------------------------------------------------"
- set lMessageStr [DboTclHelper_sMakeCString $lMessage]
- DboState_WriteToSessionLog $lMessageStr
- puts [DboTclHelper_sGetConstCharPtr $lMessageStr]
- set lSession $::DboSession_s_pDboSession
- DboSession -this $lSession
- set lNullObj NULL
- set lDesign [$lSession GetActiveDesign]
- if { $lDesign == $lNullObj} {
- set lError [DboTclHelper_sMakeCString "Active design not found"]
- DboState_WriteToSessionLog $lError
- puts [DboTclHelper_sGetConstCharPtr $lError]
- return
- }
- variable mOldDiffs
- variable mNewDiffs
- if {$pMode == "ReportAllDiffs"} {
- set mOldDiffs [clearList $mOldDiffs]
- set mNewDiffs [clearList $mNewDiffs]
- }
- if {$pMode == "ReportNewDiffs"} {
- set mOldDiffs [concat $mOldDiffs $mNewDiffs]
- set mNewDiffs [clearList $mNewDiffs]
- }
- #updateNewDiffs should forcibly call ReportNewDiffs first
- if {$pMode == "UpdateNewDiffs"} {
- set mNewDiffs [clearList $mNewDiffs]
- visitSchematics $lDesign "ReportNewDiffs"
- }
- #updateNewDiffs should forcibly call ReportAllDiffs first
- if {$pMode == "UpdateAllDiffs"} {
- set mOldDiffs [clearList $mOldDiffs]
- set mNewDiffs [clearList $mNewDiffs]
- visitSchematics $lDesign "ReportAllDiffs"
- }
- visitSchematics $lDesign $pMode
- if {$pMode == "UpdateAllDiffs"} {
- set mOldDiffs [clearList $mOldDiffs]
- set mNewDiffs [clearList $mNewDiffs]
- }
- if {$pMode == "UpdateNewDiffs"} {
- set mNewDiffs [clearList $mNewDiffs]
- }
- DboTclHelper_sReleaseAllCreatedPtrs
- set lMessage "---------------------------------------------------------------------------------"
- set lMessageStr [DboTclHelper_sMakeCString $lMessage]
- DboState_WriteToSessionLog $lMessageStr
- puts [DboTclHelper_sGetConstCharPtr $lMessageStr]
- return
- }
- # pMode = ReportAllDiffs | UpdateAllDiffs
- proc ::capSyncPropPCBFootprint::syncDesign { pDesignPath pMode } {
- set lMessage "---------------------------------------------------------------------------------"
- set lMessageStr [DboTclHelper_sMakeCString $lMessage]
- DboState_WriteToSessionLog $lMessageStr
- puts [DboTclHelper_sGetConstCharPtr $lMessageStr]
- set lSession [DboTclHelper_sCreateSession]
- set lStatus [DboState]
- set lDesignPath [DboTclHelper_sMakeCString $pDesignPath]
- set lDesign [DboSession_GetDesignAndSchematics $lSession $lDesignPath $lStatus]
- set lNullObj NULL
-
- if { $lDesign == $lNullObj} {
- set lError [DboTclHelper_sMakeCString [concat "Design not found : " $pDesignPath]]
- DboState_WriteToSessionLog $lError
- puts [DboTclHelper_sGetConstCharPtr $lError]
- return
- }
- variable mOldDiffs
- variable mNewDiffs
- if {$pMode == "ReportAllDiffs"} {
- set mOldDiffs [clearList $mOldDiffs]
- set mNewDiffs [clearList $mNewDiffs]
- }
- visitSchematics $lDesign $pMode
- if {$pMode == "UpdateAllDiffs"} {
- $lSession MarkAllLibForSave $lDesign
- $lSession SaveDesign $lDesign
- }
- if {$pMode == "UpdateAllDiffs"} {
- set mOldDiffs [clearList $mOldDiffs]
- set mNewDiffs [clearList $mNewDiffs]
- }
- $lSession RemoveDesign $lDesign
- delete_DboSession $lSession
- $lStatus -delete
- DboTclHelper_sReleaseAllCreatedPtrs
- set lMessage "---------------------------------------------------------------------------------"
- set lMessageStr [DboTclHelper_sMakeCString $lMessage]
- DboState_WriteToSessionLog $lMessageStr
- puts [DboTclHelper_sGetConstCharPtr $lMessageStr]
- return
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。