阻止对象插入点?
我试图修改李·麦克几周前为我写的LISP,我用它在与现有块相同的插入点插入一个块。Lee的代码使用excell电子表格作为输入,用于在图形中查找块列表。由于代码已经找到了每个块,我认为它应该也能够插入新块。我就是不知道如何在不让用户点击的情况下编码插入点。(defun c:BLOCKINSERT (/ file nl lst Minp Maxp pts elst ipt)
(vl-load-com)
(if (setq file
(getfiled "Select Text File"
(if *load
*load
""
)
"txt"
8
)
)
(progn
(setq *load file
file(open file "r")
)
(while (setq nl (read-line file))
;(princ nl)
(setq lst (cons (car (StrBrk nl 9)) lst))
)
(close file)
(princ "\n<< Closed file >>")
(if (setq elst (vl-remove-if
'null
(mapcar 'handent
(mapcar
(function
(lambda (x)
(substr x 2)
)
)
(reverse lst)
)
)
)
)
(foreach Obj (mapcar 'vlax-ename->vla-object elst)
(vla-getBoundingBox Obj 'Minp 'Maxp)
(setq pts (mapcar 'vlax-safearray->list (list Minp Maxp)))
(vla-ZoomCenter
(vlax-get-acad-object)
(vlax-3D-point
(polar (car pts)
(apply 'angle pts)
(/ (apply 'distance pts) 2.)
)
)
400.
)
(setq ipt (assoc 10 entget (Obj)))
(command "-insert" "KEY_MG_RED" ipt 1 1 0)
)
)
)
(princ "\n<< No File Selected >>")
)
(princ)
)
(defun StrBrk (str chrc / pos lst)
(while (setq pos (vl-string-position chrc str))
(setq lst (cons (substr str 1 pos) lst)
str (substr str (+ pos 2))
)
)
(reverse (cons str lst))
)
有人能给我指出正确的方向吗?
格伦
上述代码应为
(setq ipt (cdr(assoc 10 (entget (Obj)))))
(command "-insert" "KEY_MG_RED" ipt 1 1 0)
如果Obj实体没有来自选择集,则该行将为
(setq ipt (cdr(assoc 10 (entget(car (Obj))))))
(command "-insert" "KEY_MG_RED" ipt 1 1 0)
希望有帮助 使用这两个中的第一个,我得到了错误:
命令:;错误:功能错误:#
使用第二个,我得到:
命令:;错误:功能错误:#
我不认为obj实体来自选择集,尽管我不完全确定。
谢谢
格伦 Obj是通过foreach函数表示为符号的VLA对象。
即
(foreach Obj ...
我希望不是!。。。我将其编码为txt文件。。 哎呀,真的,我只是用Excel修改了txt文件,以至于我忘了它们是不一样的。
我知道你过去曾发布过解释VLA函数的来源,但我的搜索一直徒劳。请转寄好吗?我还读到,你有一个LISP常见问题解答,它是“即将推出”是可用的吗?
谢谢
格伦 显然,有几个站点可以解释VL功能,下面是几个站点:
http://www.afralisp.net/
VL方法差异
VL中的属性
图纸空间/模型空间对象
至于LISP常见问题解答,在向公众开放之前需要得到其他成员的批准,而这一批准似乎需要一些时间。
李
页:
[1]