所以我有这个代码。
(setq ss (ssget "X" '((0 . "LWPOLYLINE") (90 . 4) (-4 . "&=") (70 . 1) )))
;Selecteaza toate Polyline-urile cu 4 colturi, si care sunt inchise.
(setq n 0
var (getpoint "Select where to order rentagles")
)
(repeat (sslength ss) ;Parcurge setul de selectie
(setq tent (entget (ssname ss n))
telem (assoc 10 tent)
listvar(cons 10 var))
(setq
tent(subst listvar telem tent)
)
(entmod tent)
(setq n (1+ n))
)
(princ)
)
虽然它所做的是,它只移动任何矩形的左上角到我的指定点。我怎么能对整个矩形做同样的事情,或者我怎么能用dxf代码改变其他角?先谢谢你
EDIT : 我读到了这个" 10个顶点坐标(OCS中),多个条目;每个顶点一个条目DXF:X值;APP:2D点 "我如何能使用顶点的其他条目?
您需要计算您希望对齐的顶点和目标点之间的向量,然后用相同的向量翻译所有顶点。
例如(使用你另一个问题的代码):
(defun c:moverect ( / a b c d e i p s v x )
(cond
( (not (setq s (ssget "_X" '((0 . "LWPOLYLINE") (90 . 4) (-4 . "&=") (70 . 1)))))
(princ "\nNo closed polylines found.")
)
( (setq p (getpoint "\nSpecify target point: "))
(setq p (trans p 1 (trans '(0 0 1) 1 0 t)))
(repeat (setq i (sslength s))
(setq i (1- i)
e (ssname s i)
x (entget e)
)
(mapcar 'set '(a b c d) (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) x)))
(if
(and
(equal (distance a b) (distance c d) 1e-8)
(equal (distance b c) (distance a d) 1e-8)
(equal (distance a c) (distance b d) 1e-8)
)
(progn
(setq v (mapcar '- p a))
(entmod
(mapcar
'(lambda ( x )
(if (= 10 (car x))
(cons 10 (mapcar '+ (cdr x) v))
x
)
)
x
)
)
)
)
)
)
)
(princ)
)
然而,请注意,与目标点对齐的顶点将取决于二维多角线的方向--你可能想要包含一个测试,以总是选择,例如,左下角的顶点对齐--然后你将需要决定如何处理旋转的矩形。