|
目前写了1个代码,无法实现功能,我想要运行skil以后,选择1个过孔,然后上下左右可以等间距复制过孔- /*********************************************************************
- 源码
- 作者:KLJ
- 功能:等间距拷贝过孔
- 优化:KLJ
- 更新:
- 2025年07月10日
- 思路,1、选择过孔
- 2、axlDBGetPad()获取选择的过孔的DBID,根据DBID获取坐标、网络名称
- 3、axlDBCreateVia创建过孔
-
- axlSetFindFilter支持的参数:
- "PINS","VIAS","CLINES","CLINESEGS","LINES","LINESEGS","DRCS","TEXT","SHAPES",
- "SHAPESEGS","BOUNDARY_SHAPES","VOIDS","VOIDSEGS","SYMBOLS","FIGURES","COMPONENTS",
- "FUNCTIONS","NETS","INVISIBLE","NAMEFORM","ALLTYPES","ALL","DYnthEMALS","GROUPS",
- "GROUPmemberS""DYNTHEMALS","GROUPS","GROUPMEMBERS"
-
- **********************************************************************/
- axlCmdRegister("COpyViaBySameDistance" 'CreateCOpyViaForm_KLJ)
- defun(CreateCOpyViaForm_KLJ ()
- time = getCurrentTime()
- time = parseString(time)
- day = nth(1 time)
- month = car(time)
- month = upperCase(month)
- year = nth(3 time)
- date = strcat(" Date: " day " " month " " year)
- CreateCOpyViaForm()
- COpyViaForm_KLJ=axlFormCreate( (gensym) form_file nil 'CopyVia_CallBack t)
- axlFormDisplay(COpyViaForm_KLJ)
- axlUIWPrint(COpyViaForm_KLJ date)
- axlFormSetField(COpyViaForm_KLJ "Radio2" "true") ;默认勾选SMD
- axlFormSetField(COpyViaForm_KLJ "Units_value" car(axlDBGetDesignUnits()))
-
-
- );end defun
- defun(CreateCOpyViaForm ()
- drain()
- form_file = "CopyViaBySameDistance_form.form"
- COpyViaForm = outfile(form_file "w")
- fprintf(COpyViaForm "#Created by xml2bnf perl utility\n")
- fprintf(COpyViaForm "#Coded by Venkata Ramanan/Santa Clara, CA\n\n")
- fprintf(COpyViaForm "FILE_TYPE=FORM_DEFN VERSION=2\n")
- fprintf(COpyViaForm "FORM AUTOGREYTEXT\n")
- fprintf(COpyViaForm "FIXED\n")
- fprintf(COpyViaForm "PORT 36 28\n")
- fprintf(COpyViaForm "HEADER "Form Field Type Demo"\n\n")
- fprintf(COpyViaForm "TILE\n\n")
- fprintf(COpyViaForm "TEXT Current_Units:\n")
- fprintf(COpyViaForm "FLOC 7 0\n")
- fprintf(COpyViaForm "TGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDTEXT\n\n")
- fprintf(COpyViaForm "TEXT \n")
- fprintf(COpyViaForm "FLOC 17 0\n")
- fprintf(COpyViaForm "INFO Units_value 16 1\n") ;
- fprintf(COpyViaForm "TGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDTEXT \n\n")
- when(car(axlDBGetDesignUnits())=="mils"
- fprintf(COpyViaForm "FIELD Radio1\n")
- fprintf(COpyViaForm "FLOC 8 2\n")
- fprintf(COpyViaForm "CHECKLIST "19.69" "rg"\n")
- fprintf(COpyViaForm "FGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDFIELD \n\n")
-
- fprintf(COpyViaForm "FIELD Radio2\n")
- fprintf(COpyViaForm "FLOC 18 2\n")
- fprintf(COpyViaForm "CHECKLIST "31.5" "rg"\n")
- fprintf(COpyViaForm "FGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDFIELD \n\n")
-
- fprintf(COpyViaForm "FIELD Radio3\n")
- fprintf(COpyViaForm "FLOC 8 4\n")
- fprintf(COpyViaForm "CHECKLIST "39.37" "rg"\n")
- fprintf(COpyViaForm "FGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDFIELD \n\n")
-
- fprintf(COpyViaForm "FIELD Radio4\n")
- fprintf(COpyViaForm "FLOC 18 4\n")
- fprintf(COpyViaForm "CHECKLIST "50" "rg"\n")
- fprintf(COpyViaForm "FGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDFIELD \n\n")
- );end when
- when(car(axlDBGetDesignUnits())=="millimeters"
- fprintf(COpyViaForm "FIELD Radio1\n")
- fprintf(COpyViaForm "FLOC 8 2\n")
- fprintf(COpyViaForm "CHECKLIST "0.5" "rg"\n")
- fprintf(COpyViaForm "FGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDFIELD \n\n")
-
- fprintf(COpyViaForm "FIELD Radio2\n")
- fprintf(COpyViaForm "FLOC 18 2\n")
- fprintf(COpyViaForm "CHECKLIST "0.8" "rg"\n")
- fprintf(COpyViaForm "FGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDFIELD \n\n")
-
- fprintf(COpyViaForm "FIELD Radio3\n")
- fprintf(COpyViaForm "FLOC 8 4\n")
- fprintf(COpyViaForm "CHECKLIST "1.0" "rg"\n")
- fprintf(COpyViaForm "FGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDFIELD \n\n")
-
- fprintf(COpyViaForm "FIELD Radio4\n")
- fprintf(COpyViaForm "FLOC 18 4\n")
- fprintf(COpyViaForm "CHECKLIST "1.27" "rg"\n")
- fprintf(COpyViaForm "FGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDFIELD \n\n")
- );end when
- fprintf(COpyViaForm "FIELD Radio5\n")
- fprintf(COpyViaForm "FLOC 8 6\n")
- fprintf(COpyViaForm "CHECKLIST "Renew:" "rg"\n")
- fprintf(COpyViaForm "FGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDFIELD \n\n")
- fprintf(COpyViaForm "FIELD Input\n")
- fprintf(COpyViaForm "FLOC 16 6\n")
- fprintf(COpyViaForm "FSIZE 4 2\n")
- fprintf(COpyViaForm "STRFILLIN 6 32\n")
- fprintf(COpyViaForm "FGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDFIELD \n\n\n")
- curdesignunit = axlGetParam("paramDesign")->units
- fprintf(COpyViaForm "TEXT %L\n" curdesignunit) ;curdesignunit是1个变量
- fprintf(COpyViaForm "FLOC 24 6\n")
- fprintf(COpyViaForm "TGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDTEXT\n\n")
- fprintf(COpyViaForm "FIELD Button_Up\n")
- fprintf(COpyViaForm "FLOC 11 11\n")
- fprintf(COpyViaForm "MENUBUTTON "Up" 11 3\n")
- fprintf(COpyViaForm "FGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDFIELD \n\n")
- fprintf(COpyViaForm "FIELD Button_Down\n")
- fprintf(COpyViaForm "FLOC 11 17\n")
- fprintf(COpyViaForm "MENUBUTTON "Down" 11 3\n")
- fprintf(COpyViaForm "FGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDFIELD \n\n")
- fprintf(COpyViaForm "FIELD Button_Left\n")
- fprintf(COpyViaForm "FLOC 1 14\n")
- fprintf(COpyViaForm "MENUBUTTON "Left" 11 3\n")
- fprintf(COpyViaForm "FGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDFIELD \n\n")
- fprintf(COpyViaForm "FIELD Button_Right\n")
- fprintf(COpyViaForm "FLOC 22 14\n")
- fprintf(COpyViaForm "MENUBUTTON "Right" 11 3\n")
- fprintf(COpyViaForm "FGROUP "Form1"\n")
- fprintf(COpyViaForm "ENDFIELD \n\n")
- fprintf(COpyViaForm "ENDTILE\n\n")
- fprintf(COpyViaForm "ENDFORM\n\n")
- close(COpyViaForm)
- )
- defun(CopyVia_CallBack (COpyViaForm_KLJ)
- let( (dist field cnt)
- printf("field/value %L = %L (int %L\n)" COpyViaForm_KLJ->curField, COpyViaForm_KLJ->curValue, COpyViaForm_KLJ->curValueInt )
- printf("doneState %L\n" COpyViaForm_KLJ->doneState )
- case(COpyViaForm_KLJ->curField
- ("Button_Up"
- dist = getDistanceValue(COpyViaForm_KLJ)
- when(dist
- CopyViaBySameDimension(0 dist)
- );end when
- )
- ("Button_Down"
- dist = getDistanceValue(COpyViaForm_KLJ)
- when(dist
- CopyViaBySameDimension(0 -dist)
- );end when
- )
- ("Button_Left"
- dist = getDistanceValue(COpyViaForm_KLJ)
- when(dist
- CopyViaBySameDimension(-dist 0)
- );end when
- )
- ("Button_Right"
- dist = getDistanceValue(COpyViaForm_KLJ)
- when(dist
- CopyViaBySameDimension(dist 0)
- );end when
- )
- ("Radio1"
- )
- ("Radio2"
- )
- ("Radio3"
-
- )
- ("Radio4"
-
- )
- ("Input"
- )
- );end let
- );end procedure
- if((nequal COpyViaForm_KLJ->doneState 0)
- axlFormClose(COpyViaForm_KLJ))
- )
- ; 辅助函数:获取距离值
- defun(getDistanceValue (form)
- let((dist)
- Radio_num1 = axlFormGetField(form "Radio1")
- Radio_num2 = axlFormGetField(form "Radio2")
- Radio_num3 = axlFormGetField(form "Radio3")
- Radio_num4 = axlFormGetField(form "Radio4")
- Radio_num5 = axlFormGetField(form "Radio5")
- when(Radio_num1
- when(car(axlDBGetDesignUnits()) == "mils" dist = float(19.69))
- when(car(axlDBGetDesignUnits()) == "millimeters" dist = float(0.5))
- )
- when(Radio_num2
- when(car(axlDBGetDesignUnits()) == "mils" dist = float(31.5))
- when(car(axlDBGetDesignUnits()) == "millimeters" dist = float(0.8))
- )
- when(Radio_num3
- when(car(axlDBGetDesignUnits()) == "mils" dist = float(39.37))
- when(car(axlDBGetDesignUnits()) == "millimeters" dist = float(1.0))
- )
- when(Radio_num4
- when(car(axlDBGetDesignUnits()) == "mils" dist = float(50))
- when(car(axlDBGetDesignUnits()) == "millimeters" dist = float(1.27))
- )
- when(Radio_num5
- dist = atof(axlFormGetField(form "Input"))
- )
- dist
- );end let
- );end defun
- defun( CopyViaBySameDimension (x_offset y_offset)
- let((ViaDbid)
- axlSetFindFilter(?enabled (list "noall" "VIAS") ?onButtons (list "VIAS"))
- ;axlClearSelSet()
- axlMsgPut("Select a via as reference...")
- selectedVia = axlSingleSelectPoint()
- ViaDbid = axlGetSelSet(selectedVia) ;获取选择对象的DBID
- ;unless(axlOKToProceed() axlShell("done"))
- when(ViaDbid
- padstackName = car(ViaDbid)->name ;获取焊盘名称
- ViaNet = car(ViaDbid)->net->name ;获取当前选择过孔的网络名称
- ViaXY = car(ViaDbid)->xy ;获取当前选择过孔的坐标
- ViaRotation = car(ViaDbid)->via->rotation ;获取旋转角度
- ViaMirror = car(ViaDbid)->via->mirrored ;获取旋转角度
- );end when
- x = xCoord(ViaXY) ; 获取x坐标
- y = yCoord(ViaXY) ; 获取y坐标
- ;点击左右则x变化,y不变
- x = x + x_offset
- ;点击上下则y变化,X不变
- y = y + y_offset
- ;unless(axlOKToProceed() axlShell("done"))
- newVia = axlDBCreateVia(padstackName , x:y , ViaNet, ViaMirror , ViaRotation , nil) ;创建过孔
- when(newVia
- NewViaDbid = list(car(newVia))
- axlHighlightObject(NewViaDbid)
- );end when
-
- );end let
- );end defun
-
-
-
-
-
复制代码
|
|