- 积分
- 14013
- 明经币
- 个
- 注册时间
- 2013-9-7
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 荒野孤行 于 2015-6-14 10:29 编辑
程序源码是根据论坛的源码改的,论坛的写的太散乱了,以下源码直接下载就可以用。已重新根据坛友的代码进行了修改。
;;;*****交点插块 程序开始*****
(defun c:t1 ()
(setvar "cmdecho" 0)
(vl-load-com)
(setvar "osmode" 15359)
(princ
"\n★功能:在批量图元的相交点处插入块。\n提示:在执行此功能前请确定图块的基点是否在其中心位置,否则会出现插入点偏位现象。\n"
)
(princ "\n请选择多段线、样条曲线、直线、圆、圆弧或椭圆:")
(command "undo" "be")
(if (not (setq ss (ssget '((0 . "*LINE,ARC,CIRCLE,ELLIPSE")))))
(progn (princ "\n提示:未选取图元,程序退出。\n") (exit))
)
(setq acad (vlax-get-acad-object))
(setq acaddocument (vla-get-activedocument acad))
(setq mspace (vla-get-modelspace acaddocument))
(while
(progn (setq blockent (entsel "\n请选择要插入交点的图块:")
blockentname (car blockent)
)
(not (if (= blockent nil)
nil
(= (cdr (assoc 0 (entget blockentname))) "INSERT")
)
)
)
(princ
"\n提示:选取的不是图块或未选取任何图元,请重新选取:"
)
)
(setq blockname (cdr (assoc 2 (entget blockentname))))
(initget 6)
(if (not (setq bili (getreal "\n插入比例<1.0>")))
(setq bili 1.0)
)
(setvar "osmode" 0)
(setq ptlist (ssinters ss))
(foreach pt ptlist
(vla-insertblock
mspace
(vlax-3d-point pt)
blockname
bili
bili
bili
0
)
)
(command "undo" "e")
(setvar "osmode" 15359)
(princ)
)
(defun ssinters (ss / i num obj1 obj2 j interpts ptlist)
(setq i 0
num (sslength ss)
)
(while (< i (1- num))
(setq obj1 (ssname ss i)
obj1 (vlax-ename->vla-object obj1)
j (1+ i)
)
(while (< j num)
(setq obj2 (ssname ss j)
obj2 (vlax-ename->vla-object obj2)
interpts (vla-intersectwith
obj1
obj2
0
)
interpts (vlax-variant-value interpts)
)
(if (> (vlax-safearray-get-u-bound interpts 1) 0)
(progn
(setq interpts
(vlax-safearray->list interpts)
)
(while (> (length interpts) 0)
(setq ptlist (cons (list (car interpts)
(cadr interpts)
(caddr interpts)
)
ptlist
)
)
(setq interpts (cdddr interpts))
)
)
)
(setq j (1+ j))
)
(setq i (1+ i))
)
ptlist
)
;;;*****交点插块 程序结束*****
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
评分
-
查看全部评分
|