Cadence Skill 论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 18380|回复: 27

cline2shape SKILL源码分享,详解

[复制链接]
发表于 2013-4-18 21:41:15 | 显示全部楼层 |阅读模式
  1. axlCmdRegister("cline2shape" 'LCB_cline_to_shape ?cmdType "interactive"
  2. ?doneCmd 'LCB_Done ?cancelCmd 'LCB_Cancel)

  3. procedure(LCB_cline_to_shape()
  4. let( ()
  5. axlSetFindFilter(?enabled list("noall" "clines")
  6.                   ?onButtons list("noall" "clines"))
  7. LCBpopup = axlUIPopupDefine( nil (list
  8.     (list "Undo" 'LCB_unDo)
  9.     (list "Done" 'LCB_Done)
  10.     (list "Cancel" 'LCB_Cancel)
  11.      ))
  12. axlUIPopupSet(LCBpopup)

  13. LCB_mark = axlDBTransactionStart()
  14. notdone = t
  15. while(notdone
  16.   lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))
  17.   if(lclines then
  18.     foreach(clinedbid lclines
  19.       layer = "etch/bottom"
  20.        polydbid = axlPolyFromDB(clinedbid ?endCapType "ROUND")
  21.        if(polydbid then
  22.         axlDeleteObject(clinedbid)
  23.         if(! axlDBCreateShape(car(polydbid) t layer)  then
  24.           axlUIWPrint(nil "** Error. Failed to create Shape from Cline. **")
  25.         ); endif
  26.         if(cadr(polydbid) then
  27.             axlDBCreateShape(cadr(polydbid) t layer)  )
  28.        else
  29.         axlUIWPrint(nil "** Error. Failed to create Polydbid from Cline. **")
  30.        ); endif
  31.     ); end foreach cline
  32.   ); endif
  33. ); end while
  34. axlDBTransactionCommit(LCB_mark)

  35. )); let and procedure

  36. procedure(LCB_unDo()
  37. let( ()
  38.   if(! axlDBTransactionOops(LCB_mark) then
  39.     axlUIWPrint(nil "-- Nothing Left To Undo. --")
  40.   else
  41.     axlUIWPrint(nil "-- Replacing Clines. --")
  42.   ); endif
  43.   axlClearSelSet()
  44. )); end let procedure

  45. procedure(LCB_Cancel()
  46. let( ()
  47.   axlUIWPrint(nil "** Cancelled Program. **")
  48.   ;axlDBTransactionRollback(LCB_mark)
  49.   notdone = nil
  50.   axlClearSelSet()
  51.   axlCancelEnterFun()

  52. )); end let procedure


  53. procedure(LCB_Done()
  54. let( ()
  55.   axlUIWPrint(nil "- Done -")
  56.   axlDBTransactionCommit(LCB_mark)
  57.   notdone = nil
  58.   axlCancelEnterFun()
  59.    
  60. )); end let and procedure
复制代码
编程思路:
1.首先通过axlSetFindFilter设置过滤元素,然后选中需要变为铜皮的Cline,并将选中的Cline的dbid存放于lclines中。
2.通过foreach循环函数,逐个将lclines中的元素取出,使用axlPolyFromDB函数获取cline的几何形状。
3.axlDBCreateShape创建shape
发表于 2013-7-3 10:58:32 | 显示全部楼层
本帖最后由 XYX365 于 2013-7-3 11:07 编辑

多加入一些功能
Shape可以設為靜態或動態
將the end cap type 改為可以變更

  1. procedure(LCB_cline_to_shape()
  2. let( ()
  3. axlSetFindFilter(?enabled list("noall" "LINES" "clines") ?onButtons list("noall" "LINES" "clines"))
  4. LCBpopup = axlUIPopupDefine( nil (list
  5. list("Done" 'LCB_Done)
  6. list("Undo" 'LCB_unDo)
  7. list("Cancel" 'LCB_Cancel)
  8. list("MENU_SEPARATOR" nil)
  9. list("Set Dynamic" "bDynamic = t")
  10. list("Set Statics" "bDynamic = nil")
  11. list("MENU_SEPARATOR" nil)
  12. list("EndCapType = OCTAGON" "sEndCapType = 'OCTAGON")
  13. list("EndCapType = ROUND" "sEndCapType = 'ROUND")
  14. list("EndCapType = SQUARE" "sEndCapType = 'SQUARE")
  15. ))
  16. axlUIPopupSet(LCBpopup)
  17. LCBstartMark = axlDBTransactionStart()
  18. notdone = t
  19. bDynamic = t
  20. sEndCapType = 'OCTAGON
  21. while(notdone
  22. lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))
  23. if(lclines then
  24. foreach(clinedbid lclines ;clinedbid = car(lclines)
  25. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  26. net = clinedbid->net->name
  27. layer = clinedbid->layer
  28. ;******************
  29. unless(clinedbid->isEtch
  30. bDynamic = nil
  31. )
  32. axlUIWPrint(layer "** now layer is layer. **")
  33. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  34. polydbid = axlPolyFromDB(clinedbid ?endCapType sEndCapType)
  35. if(polydbid then
  36. axlDeleteObject(clinedbid)
  37. if(bDynamic then
  38. tNewLayer = strcat("BOUNDARY/" cadr(parseString(layer "/")))
  39. unless(axlDBCreateShape(car(polydbid) t tNewLayer net)
  40. axlUIWPrint(nil "** Error. Failed to create Shape from Cline. **")
  41. ); endif
  42. else
  43. unless(axlDBCreateShape(car(polydbid) t Layer net)
  44. axlUIWPrint(nil "** Error. Failed to create Shape from Cline. **")
  45. ); endif
  46. )
  47. if(cadr(polydbid) then
  48. if(bDynamic then
  49. tNewLayer = strcat("BOUNDARY/" cadr(parseString(layer "/")))
  50. axlDBCreateShape(cadr(polydbid) t tNewLayer net)
  51. else
  52. axlDBCreateShape(cadr(polydbid) t layer net)
  53. )
  54. )
  55. else
  56. axlUIWPrint(nil "** Error. Failed to create Polydbid from Cline. **")
  57. ); endif
  58. ); end foreach cline
  59. ); endif
  60. ); end while
  61. axlDBTransactionCommit(LCBstartMark)
  62. )); let and procedure

  63. procedure(LCB_unDo()
  64. let( ()
  65.   if(! axlDBTransactionOops(LCB_mark) then
  66.     axlUIWPrint(nil "-- Nothing Left To Undo. --")
  67.   else
  68.     axlUIWPrint(nil "-- Replacing Clines. --")
  69.   ); endif
  70.   axlClearSelSet()
  71. )); end let procedure

  72. procedure(LCB_Cancel()
  73. let( ()
  74.   axlUIWPrint(nil "** Cancelled Program. **")
  75.   ;axlDBTransactionRollback(LCB_mark)
  76.   notdone = nil
  77.   axlClearSelSet()
  78.   axlCancelEnterFun()
  79. )); end let procedure

  80. procedure(LCB_Done()
  81. let( ()
  82.   axlUIWPrint(nil "- Done -")
  83.   axlDBTransactionCommit(LCB_mark)
  84.   notdone = nil
  85.   axlCancelEnterFun()
  86.    
  87. )); end let and procedure




复制代码
 楼主| 发表于 2013-7-3 22:18:05 | 显示全部楼层
XYX365 发表于 2013-7-3 10:58
多加入一些功能
Shape可以設為靜態或動態
將the end cap type 改為可以變更

呵呵,不错。多谢。。
发表于 2014-4-2 17:55:44 | 显示全部楼层
很好 学习了;
发表于 2014-7-5 00:28:17 | 显示全部楼层
这个好,终于见到了,谢谢分享
发表于 2014-7-24 21:01:11 | 显示全部楼层
学习学习!谢谢!
发表于 2014-7-25 17:21:32 | 显示全部楼层
好贴,学习了!
发表于 2014-8-20 09:55:32 | 显示全部楼层
好帖,楼主真伟大!
发表于 2014-8-20 19:07:47 | 显示全部楼层
LZ真伟大!感谢LZ的分享
发表于 2014-9-21 21:55:05 | 显示全部楼层
XYX365 发表于 2013-7-3 10:58
多加入一些功能
Shape可以設為靜態或動態
將the end cap type 改為可以變更

表示不懂得怎么变更
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|网站地图|Cadence Skill 论坛 ( 蜀ICP备13024417号 )

GMT+8, 2024-4-27 04:44 , Processed in 0.153674 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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