• 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. Custom IC SKILL
  3. Skill code for calculating length of a path with bends

Stats

  • Locked Locked
  • Replies 7
  • Subscribers 144
  • Views 17531
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Skill code for calculating length of a path with bends

Zebib
Zebib over 15 years ago

 I am trying to calculate the length of a given path with many bends using a skill code.

Thanks 

  • Cancel
  • skillUser
    skillUser over 15 years ago

     Hi Zebib,

    There is an existing Solution 11422112 that may help with what you are asking.

    Alternatively, here is another (more simplistic) SKILL example that I wrote:

    
    ********************************************************************
    * DISCLAIMER: The following code is provided for Cadence customers *
    * to use at their own risk. The code may require modification to *
    * satisfy the requirements of any user. The code and any *
    * modifications to the code may not be compatible with current or *
    * future versions of Cadence products. *
    * THE CODE IS PROVIDED "AS IS" AND WITH NO WARRANTIES, INCLUDING *
    * WITHOUT LIMITATION ANY EXPRESS WARRANTIES OR IMPLIED WARRANTIES *
    * OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. *
    ********************************************************************
    */
    /***************************************************************
    * *
    * CCSgetPathLength() *
    * Uses the selected object, if no object is selected then the *
    * current mouse pointer location is used (if infix is on). If *
    * the object is a path then iterate over the points and sum *
    * the length of each segment (works for 45 degree segments). *
    * Prints the summed length of the selected path in the CIW. *
    * *
    ***************************************************************/
    procedure(CCSgetPathLength(@optional (obj car(geGetSelectedSet())) silent )
    let((prevpt x y (length 0.0))
    ;; if no object is selected, and infix is turned on, then
    ;; use the current mouse location to select the object.
    ;; This is for use with a bindkey, i.e. it is set to run
    ;; this procedure when a key is pressed.
    unless(obj
    when(hiGetCIWindow()->infix
    geSelectPoint(nil enterPoint())
    obj = car(geGetSelectedSet())
    )
    )
    ;; when the selected object is a path object, iterate
    ;; over the list of points and sum the length. This
    ;; assumes orthogonal or 45 degree segments only.
    when(obj~>objType == "path"
    foreach(pt obj~>points
    ;; operate on pairs of points, if no previous point
    ;; then set it to be the same as the first and use
    ;; it in the next iteration.
    if(!prevpt then
    ;; initialise prevpt to be the first point
    prevpt=pt
    else
    ;; for simplicity keep the calculation the same
    ;; regardless of which direction the segment is
    ;; oriented. One of x or y will be 0 unless the
    ;; path segment is not horizontal or vertical.
    x=abs(car(pt) - car(prevpt))
    y=abs(cadr(pt)-cadr(prevpt))
    length = length + sqrt(expt(x 2) + expt(y 2))
    prevpt=pt
    )
    );; foreach
    ;; print the summed length to the CIW, length will
    ;; have a value as it was initialised as 0.0
    unless(silent
    printf("Path length: %5.2f\n" length)
    )
    ;; return the length calculated
    length
    );; when selected object is a path
    );; let
    );; procedure CCSgetPathLength

    The above code only calculates the length of a path object type (i.e. OA 'pathSegs' are not considered) and does not consider any layer change or overlaps (or non flush end-types) , but hopefully it is helpfulto you.

    Regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Zebib
    Zebib over 15 years ago

    skilluser,

    Thanks. It works!

    Zebib

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Zebib
    Zebib over 15 years ago

    Hi skilluser,

    Your skill code for finding the length of a path works fine. I also tride to do similar code for rectangles which

    is ofcourse much simpler than that od the path. Now I am wondering if you have a skill code that would calculate the length of a polyon of several bends and different width.

    By the way I am trying to learn skill code and where can I find skill codes so that I can learn from them.

    Thanks,

     

    Zebib

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 15 years ago

    What does the "length" of a rectangle mean? Unless you know the direction, you don't know which is the "length" and which is the "width".

    With a rectangle object you have the ~>bBox attribute - from that it's easy to compute the length of each side.

    For a polygon, I've no idea what "length" means.

    In order to learn more about SKILL:

    1. Read the SKILL User Guide in the documentation
    2. Look at examples on Cadence Online Support (support.cadence.com) - particularly in the Resources section at the top
    3. Look on this forum
    4. Look on the comp.cad.cadence usenet news group (look on google groups)
    5. Attend a SKILL Language Programming class (follow the Education link at the top of the page)
    6. Experiment (in conjunction with the documentation)
    7. Experiment some more... 

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Zebib
    Zebib over 15 years ago

    Andrew,

    If you have an L-shaped path and then if this path is converted to a polygon, how do you calculate its length.

    I will do some more reading as you suggested. I wish I could get more skill programs that I can learn from.

     

    Thanks,

     

    Zebib

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 15 years ago

    Zebib,

    There are lots of examples around, in the places I mentioned.

    One approach you could use is to use code like this to convert a polygon back into a path. A bit of a brute-force (not the most elegant thing I've ever written), but it's one approach. It assumes it is really like a path - i.e. constant "width". Also deals with rectangles (see comments in code).

    Having converted to a path, you could calculate the length as Lawrence suggested before.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • twen
    twen over 10 years ago
    Is there any way that I can use the length measurement skill code to dynamically display the total path length while I stretch a path segment like the tool bar's X,Y,dX,DY? This feature will be useful when I try to create hundreds of length-matched irregular paths. Stretching a path segment, selecting it again, and then pressing a key to display it is not convenient in this case. Thanks, TJ.
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

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