• 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 Scripting - Skill
  3. Expand a Polygon along one dimension only with SKILL

Stats

  • Replies 3
  • Subscribers 18
  • Views 10549
  • Members are here 0
More Content

Expand a Polygon along one dimension only with SKILL

markmalin
markmalin over 4 years ago

I have a polygon with a given bounding box.  I want to take that polygon and create a new one, but have the X dimension 10% wider.

I'm somewhat new to SKILL, so bear with me.  I understand how I can get access to the given polygon object from the database, and I understand that there is a "bbox" list defining the bounding box.  If I calculate the width in X to be some number of user units, I want to add them like so:

xDistance = sqrt(caar(myPolygon->bBox) - cadr(myPolygon->bBox))
xDistance = expt(xDistance 2)

xExpandDist = xDistance * (0.1)

Now I want to expand the myPolygon->bBox "xExpandDist/2" to the left (i.e. on the X axis), and "xExpandDist/2" to the right (i.e. on the X axis).

I understand that a polygon has a bounding box, I can get the X,Y coordinates for the bbox, I know how much I want to expand it, but can I simply assign a new value to it?  In other words, in pseudo code:

myPolygon's bbox lower left x value = myPolygon's bbox lower left x value - xExpandDist 

myPolygon's bbox upper right x value = myPolygon's bbox upper right x value + xExpandDist 

How do I do this?  How do I change the X coordinates of the bounding box?

Thanks
Mark

  • Cancel
  • Sign in to reply
  • DavidJHutchins
    DavidJHutchins over 4 years ago

    No, the bounding box is calculated from the min/max values of the segments

    To modify the X dimensions you will need to recalculate the X coordinates of the min & max locations, then rebuild the shape

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • eDave
    eDave over 4 years ago

    You need to take the vertices from the polygon and add your delta x to those.

    This code should help you:

    defun( DE_polyVertsToPath (poly @key (expandx 0), (expandy 0) (width 0))
    let((dx, dy, midPoly, verts, pt1, pt2, rpath, radius, cw)
    dx = expandx / 2.0
    dy = expandy / 2.0
    midPoly = axlMidPointLine(poly ->bBox)
    verts = poly ->vertices
    pt1 = DE_polyVertsToPath_expandPt(caar(verts), dx, dy, midPoly)
    rpath = axlPathStart(list(pt1), width)
    foreach(vert, car(tconc(lconc(nil, cdr(verts)), car(verts)))
    pt2 = DE_polyVertsToPath_expandPt(car(vert), dx, dy, midPoly)
    unless(axlGeoPointsEqual(pt1, pt2)
    radius = cadr(vert)
    if(zerop(radius)
    then axlPathLine(rpath, width, pt2)
    else cw = plusp((cadr(pt2) - cadr(pt1)) * radius), axlPathArcRadius(rpath, width, pt2, cw, nil, abs(radius))
    )
    )
    pt1 = pt2
    ); foreach vert
    rpath
    ))

    defun( DE_polyVertsToPath_expandPt (pt, dx, dy, midPt)
    list(
    if(car(pt) < car(midPt) then car(pt) - dx else car(pt) + dx)
    if(cadr(pt) < cadr(midPt) then cadr(pt) - dy else cadr(pt) + dy)
    )
    )

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • markmalin
    markmalin over 4 years ago in reply to eDave

    Thanks.  This is helpful.  It wasn't clear from the documentation how to either modify and existing shape or how to re-create/create one.  I'll look closely at the example you posted.  Thanks!  Mark

    • Cancel
    • Vote Up 0 Vote Down
    • 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