• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Allegro X PCB Editor
  3. etch length-measuring functions

Stats

  • Replies 0
  • Subscribers 158
  • Views 12428
  • Members are here 0
More Content

etch length-measuring functions

archive
archive over 18 years ago

Greetings all,

In the past I've had need of  getting the length of a trace, whether that trace be a segment (CLINESEG), path (CLINE) or of an entire net. "show elements" on the trace yields the desired value but I want the value to be available within a SKILL routine.  So I wrote my own set of functions to calculate the value for me.  Here they are:

;----------------------------------------
; length-finding utility functions
; written by: Chris Walters
;
;
; These functions will find the length of an etch trace
; for a given segment, path, or entire net, respectively
;
; Revision History
; 2006/12/13 Chris Walters
; Initial release
;----------------------------------------
procedure( cdw_findSegLength( seg_db)
prog((seglength pt1 pt2 pt3 chordlength rradius aangle xproduct)

seglength = 0.0

pt1 = car( seg_db->startEnd)
pt2 = cadr( seg_db->startEnd)

pt1.x = xCoord( pt1)
pt1.y = yCoord( pt1)
pt2.x = xCoord( pt2)
pt2.y = yCoord( pt2)

if( seg_db->objType == "arc" then
pt3 = seg_db->xy
pt3.x = xCoord( pt3)
pt3.y = yCoord( pt3)
chordlength = sqrt( (pt2.x - pt1.x)*(pt2.x - pt1.x) + (pt2.y - pt1.y)*(pt2.y - pt1.y) )
rradius = seg_db->radius

;determine angle formed by pt1 and pt2 with center at rradius
aangle = 2 * asin( chordlength / (2 * rradius)) ; in radians

;determine whether arc is major or minor
xproduct = (pt2.x - pt1.x)*(pt3.y - pt1.y) - (pt3.x - pt1.x)*(pt2.y - pt1.y) ; 2D cross-product

cond(
( !seg_db->isClockwise && xproduct
seglength = (6.283185 - aangle) * rradius
)
( !seg_db->isClockwise && xproduct >= 0.0 ; minor arc
seglength = aangle * rradius
)
( seg_db->isClockwise && xproduct
seglength = aangle * rradius
)
( seg_db->isClockwise && xproduct >= 0.0 ; major arc
seglength = (6.283185 - aangle) * rradius
)
);end-cond
else
seglength = sqrt( (pt2.x - pt1.x)*(pt2.x - pt1.x) + (pt2.y - pt1.y)*(pt2.y - pt1.y) )
);end-if

return( seglength)

);end-prog
);end-procedure

;----------------------------------------
procedure( cdw_findPathLength( path_db)
prog(( pathlength)

pathlength = 0.0

foreach( seg_db path_db->segments
pathlength = pathlength + cdw_findSegLength( seg_db)
);end-foreach

return( pathlength)

);end-prog
);end-procedure

;----------------------------------------
procedure( cdw_findNetLength( net_db)
prog(( netlength)

netlength = 0.0

foreach( net_br net_db->branches
foreach( child_db net_br->children
if( child_db->objType == "path" then
netlength = netlength + cdw_findPathLength( child_db)
);end-if
);end-foreach
);end-foreach

return( netlength)

);end-prog
);end-procedure


Merry Christmas!


Chris Walters
local Cadence guru
()


Originally posted in cdnusers.org by kerchunk
  • Sign in to reply
  • Cancel
Cadence Guidelines

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information