EDA365电子工程师网

标题: 求助:文字转shape [打印本页]

作者: chengcheng123    时间: 2018-4-10 20:34
标题: 求助:文字转shape
因为文字的Bbox比文字本身要大一些。所以想把文字转为shape再去比较文字和文字以及文字和其他东西有没有重叠。
之前在网上看到过大神提供的思路:先用axlText2Lines ,再用axlPolyFromDB,最后用axlDBCreateShape,但是我试了一下午都没有成功。有高手可以帮忙看看吗?或者有其他更好的办法不。我的最终目的是要判断文字和文字、焊盘、零件外框之类的有没有重叠。感谢感谢~~~

作者: jordanli22    时间: 2018-4-11 09:32
axlCmdRegister("c2s" 'LCB_cline_to_shape ?cmdType "interactive"
?doneCmd 'LCB_Done ?cancelCmd 'LCB_Cancel)
axlSetFunckey("cts" "c2sXXX")
procedure(LCB_cline_to_shape()
let( ()
axlSetFindFilter(?enabled list("noall" "clines" "lines" )
                  ?onButtons list("noall" "clines" "lines"))
LCBpopup = axlUIPopupDefine( nil (list
    (list "Undo" 'LCB_unDo)
    (list "Done" 'LCB_Done)
    (list "Cancel" 'LCB_Cancel)
     ))
axlUIPopupSet(LCBpopup)

LCB_mark = axlDBTransactionStart()
notdone = t
while(notdone
  lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))
  if(lclines then
    foreach(clinedbid lclines
      ;layer = "etch/bottom"
      layer = car(axlGetSelSet())->layer
       polydbid = axlPolyFromDB(clinedbid ?endCapType "ROUND")
       if(polydbid then
        ;axlDeleteObject(clinedbid)
        if(! axlDBCreateShape(car(polydbid) t layer)  then
          axlUIWPrint(nil "** Error. Failed to create Shape from Cline. **")
        ); endif
        if(cadr(polydbid) then
            axlDBCreateShape(cadr(polydbid) t layer)  )
       else
        axlUIWPrint(nil "** Error. Failed to create Polydbid from Cline. **")
       ); endif
    ); end foreach cline
  ); endif
); end while
axlDBTransactionCommit(LCB_mark)

)); let and procedure

procedure(LCB_unDo()
let( ()
  if(! axlDBTransactionOops(LCB_mark) then
    axlUIWPrint(nil "-- Nothing Left To Undo. --")
  else
    axlUIWPrint(nil "-- Replacing Clines. --")
  ); endif
  axlClearSelSet()
)); end let procedure

procedure(LCB_Cancel()
let( ()
  axlUIWPrint(nil "** Cancelled Program. **")
  ;axlDBTransactionRollback(LCB_mark)
  notdone = nil
  axlClearSelSet()
  axlCancelEnterFun()

)); end let procedure

procedure(LCB_Done()
let( ()
  axlUIWPrint(nil "- Done -")
  axlDBTransactionCommit(LCB_mark)
  notdone = nil
  axlCancelEnterFun()
   
)); end let and procedure

作者: jordanli22    时间: 2018-4-11 09:34
[attach]137180[/attach]

作者: leilei4908    时间: 2018-4-11 10:47
本帖最后由 leilei4908 于 2018-4-11 10:49 编辑

lines = axlText2Lines(text)
paths = foreach(mapcan x lines x)
tPolys = nil
foreach(path paths
      polys = axlPolyFromDB(path ?endCapType 'ROUND ?line2poly t)
      foreach(poly polys
             tPolys = axlPolyOperation(tPolys poly 'OR)
      )
)
unless(listp(tPolys) tPolys = list(tPolys))
foreach(tPoly tPolys
      axlDBCreateShape(tPoly t "BOARD GEOMETRY/SILKSCREEN_TOP")
)
这个方式仅限于16.6及以上版本使用


作者: leilei4908    时间: 2018-4-11 10:48
本帖最后由 leilei4908 于 2018-4-11 10:51 编辑
jordanli22 发表于 2018-4-11 09:32
axlCmdRegister("c2s" 'LCB_cline_to_shape ?cmdType "interactive"
?doneCmd 'LCB_Done ?cancelCmd 'LCB ...


楼主要的是文字转图形,不是铜线转图形

作者: chengcheng123    时间: 2018-4-11 16:19
leilei4908 发表于 2018-4-11 10:47
lines = axlText2Lines(text)
paths = foreach(mapcan x lines x)
tPolys = nil

试了,很好哦,非常非常感谢您
作者: chengcheng123    时间: 2018-4-11 16:20
jordanli22 发表于 2018-4-11 09:32
axlCmdRegister("c2s" 'LCB_cline_to_shape ?cmdType "interactive"
?doneCmd 'LCB_Done ?cancelCmd 'LCB ...

改天再来研究下你这个。感谢Jordan童鞋~~
作者: leilei4908    时间: 2018-4-11 16:29
chengcheng123 发表于 2018-4-11 16:19
试了,很好哦,非常非常感谢您

检查文字是否与焊盘重叠,可以用axlPolyOperation(tPoly pPoly 'And)判断





欢迎光临 EDA365电子工程师网 (https://bbs.elecnest.cn/) Powered by Discuz! X3.2