我正在尝试创建一个lisp来交叉选择多个块,并通过单击鼠标逐个更改它们的Y平面值,从选中的最上面的块开始,然后移动第二个最上面的,等等,直到所有块都按所需的间距堆叠(每个间距都可能不同,因此指定一个设置的堆叠空间是行不通的)。
这就是我所处的位置,我花了几个小时创建自己的代码,还将不同的代码混合在一起,但我甚至无法移动1。
- (defun c:test (/ blks blk )
- (if (and (setq blks (ssget ":L" '((0 . "INSERT")))));create block list from selected blocks
-
- (repeat (setq x (sslength blks));returns the number of blocks selected as an integer
- (foreach blk (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex blks))));Not my forte, probably where I'm messing up the rest
- (setq p (getpoint "\Pick Y alignment point: "));get a point, only need y value
- ;here is where no matter what I add, I can't get anything to move. probably my list formation above is wrong
- )
- )
- )
我尝试添加和修改代码,我相信我是从LeeMac那里得到的。
您可以选择一组块,它会根据X、Y或Z将它们对齐,但一次全部对齐。很有用,它是我今天最常用的Lisp例程之一。但它不适用于这种新情况,因为我只需要基于Y平面进行堆栈(或更改当前堆栈的间距)。
- (defun c:XYZ (/ a i k p s)
- (or (setq k (getenv "AlignBlocks")) (setq k "X"))
- (if (and (not (initget "X Y Z"))
- (setq k (cond ((getkword (strcat "\nAlignment [X/Y/Z] <" k ">: ")))
- (k)
- )
- )
- (setq p (getpoint "\Pick an alignment point: "))
- (setq s (ssget '((0 . "insert"))))
- )
- (progn
- (setenv "AlignBlocks" k)
- (setq i (vl-position k '("X" "Y" "Z")))
- (setq a (nth i p))
- (foreach b (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))
- (vlax-invoke b 'move (setq p (vlax-get b 'insertionpoint)) (subst a (nth i p) p))
- )
- )
- )
- (princ)
- )
- (vl-load-com)
|