马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Change a specific coordinate in a LWPOLYLINE in Lisp By Gopinath Taget
The LWPOLYLINE (or light weight polyline) will typically have multiple coordinates and it is not easy to modify these vertices. What is the easiest way to access specific coordinates in a LWPOLYLINE and modify it?
The following lisp code demonstrates an easy way. The lisp code snippet increments the Y values of the LWPOLYLINE vertices by 5 units:
------------------------------------------------------翻译的分割线--------------------------------------------------
LWPOLYLINE(或者轻多段线 light weight polyline) 通常有多个顶点并且要修改它们不是很容易,有什么方便的方式存取LWPOLYLINE指定的顶点坐标并且修改它?
下面的LISP代码演示了一个方便的方法,把一个多段线的顶点坐标的Y值增加5个单位。 - (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 (+ 5 Y)) ;_ increment the Y value by 5 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
|