|
本帖最后由 紫菁 于 2017-11-3 14:30 编辑
EDA365 Skill 工具箱有这个工具,但是有问题,所以没事自己重写了一下;
主要是为了出dxf时将hole空能够输出到dxf文件,直接上代码:执行前========>
执行后=======>
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;draw drill holes as shape to BOARD GEOMETRY/DrillHole
- ;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- axlCmdRegister( "drlh" `drill_hole_by)
- num = 0
- cnt = 0
- pi = 3.141592
- (defun drill_hole_by ()
- saveVis = axlVisibleGet()
- axlVisibleDesign(nil)
- ; set desired layers visible via one or more calls to
- axlVisibleLayer("pin/top" t)
- creat_layer_drlh()
- ;;turn_on_layer( layer)
- formname = "./drlhole.form"
- biuld_form_drlh(formname)
- )
- (defun creat_layer_drlh ()
- ; ########################################################
- ; Check for the existence of "BOARD GEOMETRY/DrillHole" layer
- ; ########################################################
- if(axlIsLayer("BOARD GEOMETRY/Drillhole") == nil then
- axlUIConfirm("You must have a\"BOARD GEOMETRY/DrillHole\" subclass defined")
- axlLayerCreateNonConductor("BOARD GEOMETRY/Drillhole")
- else
- axlMsgPut("---Dirll holes to :BOARD GEOMETRY/Drillhole")
- );end if
- ); end creat_layer_drlh
- (defun biuld_form_drlh (formname)
- (prog ()
- pform = outfile(formname "w")
- fprintf(pform "FILE_TYPE=FORM_DEFN VERSION=2\n")
- fprintf(pform "FORM toolwindow\n")
- fprintf(pform "FIXED\n")
- fprintf(pform "PORT 20 10\n")
- ;PORT w h
- fprintf(pform "HEADER \"byao\"\n")
- fprintf(pform "TILE\n")
- fprintf(pform "TEXT \"Drill Hole to Shape V1.0\"\n")
- fprintf(pform "OPTIONS UNDERLINE BOLD\n")
- fprintf(pform "TLOC 0 0\n")
- fprintf(pform "ENDTEXT\n")
- fprintf(pform "FIELD drawhole\n")
- fprintf(pform "FLOC 1 2\n") ;FLOC x y
- fprintf(pform "MENUBUTTON \"Drawhole\" 10 3\n")
- fprintf(pform "ENDFIELD\n")
- fprintf(pform "FIELD clearshape\n")
- fprintf(pform "FLOC 1 5\n")
- fprintf(pform "MENUBUTTON \"ClearShape\" 10 3\n")
- fprintf(pform "ENDFIELD\n")
- fprintf(pform "FIELD done\n")
- fprintf(pform "FLOC 1 8\n")
- fprintf(pform "MENUBUTTON \"Done\" 10 3\n")
- fprintf(pform "ENDFIELD\n")
- fprintf(pform "FLEXMODE EdgeGravityOne\n")
- fprintf(pform "FLEX drawhole 0 0 1 1\n")
- fprintf(pform "FLEX clearshape 0 1 0 0\n")
- fprintf(pform "FLEX done 0 1 0 0\n")
- fprintf(pform "ENDTILE\n")
- fprintf(pform "ENDFORM\n")
- close(pform)
- form=axlFormCreate( (gensym) "drlhole.form"
- `(e inner) `pform_Action_drlh t)
- axlFormDisplay(form)
- ))
- (defun pform_Action_drlh (form)
- axlDBRefreshId(axlDBGetDesign())
- (case form->curField
- ("done"
- axlFormClose(form)
- axlCancelEnterFun()
- deleteFile(formname)
- axlMsgPut("Done")
- nil
- )
- ("drawhole"
- axlMsgPut("Draw Holes........" )
- draw_hole_drlh()
- t
- )
- ("clearshape"
- clear_shape()
- t
- )
- );end case
- );end defun
- (defun unselect_object_drlh ()
- (let (allsel)
- axlSetFindFilter(?enabled '(noall shapes pins vias text) ?onButtons '(noall shapes pins vias text))
- ; axlSetFindFilter(?enabled '(all) ?onButtons '(all))
- allsel = axlGetSelSet(axlAddSelectAll())
- axlClearSelSet()
- axlSetFindFilter(?enabled '(noall symbols) ?onButtons '(noall symbols))
- allsel = axlGetSelSet(axlAddSelectAll())
- axlClearSelSet()
- )
- )
- (defun draw_circle (x y dia)
- mycirpath = axlPathStartCircle((list x:y dia/2),0)
- axlDBCreateCloseShape( axlDBCreateOpenShape( mycirpath, t,"BOARD GEOMETRY/Drillhole", nil))
- )
- (defun draw_oval_slot (x y w h r) ;;w=dia
- ;;x'=x*cos(r)-y*sin(r);y'=y*cos(r)+x*sin(r)
- ll = ((x+((-w/2)*cos(pi*r/180)-(-(h-w)/2)*sin(pi*r/180))) : (y+(-(w/2)*sin(pi*r/180)+(-(h-w)/2)*cos(pi*r/180)))) ;;low left
- ul = ((x+((-w/2)*cos(pi*r/180)-((h-w)/2)*sin(pi*r/180))) : (y+((-w/2)*sin(pi*r/180)+((h-w)/2)*cos(pi*r/180))))
- ur = ((x+((w/2)*cos(pi*r/180)-((h-w)/2)*sin(pi*r/180))) : (y+((w/2)*sin(pi*r/180)+((h-w)/2)*cos(pi*r/180))))
- lr = ((x+((w/2)*cos(pi*r/180)-(-(h-w)/2)*sin(pi*r/180))) : (y+((w/2)*sin(pi*r/180)+(-(h-w)/2)*cos(pi*r/180))))
- mypath = axlPathStart( list(ll) )
- mypath = axlPathLine( mypath, 0.0, ul )
- mypath = axlPathArcAngle(mypath, 0.0, ur, t, 180)
- mypath = axlPathLine( mypath, 0.0, lr)
- mypath = axlPathArcAngle(mypath, 0.0, ll , t, 180)
- myshape = axlDBCreateOpenShape( mypath, t,"board geometry/drillhole", nil)
- axlDBCreateCloseShape( myshape)
- )
- (defun draw_rect_slot (x y w h r)
- ;;x'=x*cos(r)-y*sin(r);y'=y*cos(r)+x*sin(r)
- ll = ((x+((-w/2)*cos(pi*r/180)-(-h/2)*sin(pi*r/180))) : (y+(-(w/2)*sin(pi*r/180)+(-h/2)*cos(pi*r/180)))) ;;low left
- ul = ((x+((-w/2)*cos(pi*r/180)-(h/2)*sin(pi*r/180))) : (y+((-w/2)*sin(pi*r/180)+(h/2)*cos(pi*r/180))))
- ur = ((x+((w/2)*cos(pi*r/180)-(h/2)*sin(pi*r/180))) : (y+((w/2)*sin(pi*r/180)+(h/2)*cos(pi*r/180))))
- lr = ((x+((w/2)*cos(pi*r/180)-(-h/2)*sin(pi*r/180))) : (y+((w/2)*sin(pi*r/180)+(-h/2)*cos(pi*r/180))))
- mypath = axlPathStart( list(ll) )
- mypath = axlPathLine( mypath, 0.0, ul )
- mypath = axlPathLine( mypath, 0.0, ur )
- mypath = axlPathLine( mypath, 0.0, lr )
- mypath = axlPathLine( mypath, 0.0, ll )
- myshape = axlDBCreateOpenShape( mypath, t,"board geometry/drillhole", nil)
- axlDBCreateCloseShape( myshape)
- )
- (defun draw_hole_drlh ()
- clear_shape()
- unselect_object_drlh()
- axlSetFindFilter(?enabled '(noall pins) ?onButtons '(noall pins))
- allpins = axlGetSelSet(axlAddSelectAll())
- foreach(item allpins
- if(item->isThrough then
- padstack_ = item->definition
- cnt++
- case(padstack_->holeType
- ("circle_drill"
- x = nthelem(1 item->xy)
- y = nthelem(2 item->xy)
- x_offset = nthelem(1 padstack_->drillOffset)
- y_offset = nthelem(2 padstack_->drillOffset)
- r = item->rotation
- dia = padstack_->drillDiameter
- draw_circle((x+(x_offset*cos(pi*r/180)-y_offset*sin(pi*r/180))) (y+(x_offset*sin(pi*r/180)+y_offset*cos(pi*r/180))) dia)
- t
- )
- ("oval_slot"
- x = nthelem(1 item->xy)
- y = nthelem(2 item->xy)
- x_offset = nthelem(1 padstack_->drillOffset)
- y_offset = nthelem(2 padstack_->drillOffset)
- w = padstack_->drillSizeWidth
- h = padstack_->drillSizeHeight
- r = item->rotation
- draw_oval_slot((x+(x_offset*cos(pi*r/180)-y_offset*sin(pi*r/180))) (y+(x_offset*sin(pi*r/180)+y_offset*cos(pi*r/180))) w h r)
- t
- )
- ("rectangle_slot"
- x = nthelem(1 item->xy)
- y = nthelem(2 item->xy)
- x_offset = nthelem(1 padstack_->drillOffset)
- y_offset = nthelem(2 padstack_->drillOffset)
- w = padstack_->drillSizeWidth
- h = padstack_->drillSizeHeight
- r = item->rotation
- draw_rect_slot((x+(x_offset*cos(pi*r/180)-y_offset*sin(pi*r/180))) (y+(x_offset*sin(pi*r/180)+y_offset*cos(pi*r/180))) w h r)
- t
- )
- (t
- x = nthelem(1 item->xy)
- y = nthelem(2 item->xy)
- printf("Wanning:%f %f %s\n" x y padstack_->holeType)
- )
- );case
- );end if
- );end foreach
- unselect_object_drlh()
- ; restore visiblility
- axlVisibleSet(saveVis)
- axlVisibleLayer("BOARD GEOMETRY/Drillhole" t)
- ; note no need to make a call to axlVisibileUpdate because
- ; the visisbility changes are a wash
- axlVisibleUpdate(t)
- axlMsgPut("---Total of throughhole : %d" cnt)
- cnt=0
- )
- (defun clear_shape ()
- unselect_object_drlh()
- saveVisx = axlVisibleGet()
- axlVisibleDesign(nil)
- ; set desired layers visible via one or more calls to
- axlVisibleLayer("BOARD GEOMETRY/Drillhole" t)
- ; set find filter for objects to find
- axlSetFindFilter(?enabled '(noall shapes) ?onButtons '(noall shapes))
- axlAddSelectAll()
- axlDeleteObject(axlGetSelSet())
- ; restore visiblility
- axlVisibleSet(saveVisx)
- )
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
评分
-
查看全部评分
|