明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2109|回复: 1

[原创]更改线的宽度.欢迎指点

[复制链接]
发表于 2003-8-31 14:57:00 | 显示全部楼层 |阅读模式
;;;更改线的宽度
;;;本程序只线.多义线.圆.圆弧适用
;;;2003.08.08 by Mr.zhong
(defun c:ono(/ ss pw entyp rr cen)
    (setvar "cmdecho" 0)
    (setq ss (entsel "\n选择线/多义线/圆/圆弧:"))
    (while (= ss nil)
    (setq ss (entsel "\n选择线/多义线/圆/圆弧:"))
    )
    (setq pw (getdist "\n点选或输入宽度<0>:"))
    (if (= pw nil) (setq pw 0))
    (setq entyp (cdr (assoc 0 (entget (car ss)))))
    (cond ((= entyp "LINE") (command "pedit" ss "y" "w" pw ""))
          ((= entyp "ARC")  (command "pedit" ss "y" "w" pw ""))
          ((= entyp "LWPOLYLINE") (command "pedit" ss "w" pw ""))
          ((= entyp "CIRCLE")
          (setq rr  (cdr (assoc 40 (entget (car ss)))))
          (while (> pw rr)
                 (prompt "\n你的宽度大于圆或圆弧的半径,重新输入...")
                 (setq pw (getdist "\n点选或输入宽度<0>:"))
          )
          (setq cen (trans (cdr (assoc 10 (entget (car ss)))) 0 1))
          (command "donut" (* 2 (- rr (/ pw 2))) (* 2 (+ rr (/ pw 2))) cen "")
          (command "erase" ss "")
          )
    )
    (while (/= ss nil)
           (setq ss (entsel "\n选择线/多义线/圆/圆弧:"))
           (while (= ss nil)
           (setq ss (entsel "\n选择线/多义线/圆/圆弧:"))
           )
           (setq entyp (cdr (assoc 0 (entget (car ss)))))
           (cond ((= entyp "LINE") (command "pedit" ss "y" "w" pw ""))
                 ((= entyp "ARC")  (command "pedit" ss "y" "w" pw ""))
                 ((= entyp "LWPOLYLINE") (command "pedit" ss "w" pw ""))
                 ((= entyp "CIRCLE")
                  (setq rr  (cdr (assoc 40 (entget (car ss)))))
                  (while (> pw rr)
                         (prompt "\n你的宽度大于圆或圆弧的半径,重新输入...")
                         (setq pw (getdist "\n点选或输入宽度<0>:"))
                  )
                  (setq cen (trans (cdr (assoc 10 (entget (car ss)))) 0 1))
                  (command "donut" (* 2 (- rr (/ pw 2))) (* 2 (+ rr (/ pw 2))) c
en "")
                  (command "erase" ss "")
                 )
            )
    )
    (princ)
)


本程序循环的这一段和退出写的不太好,要强行退出.
大家如有需要可和我E_MAIL联系.ZYS@ROSSMAX.COM.TW
望大家多多指点.谢谢.
发表于 2003-8-31 16:38:00 | 显示全部楼层
不是很实用,2000以后版本中可以直接修改宽度,也可以根据层的设定等来确定宽度。虽然这些宽度不能是任意值,但应该能满足平常使用要求了。

单从程序上说,不算很完整,比如修改圆你是用DONUT代替圆,这样在画圆环会造成选中心点位置捕捉错误,须加(setvar "osmode" 0),结束后恢复。
你的退出处理是你的程序设计思路的问题,你想不停地选择修改,并且如未选中继续循环选择,但你又想选不中时退出,这两者矛盾。可以参考一些命令的设计思路来设计程序的退出
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-10-2 18:20 , Processed in 0.171604 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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