修消茄改图元为当前图层:
CAD *** 作方法
autolisp程序内容(注意是英文打字):
修改图元为当前图层,命令为:【XG】
(defun C:XG ( / &k1 &kw1 &ob1 &ss1 &tc1)
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(if (null vlax-dump-object) (vl-load-com) )
(setq &tc1 (getvar "clayer"))
(if (setq &kw1 (ssget))
(progn
(while (setq &k1 (ssname &kw1 0))
(setq &银念kw1 (ssdel &k1 &kw1))
(setq &ob1 (vlax-ename->vla-object &k1))
拿搏察 (vla-put-layer &ob1 &tc1)
)while
)
)
(princ)
)
AutoCAD绘制展开线的话,用程序绘制比较简单,程序如下:
(defun C:tes ( / &dis1 &k1 &kw1 ang1 obj pt1 pt2 tc1)(vl-load-com)加载vlax
(princ "\n请选择要绘制展开线的圆")
(if (setq &kw1 (ssget 薯卖'((0 . "CIRCLE"))))
(progn
(while (setq &k1 (ssname &kw1 0))
(setq &kw1 (ssdel &k1 &kw1))
(setq obj (vlax-ename->vla-object &k1))变枣手答为vlax对象
(setq &dis1 (vlax-curve-getDistAtParam obj (vlax-curve-getEndParam obj)))取得长度
(setq pt2 (Vlax-SafeArray->List (Vlax-Variant-Value (vla-get-Center obj))))取得圆心点
(setq tc1 (vla-get-layer obj))取得圆的图层
(setq #r1 (vla-get-Radius obj))取得圆的半径
凳慧 (setq pt1 (polar pt2 (* pi 1.5) #r1))取得圆最低点
(setq pt2 (polar pt1 0 &dis1))展开线另一点
(entmake (list '(0 . "LINE") (cons 8 tc1) (cons 10 pt1) (cons 11 pt2)))绘制展开线
)while
)
)
(prin1)
)
复制到记事本,以【.lsp】为后缀命名,打开CAD,autolisp加载,命令【TES】
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)