这里是第1个和第2个的另一个示例,只需使用(getcoords)并查看前4个值。
- ; pline co-ords by BIG AL
- (defun plcords (/ ent obj plobs )
- (vl-load-com)
- (defun getcoords (ent)
- (vlax-safearray->list
- (vlax-variant-value
- (vlax-get-property
- (vlax-ename->vla-object ent)
- "Coordinates"
- )
- )
- )
- )
- (defun co-ords2xy ( / I)
- ; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
- (setq numb (/ (length co-ords) 2))
- (setq I 0)
- (repeat numb
- (setq xy (list (nth (+ I 1) co-ords)(nth I co-ords) ))
- (setq coordsxy (cons xy coordsxy))
- (setq I (+ I 2))
- ) ; end repeat
- )
- (setq plobjs (ssget (list (cons 0 "lwpolyline"))))
- (setq numb1 (sslength plobjs))
- (setq x numb1)
- (repeat numb1
- (setq obj (ssname plobjs (setq x (- x 1))))
- (setq co-ords (getcoords obj))
- )
- (co-ords2xy)
- (setq inc (length coordsxy))
- (repeat (/ inc 2)
- (setq x (rtos (nth (setq inc (- inc 1)) co-ords) 2 3 ))
- (setq y (rtos (nth (setq inc (- inc 1)) co-ords) 2 3 ))
- (setq xy (strcat x "," y ))
- (princ xy)
- (princ "\n ")
- )
- )
- (plcords)
|