Cadence Skill 论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4743|回复: 6

[原创] [源代码}-sym的place_bound_top中心创建ref

[复制链接]
发表于 2018-1-18 11:10:46 | 显示全部楼层 |阅读模式
  1. ;PACKAGE GEOMETRY/DISPLAY_TOP层sym的place_bound_top中心创建ref

  2. (defun assembly ()

  3. ; converts to current database units
  4. ; ----------------------------------

  5. min_width = axlMKSConvert(129 "MILS")
  6. text_offset = axlMKSConvert(18 "MILS")

  7. ; creates table
  8. ; -------------

  9. reftable = makeTable("retfable" nil)

  10. ; defines text blocks
  11. ; -------------------

  12. rotate_no = make_axlTextOrientation(
  13.                 ?textBlock "2", ?rotation 0.,
  14.                 ?mirrored nil, ?justify "center")
  15. rotate_yes = make_axlTextOrientation(
  16.                 ?textBlock "2", ?rotation 270.,
  17.                 ?mirrored nil, ?justify "center")

  18. ; deletes text on package geometry/display_top
  19. ; --------------------------------------------

  20. drain()
  21. axlClearSelSet()
  22. vis_list = axlVisibleGet()
  23. axlVisibleDesign(nil)
  24. axlVisibleLayer("PACKAGE GEOMETRY/DISPLAY_TOP" t)
  25. axlSetFindFilter(?enabled list("noall" "text")
  26.         ?onButtons list("noall" "text"))
  27. axlAddSelectAll()
  28. axlDeleteObject(axlGetSelSet())

  29. ; selects symbols
  30. ; ---------------

  31. axlClearSelSet()
  32. axlVisibleDesign(nil)
  33. axlVisibleLayer("PACKAGE GEOMETRY/ASSEMBLY_TOP" t)
  34. axlSetFindFilter(?enabled list("noall" "symbols")
  35.         ?onButtons list("noall" "symbols"))
  36. axlAddSelectAll()
  37. axlVisibleSet(vis_list)
  38. symbol_db_list = axlGetSelSet()
  39. axlClearSelSet()
  40. foreach(symbol_db symbol_db_list
  41.         refdes = symbol_db->refdes
  42.         mir = symbol_db->isMirrored

  43.         ; checks if symbol is mirrored
  44.     ; ----------------------------

  45.         if( eq(mir nil) then
  46.                 children_db_list = symbol_db->children
  47.         
  48.                 ; checks if symbol has attached shapes
  49.                 ; ------------------------------------

  50.                 if( neq(children_db_list nil) then
  51.                         foreach(children_db children_db_list
  52.                                 isShape = children_db->objType
  53.                                 shape_layer = children_db->layer
  54.                                         if( equal(isShape "shape") then

  55.                                                 ; checks if shape is on package geometry/place_bound_top
  56.                                                 ; ------------------------------------------------------

  57.                                                 if( equal(shape_layer "PACKAGE GEOMETRY/PLACE_BOUND_TOP") then
  58.                                                         boundary = children_db->bBox
  59.                                                         ref_exists = reftable[refdes]

  60.                                                         ; checks if shape already exists for refdes
  61.                                                         ; -----------------------------------------

  62.                                                         if( equal(ref_exists nil) then

  63.                                                                 ; adds refdes/boundary box to table
  64.                                                                 ; ---------------------------------

  65.                                                                 reftable[refdes] = boundary
  66.                                                         else

  67.                                                                 ; calculates maximum size box
  68.                                                                 ; ----------------------------

  69.                                                                 old_boundary = reftable[refdes]
  70.                                                                 old_llx = caar(old_boundary)
  71.                                                                 old_urx = caadr(old_boundary)
  72.                                                                 old_ury = cadadr(old_boundary)
  73.                                                                 old_lly = cadar(old_boundary)
  74.                                                                 boundary = children_db->bBox
  75.                                                                 llx = caar(boundary)
  76.                                                                 urx = caadr(boundary)
  77.                                                                 ury = cadadr(boundary)
  78.                                                                 lly = cadar(boundary)
  79.                                                                 llx = min(llx old_llx)
  80.                                                                 urx = max(urx old_urx)
  81.                                                                 ury = max(ury old_ury)
  82.                                                                 lly = min(lly old_lly)
  83.                                                                 boundary = list(llx:lly urx:ury)
  84.                                                                 reftable[refdes] = boundary
  85.                                                         ) ; end of if ref exists
  86.                                                 ) ; end of package geometry
  87.                                         ) ; end of is shape
  88.                         ) ; end of foreach
  89.                 ) ; end of if children
  90.         ) ; end or if mir
  91. ) ; end of foreach symbol_db

  92. ; reads each refdes/boundary box pair
  93. ; -----------------------------------

  94. foreach( refdes reftable
  95.         if( neq(refdes nil) then        
  96.                 boundary = reftable[refdes]
  97.                 llx = caar(boundary)
  98.             urx = caadr(boundary)
  99.             ury = cadadr(boundary)
  100.             lly = cadar(boundary)
  101.                  width = urx-llx
  102.             refpos_x = (width/2)+llx
  103.             height = ury-lly
  104.             refpos_y = (height/2)+lly

  105.                                         ; if width > 129 mils text is at 0 degrees
  106.                                         ; ----------------------------------------
  107.          
  108.                     if((width > min_width) then

  109.                         refpos_y = refpos_y - text_offset
  110.                         refpos = refpos_x:refpos_y
  111.                         axlDBCreateText(refdes , refpos , rotate_no ,
  112.                                         "package geometry/display_top" )
  113.                     else

  114.                     ; if width <= 129 mils text is at 270 degrees
  115.                     ; -------------------------------------------

  116.                         refpos_x = refpos_x - text_offset
  117.                         refpos = refpos_x:refpos_y
  118.                         axlDBCreateText(refdes , refpos , rotate_yes ,
  119.                                         "package geometry/display_top" ))

  120.         ) ; end of if
  121. ) ;end of foreach
  122. axlVisibleLayer("PACKAGE GEOMETRY/DISPLAY_TOP" t)

  123. ) ; end of function assembly

  124. ; registers command assembly with Allegro
  125. ; ---------------------------------------

  126. axlCmdRegister( "assembly" `assembly)
复制代码


发表于 2018-1-18 18:29:50 | 显示全部楼层
这个能不能弄说明,意义何在
 楼主| 发表于 2018-1-19 09:28:37 | 显示全部楼层
发电机 发表于 2018-1-18 18:29
这个能不能弄说明,意义何在

学习代码,
发表于 2018-1-19 19:39:05 | 显示全部楼层
楼主   SKILL学的怎么样
发表于 2018-1-19 19:41:06 | 显示全部楼层
哦 原来是这样啊   楼主是高手不
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|网站地图|Cadence Skill 论坛 ( 蜀ICP备13024417号 )

GMT+8, 2024-3-30 00:03 , Processed in 0.136950 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表