- UID
- 267748
- 积分
- 1257
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-5-27
- 最后登录
- 1970-1-1
|
发表于 2005-11-23 17:16:29
|
显示全部楼层
Tony Tanzillo
Jan 17 2004, 5:38 pm show options
Newsgroups: autodesk.autocad.customization
From: "Tony Tanzillo" <tony.tanzillo at caddzone dot com> - Find messages by this author
Date: Sat, 17 Jan 2004 04:19:20 -0500
Local: Sat, Jan 17 2004 5:19 pm
Subject: Re: List of points?
Reply to Author | Forward | Print | Individual Message | Show original | Report Abuse
I can't say this is 'cool' but it handles both
2d and 3d coordinates (by passing the number of
dimensions in the second arg).
I've been using (and posting it here) since around
the time that A2K was released.
;; Convert a flat list of 2d or 3d points as
;; returned by various properties of ActiveX
;; objects, to a list of point lists. The first
;; argument is a simple list of doubles in the
;; form (x1 y1 [z1] x2 y2 [z2]...). The second
;; argument is the number of dimensions (which
;; must be either 2 or 3).
(defun Coordinates->List (vlist dims / rslt)
(if (eq dims 2)
(while
(setq rslt
(cons
(list
(car vlist)
(cadr vlist)
)
rslt
)
vlist (cddr vlist)
)
)
(while
(setq rslt
(cons
(list
(car vlist)
(cadr vlist)
(caddr vlist)
)
rslt
)
vlist (cdddr vlist)
)
)
)
(reverse rslt)
)
;;; ==================================================
(Coordinates->List
(vlax-safearray->list
(vlax-variant-value
(vlax-get-property
(vlax-ename->vla-object ee) ; ee == LWPOLYLINE
'Coordinates
)
)
)
2
) |
|