明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2011|回复: 4

[求助]下面程序选择时不能选到矩形,请版主帮忙改改

[复制链接]
发表于 2010-5-19 18:56:00 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2010-5-19 23:46:21 编辑

  ((> 2 len 0) (setq leg 2))
    ((> 5 len 2) (setq leg 6))
    ((> 30 len 5) (setq leg 20))
    ((> 50 len 30) (setq leg 40))
    ((> 100 len 50) (setq leg 75))
    ((> len 100) (setq leg 100))

下面程序选择时不能选到矩形,请版主帮忙改改

我想把上面的线形比例功能添加到下面程序中  谢谢

(defun c:cs (/  oce lin n nam tab pt1 pt2 x1 x2 y1 y2 len sca otyp
       osca col typ col)  ;auto change linescale(dashed and center)
 
  (setvar "cmdecho" 0)
    (if (not (setq lin (ssget "_i" '(
       (-4 . "<AND")
       (-4 . "<OR")
       (6 . "DASHED")
       (6 . "CENTER")
       (6 . "HID")
       (6 . "HIDDEN")
       (-4 . "OR>")
       (-4 . "<OR")
       (0 . "LINE")
       (0 . "CIRCLE")
       (0 . "ARC")
       (-4 . "OR>")
       (-4 . "AND>")
      ))))
    (progn
      (princ "\nPlease Select dashed or center: ")
      (setq lin (ssget '(
       (-4 . "<AND")
       (-4 . "<OR")
       (6 . "DASHED")
       (6 . "CENTER")
       (6 . "HID")
       (6 . "HIDDEN")
       (-4 . "OR>")
       (-4 . "<OR")
       (0 . "LINE")
       (0 . "CIRCLE")
       (0 . "ARC")
       (-4 . "OR>")
       (-4 . "AND>")
      )))
    );end progn
  );end if
  (setq oce (getvar "cmdecho")
 lts (getvar "ltscale")
         n 0
 );end setq
  (if lin
  (repeat (sslength lin)
    (setq nam (ssname lin n)
   tab (entget nam)
   typ (cdr (assoc 6 tab))
   otyp (cdr (assoc 0 tab))
    )

    (if (= otyp "CIRCLE")
 (setq rad (cdr (assoc 40 tab))
       len (* 2 (* 3.14 rad))
  );END setq
           ;如是圓實體取周長為"len"
      (if (= otyp "ARC")
   (setq rad (cdr (assoc 40 tab))
         len (* 3.14 rad)
   );end setq
     ;如是圓弧取其圓周長一半 
 (progn
   (setq pt1 (assoc 10 tab)
  pt2 (assoc 11 tab)
  x1  (cadr pt1)
  y1  (caddr pt1)
  x2  (cadr pt2)
  y2  (caddr pt2)
   )
   (setq len
   (sqrt (+ (* (- x1 x2) (- x1 x2)) (* (- y1 y2) (- y1 y2)))
   );end sqrt
   );end setq
 );end progn  ;如是直線由x,y坐標求長度
      );end if
    );end if
  (cond
    ((= typ "DASHED")
     (setq sca (/ len 3 lts)
    col "bylayer"
     )
    )
    ((= typ "CENTER")
     (setq sca (/ len 5 lts)
    col "magenta"
     )
    )
    ((= typ "HID")
     (setq sca (/ len 5 lts)
    col "bylayer"
     )
    )
    ((= typ "HIDDEN")
     (setq sca (/ len 14 lts)
    col "bylayer"
     )
    )
  );end cond
    (command "change" nam "" "p" "s" sca "c" col "")
    (setq n (+ n 1))
  );end repeat
    (alert "\nNo Selection!")
    );end if

  (setvar "cmdecho" oce)
  (princ)
)

 楼主| 发表于 2010-5-19 20:31:00 | 显示全部楼层
本帖最后由 作者 于 2010-5-19 23:16:48 编辑

下面是你以前给我写过的一个程序

(defun ltchange (type1 scale color / oce lts lin n nam len leg sca) ;自動變換成適當比例的中心線
 (setq oce (getvar "cmdecho")
       lts (getvar "ltscale"))
 (setvar "cmdecho" 0)
 (setq n 0)
 (princ (strcat "\\nSelect object change to " type1 ":"))
 (if (setq lin (ssget '((0 . "ARC,CIRCLE,*LINE,ELLIPSE")))) (progn
  (repeat (sslength lin)
   (setq nam (ssname lin n))
   (command "lengthen" nam "")
   (setq LEN (getvar "perimeter"))
   (cond
    ((> 2 len 0) (setq leg 2))
    ((> 5 len 2) (setq leg 6))
    ((> 30 len 5) (setq leg 20))
    ((> 50 len 30) (setq leg 40))
    ((> 100 len 50) (setq leg 75))
    ((> len 100) (setq leg 100))
   );end cond
   (setq sca (/ leg scale lts 2))
   (command "-linetype" "l" type1 "acad.lin" "" "")
   (command "change" nam "" "p" "c" color "lt" type1 "s" SCA "") ;_ end of command
   (setq n (1+ n))
  );end repeat
 ));end if
 (setvar "cmdecho" oce)
 (princ)
);_ end of defun

发表于 2010-5-20 19:11:00 | 显示全部楼层

不知道这样行不:(另:我不是本版版主)

游客,本帖隐藏的内容需要发帖数高于 5 才可浏览,你当前发帖数只有 0

 楼主| 发表于 2010-5-20 22:44:00 | 显示全部楼层

谢谢 我在你的基础上改了一下 好了 

(setq sca (/ leg scale lts 2))  我想问一下这句后面的2代表什么意思

发表于 2010-5-21 16:10:00 | 显示全部楼层
就是sca等于leg除以scale除以lts除以2
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-2-27 20:13 , Processed in 0.206289 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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