Hi Michele, Here's a snippet of some code I've used to determine which edge the pin is on (it doesn't have a prefix, because it was a local function in a SKILL++ source file, so adjust it to suit your needs): /*************************************************************** * * * (getClosestEdge xy bBox) * * * * INTERNAL function to return one of the symbols left, right * * bottom or top to indicate whether the specified point is * * closest to which edge - given a bBox of the symbol - prior * * to adding pins or labels. Helpful to determine orientation * * of labels, etc. * * * ***************************************************************/ ( defun getClosestEdge (xy bBox) ( let (edgeData distances) ( setq edgeData ( list ( list (xCoord (lowerLeft bBox)) (xCoord xy) 'left) ( list (yCoord (lowerLeft bBox)) (yCoord xy) 'bottom) ( list (xCoord (upperRight bBox)) (xCoord xy) 'right) ( list (yCoord (upperRight bBox)) (xCoord xy) 'top) )) ( setq distances ( foreach mapcar edge edgeData ( list ( abs ( difference ( car edge) ( cadr edge))) ( caddr edge)))) (cadar ( sortcar distances ' lessp )) ) ) The bBox could be the bBox of the symbol, but the problem is that this is skewed by any labels that are in the symbol - remember the bBox is the overall bBox. The xy was the centerBox() of the bBox of each pin. Once you know which side it's on, you can determine which direction to draw the stub, and which orientation to use for labels, etc. So what I have done before is look for the bBox of the "instance" layer on the symbol. Here's some code that does that (and falls back to the bBox if there is no instance layer): /****************************************************************** * * * (findSymbolBBox inst) * * * * Internal function to find the bbox of an instance, using the * * instance layer if it exists - this produces a better box - the * * selection box - than the overall bbox. * * * ******************************************************************/ ( defun findSymbolBBox (inst) ( let (master shapes instBox bBox) ( setq master ( getq inst master)) ( setq shapes ( getq ( car ( exists LP ( getq master lpps) ( and ( equal ( getq LP layerName) "instance" ) ( equal ( getq LP purpose) "drawing" ) ))) shapes)) ( if shapes ( progn ( setq instBox ( getq ( car shapes) bBox)) ( foreach shape ( cadr shapes) ( setq bBox ( getq shape bBox)) ( setq instBox ( list ( list ( min (xCoord (lowerLeft instBox)) (xCoord (lowerLeft bBox))) ( min (yCoord (lowerLeft instBox)) (yCoord (lowerLeft bBox))) ) ( list ( max (xCoord (upperRight instBox)) (xCoord (upperRight bBox))) ( max (yCoord (upperRight instBox)) (yCoord (upperRight bBox))) ) )) ) ; foreach shape ( setq instBox ( dbTransformBBox instBox ( getq inst transform))) ) ; progn ( setq instBox ( getq inst bBox)) ) ; if shapes instBox ) ; let ) ; defun findSymbolBBox Something like that would do, anyway! (the code above was hacked to remove some irrelevant feature which just confused matters, so hopefully it still works) Regards, Andrew.
↧