求解!!!!!!
以下程序可以运行,但是结果却不是我想要的4号(青色)颜色,求坛友们指点迷津![*](defun c:test()
[*](prompt"\n===您即将检测单个图元是否超宽 ……")
[*](setvar "dimzin" 0)
[*](prompt "\n<<框选图元:>>")
[*](if (setq ss (ssget '((0 . "LWPOLYLINE"))))
[*](progn
[*](repeat (setq i (sslength ss))
[*] (setq i (1- i))
[*] (setq ent (ssname ss i))
[*] (setq dxf (entget ent))
[*] (setq ptb (mapcar 'cdr (vl-remove-if '(lambda(a)(/= (car a) 10)) dxf))) ;生成坐标值表
[*] (setq ptb (vl-sort ptb '(lambda(a b)
[*] (< (cadr a) (cadr b)))))
[*] (setq miny (cadr (car ptb)))
[*] (setq ptb (vl-sort ptb '(lambda(a b)
[*] (> (cadr a) (cadr b)))))
[*] (setq maxy (cadr (car ptb)))
[*] (setq widthy (abs(- maxy miny)))
[*] (print widthy)
[*] (if (> widthy 1000)
[*](progn
[*] (setq dxf(subst(cons 8 "0") (assoc 8 dxf) dxf))
[*] (setq dxf(subst(cons 62 4) (assoc 62 dxf) dxf)) ;;;;;;;;运行结果为啥不是4号颜色???
[*] (setq dxf(subst(cons 6 "ByLayer") (assoc 6 dxf) dxf))
[*] (setq dxf(subst(cons 370 1) (assoc 370 dxf) dxf))
[*] (entmod dxf)
[*] )
[*] (progn
[*] (setq dxf(subst(cons 8 "CUTME") (assoc 8 dxf) dxf))
[*] (setq dxf(subst(cons 62 256) (assoc 62 dxf) dxf))
[*] (setq dxf(subst(cons 6 "ByLayer") (assoc 6 dxf) dxf))
[*] (setq dxf(subst(cons 370 1) (assoc 370 dxf) dxf))
[*] (entmod dxf)
[*] )
[*] )
[*] )
[*] )
[*] )
[*]
[*] (princ))
应该是颜色随层,那就没有62码了 start4444 发表于 2023-7-8 22:39
应该是颜色随层,那就没有62码了
哦,明白了,谢谢! 学到了,感谢分享 (defun c:tt ()
(defun p1p9 (s1 / p1 p9)
(vla-getboundingbox (vlax-ename->vla-object s1) 'p1 'p9)
(list (vlax-safearray->list p1) (vlax-safearray->list p9))
)
(princ "\n检测单个图元是否超宽…… ")
(princ "\n框选图元: ")
(setq i -1)
(if (setq ss (ssget '((0 . "*POLY*"))))
(while (setq s1 (ssname ss (setq i (1+ i))))
(setq ob (vlax-ename->vla-object s1))
(setq a (p1p9 s1))
(if (> (abs (- (cadar a) (cadadr a))) 1000)
(progn (vla-put-layer ob "0") (vla-put-color ob 4))
(progn (vla-put-layer ob "CUTME") (vla-put-color ob 256))
)
)
)
(princ)
) xyp1964 发表于 2023-7-9 09:18
你这个程序就有点高深了,一时半会消化不了,但是有个问题想请教一下:我用(command "layer" "n" "CUTME" "c" "1" "CUTME" "") 建立的CUTME图层,也设置了颜色是1号颜色,为什么结果却是BYLayer呢?这样的话就没有62码了,请赐教。
页:
[1]