明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2306|回复: 4

[函数] if not found Layer & Text Style (Entmake)

[复制链接]
发表于 2011-1-19 18:26:32 | 显示全部楼层 |阅读模式
Dear All,
Please Help me
I was created text style & layer if not found
1) text style (xyz) , layer (text) & same pline layer (text) around the text

  1. ;;------------------------------------------------------------;;
  2. ;;   Carpet Area Program         ;;
  3. ;;  This Program Created area of pline (@ mm Drawing only)    ;;
  4. ;;------------------------------------------------------------;;
  5. (defun c:CA nil (c:CarpetArea))
  6. (defun c:CarpetArea (/ *error* p5 p6 a b c d e f s)
  7. (vl-load-com)
  8. ;;------------------------------------------------------------;;
  9. ;;                        please add                                 ;;
  10. ;;                        Error Handler                       ;;
  11. ;;------------------------------------------------------------;;

  12. ;;---------                 entmake               ------------;;
  13. ;;--------------- if not found Layer & Text Style ------------;;
  14. ;;------------------ Create Layer & Text Style ---------------;;
  15. ;; layer      = xyz
  16. ;; text style = room
  17. ;; pline layer around text = xyz
  18.   


  19. ;;------------------------------------------------------------;;
  20. (if (and (setq s (ssget "_:S:E" '((0 . "LWPOLYLINE"))))
  21. (setq p5 (getpoint "\nWHERE TO PLACE TEXT: "))
  22. )
  23. ;;------------------------------------------------------------;;
  24. (progn
  25. (setq p5 (polar p5 pi 1250))
  26. (setq p6 (polar p5 0 2500))
  27. (command "._area" "_e" (ssname s 0))
  28. (SETQ A (GETVAR "AREA"))
  29. (setq f (* A 0.000010764))
  30. (setq f (rtos f 2 2))
  31. (SETQ f (strcat f " SQ. FT."))
  32. (SETQ B (/ A 1000000))
  33. (SETQ C (RTOS B 2 2))
  34. (SETQ D "CARPET AREA")
  35. (setq e (strcat "= " C " SQ.MT."))
  36. (setq F (strcat "= " F))
  37. ;;------------------------------------------------------------;;
  38. (COMMAND "_TEXT" "_S" "room" "_f" P5 p6 "250" D
  39. "_text" "" e
  40. "_text" "" f
  41. "_.rectangle"
  42. (mapcar '+ P5 '(-165 440 0))
  43. (mapcar '+ P6 '(165 -1045 0))
  44. ) ; end command
  45. ;;------------------------------------------------------------;;
  46. );; End Progn
  47. (princ "\n   ~¤~     ...Type "Ca" to Invoke...        ~¤~   ")
  48. );; End IF
  49. (princ)
  50. ;; Exit Cleanly
  51. );; End defun
  52. ;;----------------------End Program --------------------------;;

"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2011-1-19 21:03:13 | 显示全部楼层
  1. ;;;param : s table Name
  2. (defun table (s / d r)
  3.   (while (setq d (tblnext s (null d)))
  4.     (setq r (cons (cdr (assoc 2 d)) r))
  5.   )
  6. )
  7. example:
  8. 1. (table  "style") return all text style name.
  9. 2.  (table  "layer") return all layer name.

 楼主| 发表于 2011-1-20 15:01:30 | 显示全部楼层
回复 Gu_xl 的帖子

Dear sir,
thx for reply
Can u complicated my code, I will try u r code but error coming
发表于 2011-1-20 22:12:19 | 显示全部楼层

  1. ;;------------------------------------------------------------;;
  2. ;;   Carpet Area Program         ;;
  3. ;;  This Program Created area of pline (@ mm Drawing only)    ;;
  4. ;;------------------------------------------------------------;;
  5. (defun c:CA nil (c:CarpetArea))
  6. (defun c:CarpetArea (/ *error* p5 p6 a b c d e f s)
  7. (vl-load-com)
  8. ;;------------------------------------------------------------;;
  9. ;;                        please add                                 ;;
  10. ;;                        Error Handler                       ;;
  11. ;;------------------------------------------------------------;;

  12. ;;---------                 entmake               ------------;;
  13. ;;--------------- if not found Layer & Text Style ------------;;
  14. ;;------------------ Create Layer & Text Style ---------------;;
  15. ;; layer      = xyz
  16. ;; text style = room
  17. ;; pline layer around text = xyz
  18.   


  19. ;;------------------------------------------------------------;;
  20. (if (and (setq s (ssget "_:S:E" '((0 . "LWPOLYLINE"))))
  21. (setq p5 (getpoint "\nWHERE TO PLACE TEXT: "))
  22. )
  23. ;;------------------------------------------------------------;;
  24. (progn
  25. (setq p5 (polar p5 pi 1250))
  26. (setq p6 (polar p5 0 2500))
  27. (command "._area" "_e" (ssname s 0))
  28. (SETQ A (GETVAR "AREA"))
  29. (setq f (* A 0.000010764))
  30. (setq f (rtos f 2 2))
  31. (SETQ f (strcat f " SQ. FT."))
  32. (SETQ B (/ A 1000000))
  33. (SETQ C (RTOS B 2 2))
  34. (SETQ D "CARPET AREA")
  35. (setq e (strcat "= " C " SQ.MT."))
  36. (setq F (strcat "= " F))
  37. ;;------------------------------------------------------------;;
  38. (setq oldlayer (getvar "CLAYER"))
  39. (if (tblsearch "LAYER" "text")
  40. (setvar "CLAYER" "text")
  41. (command ".LAYER" "M" "text" "")
  42. )
  43. (if (tblsearch "STYLE" "room")
  44. (princ)
  45. (command ".STYLE" "room" "ROMANS" "" "0.7" "" "" "" "")
  46. )
  47. (COMMAND "_TEXT" "_S" "room" "_f" P5 p6 "250" D
  48. "_text" "" e
  49. "_text" "" f
  50. "_.rectangle"
  51. (mapcar '+ P5 '(-165 440 0))
  52. (mapcar '+ P6 '(165 -1045 0))
  53. ) ; end command
  54. (setvar "CLAYER" oldlayer)
  55. ;;------------------------------------------------------------;;
  56. );; End Progn
  57. (princ "\n   ~¤~     ...Type "Ca" to Invoke...        ~¤~   ")
  58. );; End IF
  59. (princ)
  60. ;; Exit Cleanly
  61. );; End defun
  62. ;;----------------------End Program --------------------------;;
 楼主| 发表于 2011-1-21 14:31:48 | 显示全部楼层
回复 ZZXXQQ 的帖子

Dear sir,
Thx for reply
great it's working thx lot
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-19 08:53 , Processed in 0.175143 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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