jiajun_16888 发表于 2010-4-30 23:45:00

可以自动改变直线,圆等的线形比例

<p>大家好&nbsp; 我这有一个非常好的LISP程序&nbsp; 可以自动改变直线,圆等的线形比例&nbsp;&nbsp; 但不能改变矩形及多段线的的&nbsp;&nbsp; 哪位大大修改一下</p><p>&nbsp;</p><p>(defun c:df ()&nbsp;&nbsp;&nbsp;&nbsp;;自動變換成適當比例的虛線<br/>&nbsp; (ltchange "dashed"&nbsp; 3 "bylayer")<br/>&nbsp; (princ)<br/>)</p><p>(defun ltchange&nbsp;(type1 scale color /&nbsp; oce&nbsp;&nbsp; lin&nbsp;&nbsp; n&nbsp;&nbsp;&nbsp; nam&nbsp; tab<br/>&nbsp;&nbsp; pt1&nbsp;&nbsp; pt2&nbsp;&nbsp; x1&nbsp;&nbsp;&nbsp; x2&nbsp; y1&nbsp;&nbsp;&nbsp; y2&nbsp;&nbsp;&nbsp; len&nbsp;&nbsp; leg&nbsp; sca<br/>&nbsp;&nbsp; otyp&nbsp; ocol&nbsp; osca&nbsp; col&nbsp; typ&nbsp;&nbsp; lts&nbsp;&nbsp; rad<br/>&nbsp;&nbsp;)&nbsp;&nbsp;&nbsp;;自動變換成適當比例的中心線<br/>&nbsp; (setq&nbsp;oce (getvar "cmdecho")<br/>&nbsp;lts (getvar "ltscale")<br/>&nbsp; ) ;_ end of setq<br/>&nbsp; (setvar "cmdecho" 0)<br/>&nbsp; (setq n 0)<br/>&nbsp; (print<br/>&nbsp;&nbsp;&nbsp; (strcat "Select object change to " type1 ":")<br/>&nbsp; ) ;_ end of print<br/>&nbsp; (setq&nbsp;lin (ssget '((-4 . "&lt;OR")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (0 . "LINE")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (0 . "CIRCLE")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (0 . "ELLIPSE")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (0 . "ARC")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (0 . "polyline")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (-4 . "OR&gt;")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br/>&nbsp;&nbsp;&nbsp;&nbsp; ) ;_ end of ssget<br/>&nbsp; )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;end setq<br/>&nbsp; (if (not lin)<br/>&nbsp;&nbsp;&nbsp; (progn</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (alert "\nNo selection!")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (exit)<br/>&nbsp;&nbsp;&nbsp; ) ;_ end of progn<br/>&nbsp; )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;end if<br/>&nbsp; (repeat (sslength lin)<br/>&nbsp;&nbsp;&nbsp; (setq nam (ssname lin n))<br/>&nbsp;&nbsp;&nbsp; (setq tab (entget nam))<br/>;;;;;;;;;;circle<br/>&nbsp;&nbsp;&nbsp; (if&nbsp;(= (cdr (assoc 0 tab)) "CIRCLE")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (progn<br/>&nbsp;(setq rad (cdr (assoc 40 tab)))<br/>&nbsp;(setq len (* 2 (* 3.14 rad)))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;如是圓實體取周長為"len"<br/>;;;;;;;;;;ARC<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (if (= (cdr (assoc 0 tab)) "ARC")<br/>&nbsp;(progn<br/>&nbsp;&nbsp; (setq rad (cdr (assoc 40 tab)))<br/>&nbsp;&nbsp; (setq len (* 3.14 rad))<br/>&nbsp;)&nbsp;&nbsp;&nbsp;&nbsp;;end progn;如是圓弧取其圓周長半 </p><p>;;;;;;;;;;ellipse<br/>&nbsp;&nbsp;&nbsp; (if&nbsp;(= (cdr (assoc 0 tab)) "ellipse")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (progn<br/>&nbsp;(setq rad (cdr (assoc 40 tab)))<br/>&nbsp;(setq len (* 2 (* 3.14 rad)))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br/>;;;;;;;;;LINE<br/>&nbsp;(progn<br/>&nbsp;&nbsp; (setq&nbsp;pt1 (cdr (assoc 10 tab))<br/>&nbsp;&nbsp;pt2 (cdr (assoc 11 tab))<br/>&nbsp;&nbsp;len (distance pt1 pt2)<br/>&nbsp;&nbsp; )&nbsp;&nbsp;&nbsp;&nbsp;;end setq<br/>&nbsp;)&nbsp;&nbsp;&nbsp;&nbsp;;end progn<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;end if&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp; )<br/>&nbsp;&nbsp; );end if</p><p>&nbsp;&nbsp;&nbsp; (cond ((and (&gt; len 0) (&lt;= len 2))<br/>&nbsp;&nbsp;&nbsp; (setq leg 2)<br/>&nbsp;&nbsp; )<br/>&nbsp;&nbsp; ((and (&gt; len 2) (&lt;= len 5))<br/>&nbsp;&nbsp;&nbsp; (setq leg 6)<br/>&nbsp;&nbsp; )<br/>&nbsp;&nbsp; ((and (&gt; len 5) (&lt;= len 30))<br/>&nbsp;&nbsp;&nbsp; (setq leg 20)<br/>&nbsp;&nbsp; )<br/>&nbsp;&nbsp; ((and (&gt; len 30) (&lt;= len 50))<br/>&nbsp;&nbsp;&nbsp; (setq leg 40)<br/>&nbsp;&nbsp; )<br/>&nbsp;&nbsp; ((and (&gt; len 50) (&lt;= len 100))<br/>&nbsp;&nbsp;&nbsp; (setq leg 75)<br/>&nbsp;&nbsp; )<br/>&nbsp;&nbsp; ((&gt; len 100)<br/>&nbsp;&nbsp;&nbsp; (setq leg 100)<br/>&nbsp;&nbsp; )<br/>&nbsp;&nbsp;&nbsp; )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;end cond<br/>&nbsp;&nbsp;&nbsp; (setq sca (/ leg scale lts 2))</p><p>&nbsp;&nbsp;&nbsp; (command "-linetype" "l" type1 "acad.lin" "" "")<br/>&nbsp;&nbsp;&nbsp; (command "change" nam "" "p" "c" color "lt"&nbsp;type1 "s" SCA "") ;_ end of command<br/>&nbsp;;_ end of command<br/>&nbsp;;_ end of command<br/>&nbsp;&nbsp;&nbsp; (setq n (+ n 1))<br/>&nbsp; )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;;end repeat<br/>&nbsp; (setvar "cmdecho" oce)<br/>&nbsp; (princ)<br/>) ;_ end of defun<br/></p>

wide 发表于 2018-11-19 11:24:52

不错的代码。

xyz2009xyz 发表于 2010-7-26 08:24:00

怎样自动改变直线,圆等的线形比例?比如说我把图比例放大它也能自动调整线性比例?

Gu_xl 发表于 2010-7-26 11:29:00



(defun c:tt (/ scale ss n k obj)
(setq scale (getreal "\n输入线型转换比例"))
(if (not scale) (exit))
(princ"\n选择要转换线型比例的实体:")
(setq ss (ssget))
(if ss
    (progn
      (setq n (sslength ss)
   k 0)
      (repeat n
      (setq obj (vlax-ename->vla-object (ssname ss k)))
      (setq newscale (* scale (vla-get-LinetypeScale obj)))
      (vla-put-linetype obj "dashed")
      (vla-put-LinetypeScale obj newscale)
      (setq k (1+ k))
      )
      )
    )
)

jfxia 发表于 2011-1-5 23:26:39

            Gu_xl的程序如能自动根据实体的长度来判断比例就好了

xiaxiang 发表于 2011-1-6 15:51:12

xyz2009xyz 发表于 2010-7-26 08:24 static/image/common/back.gif
怎样自动改变直线,圆等的线形比例?比如说我把图比例放大它也能自动调整线性比例?

这个好像不好实现

zhouwanweihf 发表于 2011-12-18 11:01:00

请帮忙顶起

功夫佬 发表于 2012-1-15 22:00:08

有没有像燕秀自动线型比例的代码

jianlin521 发表于 2012-6-17 22:50:26

有没有改标注比例的?可以根据所框选的范围,设定标注的与框选范围的比例?

sageman 发表于 2013-3-21 08:28:23

能达到自动设置比例,适合让肉眼看到的比例吗?

bai2000 发表于 2013-4-10 11:34:37

顶起来,好像SMARTOOLS中有个自动线型比例挺好用的的,他是按屏幕的尺寸确定比例的,可惜没源码
页: [1] 2
查看完整版本: 可以自动改变直线,圆等的线形比例