Cadence OrCAD Capture TCL/TK脚本实例

获取当前Session

set lSession $::DboSession_s_pDboSession
DboSession -this $lSession

创建新的Session

set lSession [DboTclHelper_sCreateSession]

获取Session的设计

set lStatus [DboState]
# 指定设计路径名称
# set pDesignPath d:/spb163/tools/capture/samples/fulladd.dsn 
set lDesignPath [DboTclHelper_sMakeCString $pDesignPath]
set lDesign [$lSession GetDesignAndSchematics $lDesignPath $lStatus]

遍历Session中所有的设计

set lDesignsIter [$lSession NewDesignsIter $lStatus]
#get the first design
set lDesign [$lDesignsIter NextDesign $lStatus]
set lNullObj NULL
while { $lDesign!= $lNullObj} {
#placeholder: do your processing on $lDesign
#get the next design
set lDesign [$lDesignsIter NextDesign $lStatus]
}
delete_DboSessionDesignsIter $lDesignsIter

获取设计中的原理图

# set pSchematicName SCHEMATIC1  EXAMPLE
set lSchematicName [DboTclHelper_sMakeCString $pSchematicName]
set lSchematic [$lDesign GetSchematic $lSchematicName $lStatus]

遍历设计中的所有原理图

set lSchematicIter [$lDesign NewViewsIter $lStatus $::IterDefs_SCHEMATICS]
#get the first schematic view
set lView [$lSchematicIter NextView $lStatus]
set lNullObj NULL
while { $lView != $lNullObj} {
#dynamic cast from DboView to DboSchematic
set lSchematic [DboViewToDboSchematic $lView]
#placeholder: do your processing on $lSchematic
#get the next schematic view
set lView [$lSchematicIter NextView $lStatus]
}
delete_DboLibViewsIter $lSchematicIter

获取原理图中的页

# set pPageName PAGE1  EXAMPLE
set lPageName [DboTclHelper_sMakeCString $pPageName]
set lPage [$lSchematic GetPage $lPageName $lStatus]

遍历原理图中所有页

set lPagesIter [$lSchematic NewPagesIter $lStatus]
#get the first page
set lPage [$lPagesIter NextPage $lStatus]
set lNullObj NULL
while {$lPage!=$lNullObj} {
#placeholder: do your processing on $lPage
#get the next page
set lPage [$lPagesIter NextPage $lStatus]
}
delete_DboSchematicPagesIter $lPagesIter

遍历原理图页中所有元件实例

set lPartInstsIter [$lPage NewPartInstsIter $lStatus]
#get the first part inst
set lInst [$lPartInstsIter NextPartInst $lStatus]
while {$lInst!=$lNullObj} {
#dynamic cast from DboPartInst to DboPlacedInst
set lPlacedInst [DboPartInstToDboPlacedInst $lInst]
if {$lPlacedInst != $lNullObj} {
#placeholder: do your processing on $lPlacedInst
}
#get the next part inst
set lInst [$lPartInstsIter NextPartInst $lStatus]
}
delete_DboPagePartInstsIter $lPartInstsIter

遍历原理图页中所有的wire

set lWiresIter [$lPage NewWiresIter $lStatus]
#get the first wire
set lWire [$lWiresIter NextWire $lStatus]
set lNullObj NULL
while {$lWire != $lNullObj} {
	set lObjectType [$lWire GetObjectType]
	if {$lObjectType == $::DboBaseObject_WIRE_SCALAR} {
		#placeholder: do your processing on Wire scalar $lWire
	} elseif {$lObjectType == $::DboBaseObject_WIRE_BUS} {
		#placeholder: do your processing on Wire Bus $lWire
	}
	#get the next wire
	set lWire [$lWiresIter NextWire $lStatus]
}
delete_DboPageWiresIter $lWiresIter

遍历原理图页中的所有全局变量

set lGlobalsIter [$lPage NewGlobalsIter $lStatus]
#get the first global
set lGlobal [$lGlobalsIter NextGlobal $lStatus]
while { $lGlobal!=$lNullObj } {
	#placeholder: do your processing on $lGlobal
	#get the next global
	set lGlobal [$lGlobalsIter NextGlobal $lStatus]
}
delete_DboPageGlobalsIter $lGlobalsIter

遍历原理图页的所有Title-Block

set lTitleBlocksIter [$lPage NewTitleBlocksIter $lStatus]
#get the first title block
set lTitle [$lTitleBlocksIter NextTitleBlock $lStatus]
while {$lTitle!=$lNullObj} {
	#placeholder: do your processing on $lTitle
	#get the next title block
	set lTitle [$lTitleBlocksIter NextTitleBlock $lStatus]
}
delete_DboPageTitleBlocksIter $lTitleBlocksIter

遍历原理图页的所有端口

set lPortsIter [$lPage NewPortsIter $lStatus]
#get the first port of the page
set lPort [$lPortsIter NextPort $lStatus]
while {$lPort!=$lNullObj} {
	#placeholder: do your processing on $lPort
	#get the next port of the page
	set lPort [$lPortsIter NextPort $lStatus]
}
delete_DboPagePortsIter $lPortsIter

遍历原理图页的所有Off-Page

set lOffPagesIter [$lPage NewOffPageConnectorsIter $lStatus $::IterDefs_ALL]
#get the first off-page of the page
set lOffPage [$lOffPagesIter NextOffPageConnector $lStatus]
while {$lOffPage!=$lNullObj} {
	#placeholder: do your processing on $lOffPage
	#get the next off-page of the page
	set lOffPage [$lOffPagesIter NextOffPageConnector $lStatus]
}
delete_DboPageOffPageConnectorsIter $lOffPagesIter

遍历原理图页的所有Graphics

set lCommentsIter [$lPage NewCommentGraphicsIter $lStatus]
#get the first graphics of the page
set lGraphic [$lCommentsIter NextCommentGraphic $lStatus]
while {$lGraphic!=$lNullObj} {
	set lType [$lGraphic GetObjectType]
	if {$lType == $::DboBaseObject_GRAPHIC_BOX_INST} {
		set lBoxInst [DboGraphicInstanceToDboGraphicBoxInst $lGraphic]
		#placeholder: do your processing on $lBoxInst
	} elseif {$lType == $::DboBaseObject_GRAPHIC_LINE_INST} {
		set lLineInst [DboGraphicInstanceToDboGraphicLineInst $lGraphic]
		#placeholder: do your processing on $lLineInst
	} elseif {$lType == $::DboBaseObject_GRAPHIC_ELLIPSE_INST} {
		set lEllipseInst [DboGraphicInstanceToDboGraphicEllipseInst $lGraphic]
		#placeholder: do your processing on $lEllipseInst
	} elseif {$lType == $::DboBaseObject_GRAPHIC_ARC_INST} {
		set lArcInst [DboGraphicInstanceToDboGraphicArcInst $lGraphic]
		#placeholder: do your processing on $lArcInst
	} elseif {$lType == $::DboBaseObject_GRAPHIC_POLYLINE_INST} {
		set lPolylineInst [DboGraphicInstanceToDboGraphicPolylineInst $lGraphic]
		#placeholder: do your processing on $lPolylineInst
	} elseif {$lType == $::DboBaseObject_GRAPHIC_POLYGON_INST} {
		set $lPolygonInst [DboGraphicInstanceToDboGraphicPolygonInst $lGraphic]
		#placeholder: do your processing on $lPolygonInst
	} elseif {$lType == $::DboBaseObject_GRAPHIC_BITMAP_INST} {
		set lBitMapInst [DboGraphicInstanceToDboGraphicBitMapInst $lGraphic]
		#placeholder: do your processing on $lBitMapInst
	} elseif {$lType == $::DboBaseObject_GRAPHIC_COMMENTTEXT_INST} {
		set lTextInst [DboGraphicInstanceToDboGraphicCommentTextInst $lGraphic]
		#placeholder: do your processing on $lTextInst
	}
	#get the next graphics of the page
	set lGraphic [$lCommentsIter NextCommentGraphic $lStatus]
}
delete_DboPageCommentGraphicsIter $lCommentsIter

遍历元件实例的所有引脚

set lIter [$lInst NewPinsIter $lStatus]
set lNullObj NULL
#get the first pin of the part
set lPin [$lIter NextPin $lStatus]
while {$lPin !=$lNullObj } {
	#placeholder: do your processing on $lPin
	#get the next pin of the part
	set lPin [$lIter NextPin $lStatus]
}
delete_DboPartInstPinsIter $lIter

遍历wire的所有别名

set lAliasIter [$lWire NewAliasesIter $lStatus]
#get the first alias of wire
set lAlias [$lAliasIter NextAlias $lStatus]
while { $lAlias!=$lNullObj} {
	#placeholder: do your processing on $lAlias
	#get the next alias of wire
	set lAlias [$lAliasIter NextAlias $lStatus]
}
delete_DboWireAliasesIter $lAliasIter

遍历设计的所有Flat Net

set lFlatNetsIter [$pDesign NewFlatNetsIter $lStatus]
#get the first flat net of design
set lFlatNet [$lFlatNetsIter NextFlatNet $lStatus]
while {$lFlatNet!=$lNullObj} {
	#placeholder: do your processing on $lFlatNet
	set lNetName [DboTclHelper_sMakeCString]
	$lFlatNet GetName $lNetName
	#get the next flat net of design
	set lFlatNet [$lFlatNetsIter NextFlatNet $lStatus]
}
delete_DboDesignFlatNetsIter $lFlatNetsIter

遍历任一对象的所有用户属性

set lPropsIter [$lObject NewUserPropsIter $lStatus]
set lNullObj NULL
#get the first user property on the object
set lUProp [$lPropsIter NextUserProp $lStatus]
while {$lUProp !=$lNullObj } {
	#placeholder: do your processing on $lUProp
	set lName [DboTclHelper_sMakeCString]
	set lValue [DboTclHelper_sMakeCString]
	$lUProp GetName $lName
	$lUProp GetStringValue $lValue
	#get the next user property on the object
	set lUProp [$lPropsIter NextUserProp $lStatus]
}
delete_DboUserPropsIter $lPropsIter

遍历任一对象的所有显示属性

set lPropsIter [$lObject NewDisplayPropsIter $lStatus]
set lNullObj NULL
#get the first display property on the object
set lDProp [$lPropsIter NextProp $lStatus]
while {$lDProp !=$lNullObj } {
	#placeholder: do your processing on $lDProp
	#get the name
	set lName [DboTclHelper_sMakeCString]
	$lDProp GetName $lName
	#get the location
	set lLocation [$lDProp GetLocation $lStatus]
	#get the rotation
	set lRot [$lDProp GetRotation $lStatus]
	#get the font
	set lFont [DboTclHelper_sMakeLOGFONT]
	set lStatus [$lDProp GetFont $::DboLib_DEFAULT_FONT_PROPERTY $lFont]
	#get the color
	set lColor [$lDProp GetColor $lStatus]
	#get the next display property on the object
	set lDProp [$lPropsIter NextProp $lStatus]
}
delete_DboDisplayPropsIter $lPropsIter

改变对象的显示属性

proc ConvertUserToDoc { pPage pUser } {
set lDocDouble [expr "[$pPage GetPhysicalGranularity] * $pUser + 0.5"]
set lDoc [expr "round($lDocDouble)"]
return $lDoc
}
proc AddDisplayProperty {} {
# Get the selected objects
set lSelObjs1 [GetSelectedObjects]
set lObj1 [lindex $lSelObjs1 0]
set lPropNameCStr [DboTclHelper_sMakeCString "ASSEMBLY"]
set lPropValueCStr [DboTclHelper_sMakeCString "NC"]
set lStatus [$lObj1 SetEffectivePropStringValue $lPropNameCStr $lPropValueCStr]
set varNullObj NULL
set pDispProp [$lObj1 GetDisplayProp $lPropNameCStr $lStatus]
set lStatus [DboState]
if { $pDispProp == $varNullObj } {
	set rotation 0
	set logfont [DboTclHelper_sMakeLOGFONT]
	set color $::DboValue_DEFAULT_OBJECT_COLOR
	#set displocation [DboTclHelper_sMakeCPoint [expr $xlocation] [expr
	$ylocation]]
	if {[catch {set lPickPosition [GetLastMouseClickPointOnPage]} lResult] } {
		set lX 0
		set lY 0
		set displocation [DboTclHelper_sMakeCPoint $intX $intY]
	} else {
		set page [$lObj1 GetOwner]
		set lX [ConvertUserToDoc $page [lindex $lPickPosition 0]]
		set lY [ConvertUserToDoc $page [lindex $lPickPosition 1]]
		set displocation [DboTclHelper_sMakeCPoint $lX $lY]
	}
		set pNewDispProp [$lObj1 NewDisplayProp $lStatus $lPropNameCStr $displocation
		$rotation $logfont $color]
		#DO_NOT_DISPLAY = 0,
		#VALUE_ONLY = 1,
		#NAME_AND_VALUE = 2,
		#NAME_ONLY = 3,
		#BOTH_IF_VALUED = 4,
		$pNewDispProp SetDisplayType $::DboValue_NAME_AND_VALUE
	} else {
		$pDispProp SetDisplayType $::DboValue_NAME_ONLY
	}
}

遍历对象的所有有效属性

set lPropsIter [$lObject NewEffectivePropsIter $lStatus]
set lNullObj NULL
#create the input/output parameters
set lPrpName [DboTclHelper_sMakeCString]
set lPrpValue [DboTclHelper_sMakeCString]
set lPrpType [DboTclHelper_sMakeDboValueType]
set lEditable [DboTclHelper_sMakeInt]
#get the first effective property
set lStatus [$lPropsIter NextEffectiveProp $lPrpName $lPrpValue $lPrpType $lEditable]
while {[$lStatus OK] == 1} {
	#placeholder: do your processing for $lPrpName $lPrpValue $lPrpType $lEditable
	#get the next effective property
	set lStatus [$lPropsIter NextEffectiveProp $lPrpName $lPrpValue $lPrpType $lEditable]
}
delete_DboEffectivePropsIter $lPropsIter

获取元件实例的属性

#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]

获取Wire属性

#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]
  • 5
    点赞
  • 37
    收藏
    觉得还不错? 一键收藏
  • 11
    评论
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值