找回密码
 注册
关于网站域名变更的通知
查看: 509|回复: 2
打印 上一主题 下一主题

[skill]-Share some skill

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2019-5-22 18:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x
Hi All,
I have
axlCmdRegister( "rename ref des" 'Rename_Ref_Des_Routine ?cmdType "interactive")

; Set the global variables
; ########################
Match_Prefix="U"; This variable represents the prefix to match
New_Prefix="U"; This variable represents the prefix to rename to
Start_Number=1; theis varible represents the first number to use when renaming

; Define the routine to get things started
; ########################################
defun(Rename_Ref_Des_Routine ()

   ; Set the variables
   ; #################
   Finished=nil; this variable is used to determine when to stop requesting another selection
   Oops_On=nil; this variable is used to determine when an Oops has been pushed
   Oops_List=nil; This list keeps track of the old (pre-rename) ref des
   New_Name_List=nil; This list keeps track of the new (changed) ref des
   X_Y_Loc_List=nil; This list keeps track of the ref des locations so Oops can find them

   ; Run the routine to create the form
   ; ##################################
   Rename_Form_Routine()

   ; Display the form and set the fields
   ; ###################################
   Rename_Ref_Des_Form=axlFormCreate( (gensym) "Rename_Ref_Des_Form.form" '(e inner) 'Rename_Form_Action t)
   axlFormDisplay(Rename_Ref_Des_Form)
   axlFormSetField(Rename_Ref_Des_Form "Match_Prefix_Field" upperCase(Match_Prefix))
   axlFormSetField(Rename_Ref_Des_Form "New_Prefix_Field" upperCase(New_Prefix))
   axlFormSetField(Rename_Ref_Des_Form "Start_Number_field" Start_Number)
); end defun Rename_Ref_Des_Routine

; Create the Rename Ref Des form
; ##############################
defun(Rename_Form_Routine ()
   Rename_Ref_Des_Form=outfile("./Rename_Ref_Des_Form.form" "w")
   fprintf(Rename_Ref_Des_Form "FILE_TYPE=FORM_DEFN VERSION=2\n")
   fprintf(Rename_Ref_Des_Form "FORM\n")
   fprintf(Rename_Ref_Des_Form "FIXED\n")
   fprintf(Rename_Ref_Des_Form "HEADER \"Rename Ref Des\"\n")
   fprintf(Rename_Ref_Des_Form "PORT 25 9\n")
   fprintf(Rename_Ref_Des_Form "TILE\n")
   fprintf(Rename_Ref_Des_Form "TEXT \"Match Prefix:\"\n")
   fprintf(Rename_Ref_Des_Form "TLOC 1 1\n")
   fprintf(Rename_Ref_Des_Form "ENDTEXT\n")
   fprintf(Rename_Ref_Des_Form "FIELD Match_Prefix_Field\n")
   fprintf(Rename_Ref_Des_Form "FLOC 15 1\n")
   fprintf(Rename_Ref_Des_Form "STRFILLIN 6 30\n")
   fprintf(Rename_Ref_Des_Form "ENDFIELD\n")
   fprintf(Rename_Ref_Des_Form "TEXT \"New  Prefix :\"\n")
   fprintf(Rename_Ref_Des_Form "TLOC 1 4\n")
   fprintf(Rename_Ref_Des_Form "ENDTEXT\n")
   fprintf(Rename_Ref_Des_Form "FIELD New_Prefix_Field\n")
   fprintf(Rename_Ref_Des_Form "FLOC 15 4\n")
   fprintf(Rename_Ref_Des_Form "STRFILLIN 6 30\n")
   fprintf(Rename_Ref_Des_Form "ENDFIELD\n")
   fprintf(Rename_Ref_Des_Form "TEXT \"Start Number:\"\n")
   fprintf(Rename_Ref_Des_Form "TLOC 1 7\n")
   fprintf(Rename_Ref_Des_Form "ENDTEXT\n")
   fprintf(Rename_Ref_Des_Form "FIELD Start_Number_Field\n")
   fprintf(Rename_Ref_Des_Form "FLOC 15 7\n")
   fprintf(Rename_Ref_Des_Form "INTFILLIN 6 30\n")
   fprintf(Rename_Ref_Des_Form "ENDFIELD\n")
   fprintf(Rename_Ref_Des_Form "FIELD Begin_Rename_Field\n")
   fprintf(Rename_Ref_Des_Form "FLOC 5 10\n")
   fprintf(Rename_Ref_Des_Form "MENUBUTTON \"Begin Rename\" 15 3\n")
   fprintf(Rename_Ref_Des_Form "ENDFIELD\n")
   fprintf(Rename_Ref_Des_Form "FIELD Cancel_Field\n")
   fprintf(Rename_Ref_Des_Form "FLOC 5 13\n")
   fprintf(Rename_Ref_Des_Form "MENUBUTTON \"Cancel Rename\" 15 3\n")
   fprintf(Rename_Ref_Des_Form "ENDFIELD\n")
   fprintf(Rename_Ref_Des_Form "ENDTILE\n")
   fprintf(Rename_Ref_Des_Form "ENDFORM\n")
   close(Rename_Ref_Des_Form)
); end defun Rename_Form_Routine

; Define action of the form buttons in the Rename_Ref_Des_Form
; ############################################################
defun(Rename_Form_Action (Rename_Ref_Des_Form)
  case(Rename_Ref_Des_Form->curField

     ("Match_Prefix_Field"
        Match_Prefix=(Rename_Ref_Des_Form->curValue)
        t
     ); end "Match_Prefix_Field"

     ("New_Prefix_Field"
        New_Prefix=(Rename_Ref_Des_Form->curValue)
        t
     ); end "New_Prefix_Field"

     ("Start_Number_Field"
        Start_Number=(Rename_Ref_Des_Form->curValue)
        t
     ); end "Start_Number_Field"

     ("Begin_Rename_Field"
        Finished=nil

        ; Close the rename form
        ; #####################
        axlFormClose(Rename_Ref_Des_Form)

        ; Start the next number counter and build the new ref des
        ; #######################################################
        Next_Number=Start_Number; This variable is used to increment the ref des number
        New_Name=sprintf(dummy "%s%d" upperCase(New_Prefix) Next_Number); This variable is the new ref des

        ; Build and display the tracking form
        ; ###################################
        Rename_Tracking_Form_Routine()
        Rename_Tracking_Form=axlFormCreate( (gensym) "./Rename_Tracking_Form.form" '(e inner) nil t)
        axlFormDisplay(Rename_Tracking_Form)

        ; Define the pop up
        ; #################
        Rename_Popup=axlUIPopupDefine(nil
            list(
            list("Reset" 'Reset_Rename_Prefix_Routine)
            list("Oops" 'Rename_Oops_Routine)
            list("Done" 'Rename_Done_Routine)))

        ; Build the List of all placed symbols
        ; ####################################
        axlSetFindFilter(?enabled '(noall symbols) ?onButtons '(noall symbols))
        Symbols=axlGetSelSet(axlAddSelectAll())

        ; Parse the list and keep the ref des that match the match prefix
        ; ###############################################################
        Component_List=nil; This variable represents the components that match
        Last_Number=1; This varable represents the total number of components that match
        Pattern=strcat(upperCase(Match_Prefix) "[0-9]+"); This variable represents the match criteria
        foreach(Symbol Symbols
           if(Symbol->refdes && rexMatchp(Pattern Symbol->refdes) then
              Component_List=cons(Symbol Component_List)
              Last_Number=Last_Number+1
           ); end if Symbol->refdes && rexMatchp(Pattern Symbol->refdes)
        ); end foreach Symbol Symbols

        ; Highlight all components that match the Match_Prefix
        ; ####################################################
        axlClearSelSet()
        axlHighlightObject(Component_List)

        ; Run the interactive ref des selection routine
        ; #############################################
        Interactive_Rename_Routine()
        t
     ); end "Begin_Rename_Field"

     ("Cancel_Field"
        axlCancelEnterFun()
        axlFormClose(Rename_Ref_Des_Form)
        shell("rm ./Rename_Ref_Des_Form.form")
        t
     ); end "Cancel_Field"
  ); end case Rename_Ref_Des_Form->curField
); end defun Rename_Form_Action

; Define the Interactive_Rename_Routine
; #####################################
defun(Interactive_Rename_Routine ()
   while(Finished == nil; This loop allows the continual selection of ref des

      ; Set the pop up and the tracking form field
      ; ##########################################
      axlUIPopupSet(Rename_Popup)
      axlFormSetField(Rename_Tracking_Form "Next_Number_Field" New_Name)

      ; Select the ref des to rename
      ; ############################
      axlSetFindFilter(?enabled '(noall text) ?onButtons '(noall text))
      Text=car(axlGetSelSet(axlSingleSelectPoint())); This variable represent the ref des to be renamed

      ; Check if Reset, Done, or Oops were pushed
      ; #########################################
      if(Oops_On == nil then
         if(Finished == nil then

            ; Check if any text was selected
            ; ##############################
            if(Text != nil then

               ; Add to the tally lists
               ; #####################
               Oops_List=cons(Text->text Oops_List)
               New_Name_List=cons(New_Name New_Name_List)
               Next_Number=Next_Number+1
               X_Y_Loc_List=cons(Text->xy X_Y_Loc_List)

               ; Determine where the ref des actually is located
               ; ###############################################
               X_Loc=car(car(X_Y_Loc_List))
               Y_Loc=car(cdr(car(X_Y_Loc_List)))

               ; Dehighlight the selected component, write and replay the script
               ; ###############################################################
               axlDehighlightObject(Text->parent)
               Script_File=outfile("./Rename_Ref_Des.scr" "w")
               fprintf(Script_File "setwindow pcb\ntext edit\n")
               fprintf(Script_File "pick %f %f\ntext %s\n" X_Loc Y_Loc New_Name)
               fprintf(Script_File "done\n")
               close(Script_File)
               axlShell("replay ./Rename_Ref_Des.scr")
               shell("rm ./Rename_Ref_Des.scr")

               ; Check if you got them all
               ; #########################
               if((Next_Number-Start_Number)+1 == Last_Number then
                  Reset_Rename_Prefix_Routine()
               ); end if (Next_Number-Start_Number)+1 == Last_Number

               ; Increment the new ref des and update the tracking form
               ; ######################################################
               New_Name=sprintf(dummy "%s%d" upperCase(New_Prefix) Next_Number)
               axlFormSetField(Rename_Tracking_Form "Next_Number_Field" New_Name)

            ); end if Text != nil

         else; if Finished == nil
            axlUIPopupSet(nil)

         ); end if Finished == nil

      else; if Oops_On == nil

         ; Check if there is anything to Oops
         ; ##################################
         if(Oops_List==nil then
            axlUIConfirm("Nothing to Oops")
            Finished=nil
            Oops_On=nil

         else; if Oops_List==nil

            ; Get the component at the top of Oops list
            ; #########################################
            axlClearSelSet()
            axlCancelEnterFun()
            axlSetFindFilter(?enabled '(noall symbols) ?onButtons '(noall symbols))
            Oppsed_Component=car(axlGetSelSet(axlSingleSelectName("SYMBOL" car(New_Name_List))))
            axlClearSelSet()

            ; If it is a matching prefix component re-highlight it
            ; ####################################################
            if(car(Oops_List)&& rexMatchp(Pattern car(Oops_List)) then
               axlHighlightObject(Oppsed_Component)
            ); end if car(Oops_List)&& rexMatchp(Pattern car(Oops_List))

            ; Determine where the Oops'd ref des was actually located
            ; #######################################################
            X_Loc=car(car(X_Y_Loc_List))
            Y_Loc=car(cdr(car(X_Y_Loc_List)))

            ; Write and replay the rename script
            ; ##################################
            Script_File=outfile("./Rename_Ref_Des.scr" "w")
            fprintf(Script_File "setwindow pcb\ntext edit\n")
            fprintf(Script_File "pick %f %f\ntext %s\n" X_Loc Y_Loc car(Oops_List))
            fprintf(Script_File "done\n")
            close(Script_File)
            axlShell("replay ./Rename_Ref_Des.scr")
            shell("rm ./Rename_Ref_Des.scr")

            ; Update the tally lists
            ; ######################
            Oops_List=cdr(Oops_List)
            X_Y_Loc_List=cdr(X_Y_Loc_List)
            New_Name=car(New_Name_List)
            Next_Number=Next_Number-1
            New_Name_List=cdr(New_Name_List)

            ; Reset the Oops_on and Finished variables
            ; ########################################
            Oops_On=nil
            Finished=nil

         ); end if Oops_List == nil
      ); end if Oops_On==nil
   ); end while Finished=nil
);end Interactive_Rename_Routine

; Define the rename tracking form
; ###############################
defun(Rename_Tracking_Form_Routine ()
   Rename_Tracking_Form=outfile("./Rename_Tracking_Form.form" "w")
   fprintf(Rename_Tracking_Form "FILE_TYPE=FORM_DEFN VERSION=2\n")
   fprintf(Rename_Tracking_Form "FORM\n")
   fprintf(Rename_Tracking_Form "FIXED\n")
   fprintf(Rename_Tracking_Form "HEADER \"Tracking\"\n")
   fprintf(Rename_Tracking_Form "PORT 17 3\n")
   fprintf(Rename_Tracking_Form "TILE\n")
   fprintf(Rename_Tracking_Form "TEXT \"Next Number\"\n")
   fprintf(Rename_Tracking_Form "TLOC 3 1\n")
   fprintf(Rename_Tracking_Form "ENDTEXT\n")
   fprintf(Rename_Tracking_Form "FIELD Next_Number_Field\n")
   fprintf(Rename_Tracking_Form "FLOC 1 3\n")
   fprintf(Rename_Tracking_Form "STRFILLIN 12 30\n")
   fprintf(Rename_Tracking_Form "ENDFIELD\n")
   fprintf(Rename_Tracking_Form "ENDTILE\n")
   fprintf(Rename_Tracking_Form "ENDFORM\n")
   close(Rename_Tracking_Form)
); end defun Rename_Tracking_Form

; Define "Reset" for the popup
; ############################
defun(Reset_Rename_Prefix_Routine ()

   ; Stop the select function
   ; ########################
   Finished=t
   axlClearSelSet()
   axlCancelEnterFun()

   ; De-highlight any components still highlighted
   ; #############################################
   axlSetFindFilter(?enabled '(noall symbols) ?onButtons '(noall symbols))
   Component_List=axlGetSelSet(axlAddSelectName("SYMBOL" sprintf(dummy "%s*" Match_Prefix)))
   axlClearSelSet()
   axlDehighlightObject(Component_List)

   ; Update the tally lists
   ; ######################
   Oops_List=nil
   New_Name_List=nil
   X_Y_Loc_List=nil
   Start_Number=Next_Number

   ; Close the tracking form
   ; #######################
   axlFormClose(Rename_Tracking_Form)
   shell("rm ./Rename_Tracking_Form.form")
   Form=axlFormCreate( (gensym) "Rename_Ref_Des_Form.form" '(e inner) 'Rename_Form_Action t)

   ; Display the rename form and set the fields
   ; ##########################################
   axlFormDisplay(Form)
   axlFormSetField(Form "Match_Prefix_Field" upperCase(Match_Prefix))
   axlFormSetField(Form "New_Prefix_Field" upperCase(New_Prefix))
   axlFormSetField(Form "Start_Number_field" Start_Number)
   axlShell("redisplay")
); defun end Reset_Rename_Prefix_Routine

; Define "Oops" for the popup
; ###########################
defun(Rename_Oops_Routine ()

该用户从未签到

推荐
发表于 2019-5-23 08:45 | 只看该作者
请问这个是什么功能?

该用户从未签到

3#
发表于 2019-5-23 10:15 | 只看该作者

请问这个是什么功能?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

EDA365公众号

关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

GMT+8, 2025-6-9 02:49 , Processed in 0.093750 second(s), 24 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

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