大佬帮我改个做匿名块的程序程序
帮我把插入点改成自动获取选择集的中线作为插入点;做匿名块的程序
(defun Nblock (ss insertpt / InstPt blocks blk i Objs)
(setq InstPt (vlax-3d-point insertpt)) ;转化为ActiveX的点
(setq blocks (vla-get-blocks *DOC))
(setq blkobj (vla-add blocks InstPt "*U")) ;定义匿名图块
(setq i -1)
(repeat (sslength ss)
(setq objs (cons (vlax-ename->vla-object (ssname ss (setq i(1+ i)))) objs))
) ;把选择集的物体加入到匿名图块
(vlax-invoke *DOC 'copyobjects objs blkobj) ;采用 copyobjects方式插入图块
(mapcar 'vla-delete objs) ;删除选择集
(vla-insertblock *MSP InstPt (vla-get-name blkobj) 1 1 1 0)
blkobj
)
;;测试程序
(defun C:tt()
(vl-load-com)
(setq *OBJ (vlax-get-acad-object)
*DOC (vla-get-activeDocument *OBJ)
*MSP (vla-get-Modelspace *DOC)
)
(if (setq ss (ssget)) ;取得选择集
(if (setq insertpt (getpoint "\n请输入插入点: "));取得插入点
(nblock ss insertpt) ;做匿名图块
)
)
)
已经解决谢谢大佬
页:
[1]