找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 2034|回复: 8

[求助] [求助]:当用程序调用AutoCAD命令Fillet或Chamfer时遇到如半径不合适,或在某个方向上

[复制链接]
发表于 2002-11-26 21:50:01 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
当用程序调用AutoCAD命令Fillet或Chamfer时遇到如半径不合适,或在某个方向上无法完成指定操作时,程序如何捕捉到错误的类型,或至少让程序能取消命令退出。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-11-26 21:54:06 | 显示全部楼层

Re: [求助]:当用程序调用AutoCAD命令Fillet或Chamfer时遇到如半径不合适,或在某个方向上无法完成指定操作时,程序如何捕捉到错误的类型,或至

最初由 mmmm 发布
[B]当用程序调用AutoCAD命令Fillet或Chamfer时遇到如半径不合适,或在某个方向上无法完成指定操作时,程序如何捕捉到错误的类型,或至少让程序能取消命令退出。 [/B]


你可以在把参数送给FILLET等命令前,先自己程序判断下,不满足提示给用户,或者重输入,或者退出,这样程序健壮。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2002-11-26 22:04:45 | 显示全部楼层
但从图形学上讲,那样就变成自己编FILLET等命令了。我想那不是Visual LISP程序能做的。
实际上,在程序中我们会送两个变量(两次点取的线段)给AutoCAD,如果AutoCAD无法完成
正常的操作,命令不退出。我只是想要程序在这是判断下命令是否已经结束,如果没有,表示
送的变量无法完成操作,我只是希望程序能自动退出FILLET等命令以执行其他的代码。否则
程序在这里会被打断而崩溃
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2002-11-26 22:19:56 | 显示全部楼层
154481
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2002-11-27 01:18:58 | 显示全部楼层
如果有新的实体产生,表示命令正常完成,反之。。。
(setq elast (entlast))
...
(command ".fillet")
(while roop
(setq pt1 () pt2 ()) ;;自己填
(command pt1 pt2)
(if (= elast (entlast)) (progn (command)(setq roop nil)))
...
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-11-27 01:45:13 | 显示全部楼层
最初由 mmmm 发布
[B]但从图形学上讲,那样就变成自己编FILLET等命令了。我想那不是Visual LISP程序能做的。
实际上,在程序中我们会送两个变量(两次点取的线段)给AutoCAD,如果AutoCAD无法完成
正常的操作,命令不退出。我只是想要?.. [/B]


判断命令是否结束,你可以用系统变量cmdactive

在COMMAND:提示状态,这个系统变量值=0,否,在命令执行中。

  1. [font=courier new]

  2. [color=blue]CMDACTIVE[/color]

  3. (只读)
  4. 类型:整数型
  5. 不保存
  6. 存储一个位码值,此位码值标识激活的是普通命令、透明命令、脚本还是对话框。本系统变量有以下可选位码值:

  7. 1        激活普通命令
  8. 2        激活普通命令和透明命令
  9. 4        激活脚本
  10. 8        激活对话框
  11. 16        激活 AutoLISP(仅 ObjectARX 定义的命令)
  12. [/font]
复制代码
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2002-11-27 02:34:06 | 显示全部楼层
贴个以前在001写的动态fillet倒角程序
其实这个程序对我没有什么用,当时只是为了验证一下所讨论的动态倒角问题。

  1.   [FONT=courier new]
  2. (defun c:fd (/ opdmode ep1 ep2 pt1 opt roop cenpt fr gr pt2 n na)
  3. (princ "\n fd=======动态fillet 倒圆角-----undo/b-------雄啸lxx.2001.5ok")
  4. (princ "\n支持line,arc,*polyline,circle--除了*polyline+*polyline ")
  5. (setq opdmode (getvar "pdmode"))
  6. (command "undo" "m" "cmdecho" "0" "blipmode" "off" "pdmode" "2")
  7. (while (not(setq ep1 (entsel "\n点取第一条线:"))))
  8. (while (not(setq ep2 (entsel "\n点取第二条线:"))))
  9. (setq pt1 (cadr ep2)
  10.       ;pt1 (getpoint "\nfillet 半径第一点:")
  11.       opt pt1
  12.       roop "true"
  13.       fr (getvar "filletrad")
  14. )
  15. (princ "\n当前filletrad=")(princ fr)
  16. (command "point" pt1 "filletrad" "");;; for undo
  17. (setq cenpt (entlast))
  18. (princ "\nfillet 半径第二点:")
  19. (while roop
  20.   (defun *error* (msg)(command "undo" "1" "erase" cenpt "")(princ "\n错误:")(princ msg)(setq *error* nil))
  21.   (setq gr (grread t 7 0))
  22.   (if (/= (car gr) 5)
  23.     (setq roop nil)
  24.     (if (not(equal (cadr gr) opt));;;else
  25.      (progn
  26.       (command "undo" "1")
  27.       (setq pt2 (cadr gr)
  28.             fr (distance pt1 pt2)
  29.             opt pt2)
  30.       (princ "\n当前filletrad=")(princ fr)
  31.       (setvar "filletrad" fr)
  32.       (command "fillet" ep1 ep2 ^c)
  33.      );end progn
  34.     );end if
  35.   );end if
  36. );end while
  37. (setq *error* nil)
  38. (if (= (car gr) 3);;;;;;;左键定filletrad
  39.   (setq  pt2 (cadr gr)
  40.          fr (distance pt1 pt2))
  41. )
  42. (if (and (= (car gr) 2)
  43.          (and(< 47 (cadr gr))
  44.              (> 58 (cadr gr))
  45.     )    );;;0~9 ascii 码值48~57
  46.     (setq n (chr(cadr gr))
  47.           na (getstring (strcat "\n键盘输入:filletrad=" n))
  48.           fr (atof (strcat n na))
  49.     )
  50. )
  51. (princ "\n当前filletrad=")(princ fr)
  52. (command "undo" "1")
  53. (setvar "filletrad" fr)
  54. (command "fillet" ep1 ep2 ^c "erase" cenpt "")
  55. (setvar "pdmode" opdmode)
  56. (princ)
  57. )

  58.   [/FONT]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 23个

财富等级: 恭喜发财

发表于 2002-11-27 09:36:03 | 显示全部楼层
这个问题是我觉得PKPM中有这个功能,希望AutoCAD也能实现而提出的...

江南兄牛刀小试即刻解决了....8-)
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2002-11-27 21:02:06 | 显示全部楼层
问题解决了,这个问题解决后,我编的扩充AutoCAD的Fillet/Chamfer命令就能够完全正常运行了,当半径或距离过大时也不会出错,在调用的命令会给用户一条提示,正好成为程序的错误提示。意想不到的效果。
欢迎试用

  1. ;;; ******************************************************************** ;;;
  2. ;;; Command to enhance AutoCAD native Fillet command                     ;;;
  3. ;;; This application can processing Fillet between Line-Line             ;;;
  4. ;;; Line-Polyline; Line-ARC; ARC-ARC; ARC-Polyline                       ;;;
  5. ;;; Polyline-Polyline and even different line or ARC segments            ;;;
  6. ;;; of a same polyline                                                   ;;;
  7. ;;; ******************************************************************** ;;;
  8. ;;; KozMos Public Freeware Service [2002.01]                             ;;;
  9. ;;; Programmed by Yota Masaru                                            ;;;
  10. ;;; Version: 2002.21124.1638                                             ;;;
  11. ;;; ReVersion: 2002.21127.2202 (quiet exit on too large radius)          ;;;
  12. ;;; Copyright(C) 1994-2002 by KozMos Inc.                                ;;;
  13. ;;; All rights reserved                                                  ;;;
  14. ;;; ******************************************************************** ;;;
  15. (Defun C:MFillet (/            Sub_CheckValid        XSub_GrDraw
  16.                   OldCmd    OldOsm    Obj1        Obj2          Pt1
  17.                   Pt2            SType     Swidth        SLayer          SColor
  18.                   Join            TType     SSet
  19.                  )
  20.   ;;; Sub-Function: [XSub_GrDraw]: Use GRDRAW with color 2 to redraw a line
  21.   ;;;               segments according to a point list
  22.   (Defun XSub_GrDraw (PointList Color / Start Next)
  23.     (if        (> (length PointList) 1)
  24.       (progn
  25.         (setq Start        (car PointList)
  26.               PointList        (append PointList (list Start))
  27.         )
  28.         (repeat        (1- (length PointList))
  29.           (setq        Next          (car PointList)
  30.                 PointList (cdr PointList)
  31.           )
  32.           (grdraw Start Next Color)
  33.           (setq Start Next)
  34.         )
  35.       )
  36.     )
  37.     (princ)
  38.   )
  39.   ;;; Sub-Function: [Sub_CheckValid]: Check if the segment picked by user
  40.   ;;;               is valid for running MFillet, the segment should be
  41.   ;;;               line or arc. If OK, Guse RDRAW to redraw that object
  42.   ;;;               with yellow.
  43.   ;;;               If a polyline is picked, the polyline will be exploded
  44.   ;;;               temperarily to check the segment.
  45.   (Defun Sub_CheckValid
  46.          (Data / XSub_GetRedrawData DataM Pt DType RedrawData Rtn)
  47.     (Defun XSub_GetRedrawData
  48.            (Obj / OType O10 O11 O40 O50 O51 Delta Rtn)
  49.       (setq OType (cdr (assoc 0 (entget Obj)))
  50.             O10          (cdr (assoc 10 (entget Obj)))
  51.             O11          (cdr (assoc 11 (entget Obj)))
  52.             O40          (cdr (assoc 40 (entget Obj)))
  53.             O50          (cdr (assoc 50 (entget Obj)))
  54.             O51          (cdr (assoc 51 (entget Obj)))
  55.       )
  56.       (cond ((= OType "LINE") (setq Rtn (list O10 O11)))
  57.             ((= OType "ARC")
  58.              (if (< O51 O50)
  59.                (setq O51 (+ (* 2 pi) O51))
  60.              )
  61.              (setq Delta (/ (- O51 O50) 50.0))
  62.              (repeat 50
  63.                (setq Rtn (cons (polar O10 O50 O40) Rtn)
  64.                      O50 (+ O50 Delta)
  65.                )
  66.              )
  67.             )
  68.       )
  69.       Rtn
  70.     )

  71.     (setq Pt        (cadr Data)
  72.           Data        (car Data)
  73.           DType        (cdr (assoc 0 (entget Data)))
  74.     )
  75.     (cond ((member DType (list "ARC" "LINE"))
  76.            (setq Rtn T
  77.                  RedrawData
  78.                   (XSub_GetRedrawData Data)
  79.            )
  80.           )
  81.           ((member DType (list "POLYLINE" "LWPOLYLINE"))
  82.            (command "_.Undo" "_Group");;; Prepare to explode
  83.            (command "_.Explode" Data)
  84.            (if
  85.              (member
  86.                (cdr (assoc 0 (entget (setq DataM (car (nentselp Pt))))))
  87.                (list "ARC" "LINE")
  88.              )
  89.               (setq Rtn        T
  90.                     Join T
  91.                     RedrawData
  92.                      (XSub_GetRedrawData DataM)
  93.               )
  94.               (alert (C:OAS_System_GetMessage -1031 nil))
  95.            )
  96.            (command "_.Undo" "_End")
  97.            (command "_U");;; disable this explode operation by undo it
  98.           )
  99.     )
  100.     (redraw Data 3)
  101.     (if        RedrawData
  102.       (XSub_GrDraw RedrawData 2)
  103.     )
  104.     Rtn
  105.   )

  106.   (setq        OldCmd (getvar "CmdEcho")
  107.         OldOsm (getvar "Osmode")
  108.   )
  109.   (setvar "CmdEcho" 0)
  110.   (princ (strcat "\n Current Fillet Radius: "
  111.                  (rtos (getvar "FilletRad") 2 4)
  112.          )
  113.   )
  114.   (if
  115.     (setq
  116.       Obj1 (entsel
  117.              "\n Please pick the 1st (Base) Line/ARC/Polyline <Exit>:"
  118.            )
  119.     )
  120.      (if (Sub_CheckValid Obj1)
  121.        (if (setq Obj2
  122.                   (entsel
  123.                     "\r Please pick the 2nd (Joined) Line/ARC/Polyline <Exit>:"
  124.                   )
  125.            )
  126.          (if (Sub_CheckValid Obj2)
  127.            (progn
  128.              (princ "\n")
  129.              (setq Pt1         (cadr Obj1)
  130.                    Obj1         (car Obj1)
  131.                    SType (cdr (assoc 0 (entget Obj1)))
  132.                    Pt2         (cadr Obj2)
  133.                    Obj2         (car Obj2)
  134.                    TType (cdr (assoc 0 (entget Obj2)))
  135.              )
  136.              (if (and (equal SType "ARC")
  137.                       (member TType (list "POLYLINE" "LWPOLYLINE"))
  138.                  ) ;;; force to order the source object. If only one polyline is picked
  139.                    ;;; this polyline should be the 1st object to fillet
  140.                    ;;; because the result will have same peroperties as the 1st object
  141.                (setq Rtn   Obj1
  142.                      Obj1  Obj2
  143.                      Obj2  Rtn
  144.                      Rtn   Pt1
  145.                      Pt1   Pt2
  146.                      Pt2   Rtn
  147.                      SType (cdr (assoc 0 (entget Obj1)))
  148.                      TType (cdr (assoc 0 (entget Obj2)))
  149.                )
  150.              )
  151.              (if
  152.                (member TType (list "LINE" "POLYLINE" "LWPOLYLINE" "ARC"))
  153.                 (progn
  154.                   (setq        SLayer (cdr (assoc 8 (entget Obj1)))
  155.                         SWidth (cdr (assoc 40 (entget Obj1)))
  156.                         SColor (cdr (assoc 62 (entget Obj1)))
  157.                   )
  158.                   (if (= TType "ARC")
  159.                     (setq SWidth 0.0)
  160.                   )
  161.                   (if (null SColor)
  162.                     (setq SColor "ByLayer")
  163.                   )
  164.                   (setvar "Osmode" 0)
  165.                   (command "_.Undo" "_Group")
  166.                   (command "_.Layer" "_M" "$SomZok$" "")
  167.                   (command "_.Change"               Obj1         Obj2
  168.                            ""             "_P"      "_La"         "$SomZok$"
  169.                            ""
  170.                           ) ;;; Create a temperory layer
  171.                   (if (member SType (list "POLYLINE" "LWPOLYLINE"))
  172.                     (command "_.Explode" Obj1)
  173.                   )
  174.                   (if
  175.                     (and (not (equal Obj1 Obj2))
  176.                          (member TType (list "POLYLINE" "LWPOLYLINE"))
  177.                     )
  178.                      (command "_.Explode" Obj2)
  179.                   )
  180.                   (setq        Obj1 (car (nentselp Pt1))
  181.                         Obj2 (car (nentselp Pt2))
  182.                   )
  183.                   (if (equal Obj1 Obj2)
  184.                     (progn
  185.                       (alert (strcat "\n Notice:"
  186.                                      "\n ======="
  187.                                      "\n Picked 2 objects are same object"
  188.                                      "\n can NOT run FILLET"
  189.                              )
  190.                       )
  191.                       (command "_.Undo" "_End")
  192.                       (command "_U")
  193.                     )
  194.                     (progn
  195.                       (command "_.Undo" "_Group") ;;; This is added to prevent errors on too large radius on fillet
  196.                       (command "_.Fillet"
  197.                                (osnap Pt1 "Nea")
  198.                                (osnap Pt2 "Nea")
  199.                       )
  200.                       (if (/= (getvar "CmdNames") "")
  201.                         (progn ;; error found, the radius is too large
  202.                                (command ^C)
  203.                                (command "_.Undo" "_End")
  204.                                (command "_U") ; close this level undo
  205.                                (command "_.Undo" "_End")
  206.                                (command "_U") ; close upper level undo
  207.                                (command "_.Undo" "_End")
  208.                                (command "_U") ; undo back to original
  209.                         )
  210.                         (progn ;; the radius is OK to fillet
  211.                           (if (car (nentselp Pt1))
  212.                             (if        (null Join)
  213.                               (command
  214.                                 "_.Change"
  215.                                 (ssget "x" (list (cons 8 "$SomZok$")))
  216.                                 ""
  217.                                 "_P"
  218.                                 "_La"
  219.                                 SLayer
  220.                                 "_C"
  221.                                 SColor
  222.                                 ""
  223.                               )
  224.                               (progn
  225.                                 (command
  226.                                   "_.PEdit"
  227.                                   (car (nentselp Pt1))
  228.                                   "_Y"
  229.                                   "_J"
  230.                                   (ssget "x" (list (cons 8 "$SomZok$")))
  231.                                   ""
  232.                                   "_W"
  233.                                   SWidth
  234.                                   ""
  235.                                 )
  236.                                 (command "_.Change"
  237.                                          (entlast)
  238.                                          ""
  239.                                          "_P"
  240.                                          "_La"
  241.                                          SLayer
  242.                                          "_C"
  243.                                          SColor
  244.                                          ""
  245.                                 )
  246.                               )
  247.                             )
  248.                           )
  249.                           (command "_.Undo" "_End")
  250.                         )
  251.                       )

  252.                     )
  253.                   )
  254.                 )
  255.              )
  256.            )
  257.          )
  258.        )
  259.      )
  260.   )
  261.   (if (setq SSet (ssget "x" (list (cons 8 "$SomZok$"))))
  262.     (command "_.Erase" SSet "")
  263.   )
  264.   (command "_.Layer" "_S" "0" "")
  265.   (if (tblsearch "Layer" "$SomZok$")
  266.     (command "_.Purge" "_La" "$SomZok$" "N")
  267.   ) ;;; Remove temperory layer
  268.   (redraw)
  269.   (if OldOsm
  270.     (setvar "Osmode" OldOsm)
  271.   )
  272.   (if OldCmd
  273.     (setvar "CmdEcho" OldCmd)
  274.   )
  275.   (princ)
  276. )
  277. ;;; ******************************************************************** ;;;
  278. ;;; Command to enhance AutoCAD native Chamfer command                    ;;;
  279. ;;; This application can processing Chamfer between Line-Line            ;;;
  280. ;;; Line-Polyline; Polyline-Polyline and even different line             ;;;
  281. ;;; segments of a same polyline                                          ;;;
  282. ;;; ******************************************************************** ;;;
  283. ;;; Same programming idea with MFillet                                   ;;;
  284. ;;; ******************************************************************** ;;;
  285. ;;; KozMos Public Freeware Service [2002.02]                             ;;;
  286. ;;; Programmed by Yota Masaru                                            ;;;
  287. ;;; Version: 2002.21124.1641                                             ;;;
  288. ;;; ReVersion: 2002.21127.2202 (quiet exit on too large distance)        ;;;
  289. ;;; Copyright(C) 1994-2002 by KozMos Inc.                                ;;;
  290. ;;; All rights reserved                                                  ;;;
  291. ;;; ******************************************************************** ;;;
  292. (Defun C:MChamfer (/             Sub_CheckValid         OldCmd           OldOsm
  293.                    Obj1             Obj2      Pt1         Pt2           SType
  294.                    SWidth    SLayer    SColor         TType           TColor
  295.                    TLayer    TWidth    SSet
  296.                   )
  297.   (Defun Sub_CheckValid        (Data / DataM Pt DType RedrawData Rtn)
  298.     (setq Pt        (cadr Data)
  299.           Data        (car Data)
  300.           DType        (cdr (assoc 0 (entget Data)))
  301.     )
  302.     (cond
  303.       ((= DType "LINE")
  304.        (setq Rtn T
  305.              RedrawData
  306.               (list (cdr (assoc 10 (entget Data)))
  307.                     (cdr (assoc 11 (entget Data)))
  308.               )
  309.        )
  310.       )
  311.       ((= DType "ARC")
  312.        (setq Rtn nil)
  313.        (alert (strcat "\n Picked segment on (LW)Polyline is ARC"
  314.                       "\n Chamfer ARC is NOT valid"
  315.                       "\n Press OK to quit"
  316.               )
  317.        )
  318.       )
  319.       ((member DType (list "POLYLINE" "LWPOLYLINE"))
  320.        (command "_.Undo" "_Group")
  321.        (command "_.Explode" Data)
  322.        (if (= (cdr (assoc 0 (entget (setq DataM (car (nentselp Pt)))))
  323.               )
  324.               "LINE"
  325.            )
  326.          (setq Rtn T
  327.                RedrawData
  328.                 (list (cdr (assoc 10 (entget DataM)))
  329.                       (cdr (assoc 11 (entget DataM)))
  330.                 )
  331.          )
  332.          (alert        (strcat        "\n Picked segment on (LW)Polyline is ARC"
  333.                         "\n Chamfer ARC is NOT valid"
  334.                         "\n Press OK to quit"
  335.                 )
  336.          )
  337.        )
  338.        (command "_.Undo" "_End")
  339.        (command "_U")
  340.       )
  341.     )
  342.     (redraw Data 3)
  343.     (if        RedrawData
  344.       (grdraw (nth 0 RedrawData) (nth 1 RedrawData) 2)
  345.     )
  346.     Rtn
  347.   )

  348.   (setq        OldCmd (getvar "CmdEcho")
  349.         OldOsm (getvar "Osmode")
  350.   )
  351.   (setvar "CmdEcho" 0)
  352.   (princ (strcat "\n Current Chamfer Distance is:"
  353.                  (rtos (getvar "ChamferA") 2 4)
  354.                  " and "
  355.                  (rtos (getvar "ChamferB") 2 4)
  356.          )
  357.   )
  358.   (if (setq Obj1 (entsel
  359.                    "\n Please pick the 1st (Base) Line/Polyline <Exit>:"
  360.                  )
  361.       )
  362.     (if        (Sub_CheckValid Obj1)
  363.       (if (setq        Obj2
  364.                  (entsel
  365.                    "\r Please pick the 2nd (Joined) Line/Polyline <Exit>:"
  366.                  )
  367.           )
  368.         (if (Sub_CheckValid Obj2)
  369.           (progn
  370.             (setvar "Osmode" 0)
  371.             (princ "\n")
  372.             (command "_.Layer" "_M" "$SomZok$" "")
  373.             (setq Pt1         (cadr Obj1)
  374.                   Obj1         (car Obj1)
  375.                   SType         (cdr (assoc 0 (entget Obj1)))
  376.                   SLayer (cdr (assoc 8 (entget Obj1)))
  377.                   SWidth (cdr (assoc 40 (entget Obj1)))
  378.                   SColor (cdr (assoc 62 (entget Obj1)))
  379.                   Pt2         (cadr Obj2)
  380.                   Obj2         (car Obj2)
  381.                   TType         (cdr (assoc 0 (entget Obj2)))
  382.                   TLayer (cdr (assoc 8 (entget Obj2)))
  383.                   TWidth (cdr (assoc 40 (entget Obj2)))
  384.                   TColor (cdr (assoc 62 (entget Obj2)))
  385.             )
  386.             (if        (and (= SType "LINE")
  387.                      (member TType (list "POLYLINE" "LWPOLYLINE"))
  388.                 )
  389.               (setq SLayer TLayer
  390.                     SWidth TWidth
  391.                     SColor TColor
  392.               )
  393.             )
  394.             (if        (null SColor)
  395.               (setq SColor "ByLayer")
  396.             )
  397.             (command "_.Undo" "_Group")
  398.             (command "_.Change" Obj1 Obj2 "" "_P" "_La" "$SomZok$" "")
  399.             (if        (/= SType "LINE")
  400.               (command "_.Explode" Obj1)
  401.             )
  402.             (if        (and (not (equal Obj1 Obj2))
  403.                      (/= TType "LINE")
  404.                 )
  405.               (command "_.Explode" Obj2)
  406.             )
  407.             (setq Obj1 (car (nentselp Pt1))
  408.                   Obj2 (car (nentselp Pt2))
  409.             )
  410.             (cond
  411.               ((equal Obj1 Obj2)
  412.                (alert (strcat "\n Notice:"
  413.                               "\n ======="
  414.                               "\n Picked 2 objects are same object"
  415.                               "\n can NOT run CHAMFER"
  416.                       )
  417.                )
  418.                (command "_.Undo" "_End")
  419.                (command "_U")
  420.               )
  421.               ((null (inters (cdr (assoc 10 (entget Obj1)))
  422.                              (cdr (assoc 11 (entget Obj1)))
  423.                              (cdr (assoc 10 (entget Obj2)))
  424.                              (cdr (assoc 11 (entget Obj2)))
  425.                              nil
  426.                      )
  427.                )
  428.                (alert (C:OAS_System_GetMessage -1033 nil))
  429.                (command "_.Undo" "_End")
  430.                (command "_U")
  431.               )
  432.               (t
  433.                (command "_.Undo" "_Group")
  434.                (command        "_.Chamfer"
  435.                         (osnap Pt1 "Nea")
  436.                         (osnap Pt2 "Nea")
  437.                )
  438.                (if (/= (getvar "CmdNames") "")
  439.                  (progn        ;; error found
  440.                         (command ^C)
  441.                         (command "_.Undo" "_End")
  442.                         (command "_U")        ; close this level undo
  443.                         (command "_.Undo" "_End")
  444.                         (command "_U")        ; close upper level undo
  445.                         (command "_.Undo" "_End")
  446.                         (command "_U")        ; undo back to original
  447.                  )
  448.                  (progn

  449.                    (setq SSet (ssget "x" (list (cons 8 "$SomZok$"))))
  450.                    (if (= SType TType "LINE")
  451.                      (command "_.Change"        SSet         ""
  452.                               "_P"     "_La"        SLayer         "_C"
  453.                               SColor   ""
  454.                              )
  455.                      (progn
  456.                        (command        "_.PEdit" Obj1 "_Y" "_J" SSet "" "_W"
  457.                                 SWidth "")
  458.                        (command        "_.Change"
  459.                                 (entlast)
  460.                                 ""
  461.                                 "_P"
  462.                                 "_La"
  463.                                 SLayer
  464.                                 "_C"
  465.                                 SColor
  466.                                 ""
  467.                        )
  468.                      )
  469.                    )
  470.                    (command "_.Undo" "_End")
  471.                  )
  472.                )
  473.               )
  474.             )
  475.           )
  476.         )
  477.       )
  478.     )
  479.   )
  480.   (if (setq SSet (ssget "x" (list (cons 8 "$SomZok$"))))
  481.     (command "_.Erase" SSet "")
  482.   )
  483.   (command "_.Layer" "_S" "0" "")
  484.   (if (tblsearch "Layer" "$SomZok$")
  485.     (command "_.Purge" "_La" "$SomZok$" "N")
  486.   )
  487.   (redraw)
  488.   (if OldOsm
  489.     (setvar "Osmode" OldOsm)
  490.   )
  491.   (if OldCmd
  492.     (setvar "CmdEcho" OldCmd)
  493.   )
  494.   (princ)
  495. )
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-9-26 05:18 , Processed in 0.175285 second(s), 46 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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