拉伸矩形(或编辑
这似乎是一个简单的程序,但我在网上找不到任何对我有帮助的东西。我想选择一个矩形,从中点将其宽度从10更改为40。长度将保持不变。我希望这是一个点击的东西。
最好的方法是让我的LISP同时选择两条边,每条边拉伸15mm?或者我应该更改4个顶点的Y坐标吗?
不管怎样,您将如何保存角点位置的变量? 您可以选择一条矩形样条线,将拾取点与cnr点进行比较,然后提供一个+-值,并修改两个角点以适合此情况,这将是一个1拾取解决方案。无代码。 在以下链接中查找所有附件。。。
http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/select-rectangles-to-change-their-lenths-and-widths-at-once/td-p/5478058/page/2
HTH,M.R。 不幸的是,我在工作中使用AutoCAD 2002,我认为我没有您指定的选项,比格尔。
因此,该链接中的reccedit文件似乎可以满足我的需要,但程序经常崩溃。当我在第一个提示下选择时,我得到一个错误,即没有函数定义。当我选择Single时,我会收到另一个提示,提示我选择编辑。所有3个选项都给了我相同的错误,即没有函数定义,程序结束。所以我不能真正微调这个程序,因为我是一个初学者,不理解大部分代码,也看不到最终的结果来尝试自己破译代码。
我想要创建的程序也不需要所有这些提示。我只想选择矩形并告诉它“顶点1(Y)=顶点1(Y)+15”,“顶点2(Y)=顶点2(Y)+15”,等等。
将宽度从10更改为40的任务每个项目至少要完成1000次,因此这是我必须解决的项目类型。 所以我找到了一个非常接近我需要的程序。我只需要做一个修改,就可以让它实现我想要的。。。。。。。。现在程序将所有“Y”顶点增加15。如何使程序在负方向15上移动顶点1和2,在正方向15上移动顶点3和4?
(defun Test (e ed / i vt)
(setq i 0)
(repeat (length ed)
(if (= (car (nth i ed)) 10) ;if item is a vertex
(progn
(setq vt (cdr (nth i ed))) ; get vertex values
(setq X (car vt)) ; get the x value
(setq Y (cadr vt)) ; get the y value
(setq Y (+ 15 Y)) ; increment the Y value by 15 units
; replace the old y value with the new y value
(setq vt (subst Y (nth 1 vt) vt))
; update the entity definition with new vertex information
(setq ed (subst (cons 10 vt) (nth i ed) ed))
(entmod ed) ; update the drawing
) ;progn
) ;if
(setq i (1+ i))
) ;repeat
) ;Test
(defun C:MyTest (/ e ed)
(setq e (car (entsel))
ed (entget e)
)
(if (= (cdr (assoc 0 ed)) "LWPOLYLINE")
(test e ed)
) ;if
) ;C:MyTest 这就存在了一个问题,即垂直度是第一位的,取决于矩形的绘制方式,即4条线,但不能保证左下角始终是第一位的。
我会使用这个(car(nth I ed))10),但如下所示,然后只添加或减去每个cnr,更新或删除rectang和redraw。
(setq pt1 (car (nth 0 ed)) 10))
(setq pt2(car (nth 1 ed)) 10))
(setq pt3 (car (nth 2 ed)) 10))
(setq pt4 (car (nth 3 ed)) 10))
我的矩形每次都将以相同的方式绘制,因为它将来自之前制作的LISP。
因此,我想我可以将这些值绑定到我的“I”变量,但我的条件语句每次都输出“Nothing”。为什么程序没有认识到“i”的价值?
(defun Test (e ed / i vt)
(setq i 0)
(repeat (length ed)
(if (= (car (nth i ed)) 10) ;if item is a vertex
(progn
(setq vt (cdr (nth i ed))) ; get vertex values
(setq X (car vt)) ; get the x value
(setq Y (cadr vt)) ; get the y value
(cond
((or (= i 0) (= i 1));or
(setq Y (+ 15 Y)) ; increse the Y value by 15 units
(setq vt (subst Y (nth 1 vt) vt)); replace the old y value with the new y value
(setq ed (subst (cons 10 vt) (nth i ed) ed)); update the entity definition with new vertex information
);cond1
((or (= i 2) (= i 3));or
(setq Y (- 15 Y)) ; decrease the Y value by 15 units
(setq vt (subst Y (nth 1 vt) vt)); replace the old y value with the new y value
(setq ed (subst (cons 10 vt) (nth i ed) ed)); update the entity definition with new vertex information
);cond2
(t (princ "\nNothing"))
);cond
(entmod ed) ; update the drawing
) ;progn
) ;if
(setq i (1+ i))
) ;repeat
) ;Test
(defun C:MyTest (/ e ed)
(setq e (car (entsel))
ed (entget e)
)
(if (= (cdr (assoc 0 ed)) "LWPOLYLINE")
(test e ed)
) ;if
) ;C:MyTest 好的,我终于想出了办法。我必须添加一个额外的计数器,只有当“I”值通过顶点测试时,它才会添加到“j”。我已经在下面发布了解决方案。
现在我到达了另一个停止点。这个Lisp程序是我的过程的“第2部分”,现在看来我必须返回并修改“第1部分”。垂直绘制的任何矩形(宽度:10/高度:100)的顶点方向与水平绘制的任何矩形(宽度:100/高度:10)的顶点方向相反。我通常是Vectorworks的用户,这给了我一个讨厌AutoCAD的理由!!我知道这是在AutoCAD 2011中用pedit修复的,但我使用的版本太旧了,如果它是一只狗,它会因年老而死。
我应该这样做还是有更好的解决方案?
顶点2x=(顶点2“X”位置)
顶点2Y=(顶点2“Y”位置)
顶点4x=(顶点4“X”位置)
顶点4y=(顶点4“Y”位置)
顶点2x=(顶点4“X”位置)
顶点2Y=(顶点4“Y”位置)
顶点4x=(顶点2“X”位置)
顶点4y=(顶点2“Y”位置)
你把这个给你用了吗?如果没有,不妨试试比格尔上面提到的方法,重新创建矩形。这里有一个方法。。。
;; Select the midpoints of the rectangle on the sides to be stretched.
;;
(defun c:test (/ ed lay1 osm pt1 pt2)
(setq pt1 (getpoint "\nSelect First Midpoint: "))
(setq pt2 (getpoint "\nSelect Second Midpoint: "))
(setq ed (entget (car (nentselp pt1))))
(setq lay1 (cdr (assoc 8 ed)))
(if
(= (car pt1) (car pt2))
(command "._rectangle" (list (- (car pt1) 20) (cadr pt1)) (list (+ (car pt2) 20) (cadr pt2)))
(command "._rectangle" (list (car pt1) (- (cadr pt1) 20)) (list (car pt2) (+ (cadr pt2) 20)))
)
(command "._chprop" (entlast) "" "LA" lay1 "")
(entdel (cdr (car ed)))
(princ)
)
页:
[1]