王开鑫55 发表于 2018-1-18 11:10:46

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

;PACKAGE GEOMETRY/DISPLAY_TOP层sym的place_bound_top中心创建ref

(defun assembly ()

; converts to current database units
; ----------------------------------

min_width = axlMKSConvert(129 "MILS")
text_offset = axlMKSConvert(18 "MILS")

; creates table
; -------------

reftable = makeTable("retfable" nil)

; defines text blocks
; -------------------

rotate_no = make_axlTextOrientation(
                ?textBlock "2", ?rotation 0.,
                ?mirrored nil, ?justify "center")
rotate_yes = make_axlTextOrientation(
                ?textBlock "2", ?rotation 270.,
                ?mirrored nil, ?justify "center")

; deletes text on package geometry/display_top
; --------------------------------------------

drain()
axlClearSelSet()
vis_list = axlVisibleGet()
axlVisibleDesign(nil)
axlVisibleLayer("PACKAGE GEOMETRY/DISPLAY_TOP" t)
axlSetFindFilter(?enabled list("noall" "text")
      ?onButtons list("noall" "text"))
axlAddSelectAll()
axlDeleteObject(axlGetSelSet())

; selects symbols
; ---------------

axlClearSelSet()
axlVisibleDesign(nil)
axlVisibleLayer("PACKAGE GEOMETRY/ASSEMBLY_TOP" t)
axlSetFindFilter(?enabled list("noall" "symbols")
      ?onButtons list("noall" "symbols"))
axlAddSelectAll()
axlVisibleSet(vis_list)
symbol_db_list = axlGetSelSet()
axlClearSelSet()
foreach(symbol_db symbol_db_list
      refdes = symbol_db->refdes
      mir = symbol_db->isMirrored

      ; checks if symbol is mirrored
    ; ----------------------------

      if( eq(mir nil) then
                children_db_list = symbol_db->children
      
                ; checks if symbol has attached shapes
                ; ------------------------------------

                if( neq(children_db_list nil) then
                        foreach(children_db children_db_list
                              isShape = children_db->objType
                              shape_layer = children_db->layer
                                        if( equal(isShape "shape") then

                                                ; checks if shape is on package geometry/place_bound_top
                                                ; ------------------------------------------------------

                                                if( equal(shape_layer "PACKAGE GEOMETRY/PLACE_BOUND_TOP") then
                                                      boundary = children_db->bBox
                                                      ref_exists = reftable

                                                      ; checks if shape already exists for refdes
                                                      ; -----------------------------------------

                                                      if( equal(ref_exists nil) then

                                                                ; adds refdes/boundary box to table
                                                                ; ---------------------------------

                                                                reftable = boundary
                                                      else

                                                                ; calculates maximum size box
                                                                ; ----------------------------

                                                                old_boundary = reftable
                                                                old_llx = caar(old_boundary)
                                                                old_urx = caadr(old_boundary)
                                                                old_ury = cadadr(old_boundary)
                                                                old_lly = cadar(old_boundary)
                                                                boundary = children_db->bBox
                                                                llx = caar(boundary)
                                                                urx = caadr(boundary)
                                                                ury = cadadr(boundary)
                                                                lly = cadar(boundary)
                                                                llx = min(llx old_llx)
                                                                urx = max(urx old_urx)
                                                                ury = max(ury old_ury)
                                                                lly = min(lly old_lly)
                                                                boundary = list(llx:lly urx:ury)
                                                                reftable = boundary
                                                      ) ; end of if ref exists
                                                ) ; end of package geometry
                                        ) ; end of is shape
                        ) ; end of foreach
                ) ; end of if children
      ) ; end or if mir
) ; end of foreach symbol_db

; reads each refdes/boundary box pair
; -----------------------------------

foreach( refdes reftable
      if( neq(refdes nil) then      
                boundary = reftable
                llx = caar(boundary)
            urx = caadr(boundary)
            ury = cadadr(boundary)
            lly = cadar(boundary)
               width = urx-llx
            refpos_x = (width/2)+llx
            height = ury-lly
            refpos_y = (height/2)+lly

                                        ; if width > 129 mils text is at 0 degrees
                                        ; ----------------------------------------
         
                  if((width > min_width) then

                        refpos_y = refpos_y - text_offset
                        refpos = refpos_x:refpos_y
                        axlDBCreateText(refdes , refpos , rotate_no ,
                                        "package geometry/display_top" )
                  else

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

                        refpos_x = refpos_x - text_offset
                        refpos = refpos_x:refpos_y
                        axlDBCreateText(refdes , refpos , rotate_yes ,
                                        "package geometry/display_top" ))

      ) ; end of if
) ;end of foreach
axlVisibleLayer("PACKAGE GEOMETRY/DISPLAY_TOP" t)

) ; end of function assembly

; registers command assembly with Allegro
; ---------------------------------------

axlCmdRegister( "assembly" `assembly)


发电机 发表于 2018-1-18 18:29:50

这个能不能弄说明,意义何在

王开鑫55 发表于 2018-1-19 09:28:37

发电机 发表于 2018-1-18 18:29
这个能不能弄说明,意义何在

学习代码,

nanshao8860 发表于 2018-1-19 19:39:05

楼主   SKILL学的怎么样

发电机 发表于 2018-1-19 19:41:06

哦 原来是这样啊   楼主是高手不

eagle31 发表于 2018-12-20 16:08:15

謝謝分享

yfchen1003 发表于 2019-5-28 08:22:42

路过,谢谢!
页: [1]
查看完整版本: [源代码}-sym的place_bound_top中心创建ref