[原创]一个小程序,请高手为什么不能运行呢?狂急!!是关于读入数据而后画多段线的。请高手指点呀![br]要实现的目的是:从文件中读入数据,而后在cad中画出图来(使用多段线) 为什么编译是说 :输入的列表有错误!- (vl-load-com)
- (setq *ModelSpace* (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-Acad-Object))))
- (defun c:dd ()
-
- (setq HOLDECHO (getvar "cmdecho"))
- (setvar "cmdecho" 0)
-
- (setq n_s 10)
- (setq w_e 2)
- (print "\nTo draw the y_oriented line")
- (setq ss (getfiled "Open file" "d:\" "dat" 8)
- s t
- fn nil)
- (setq i 1)
- (setq k 1)
- (if ss
- (progn
- (setq fn (open ss "r"))
- (print "\n Please waiting....")
- (princ)
- (while (<= i w_e)
- (while (<= k n_s)
- (setq s (read-line fn))
- (print s)
- (princ)
- (setq ps (cons (list (car(read s)) (car (cdr (read s)))) ps))
- (print ps)
- (princ)
- (setq k (1+ k))
- )
- (setq ps (reverse ps))
- (draw_grid ps)
- (setq i (1+ i))
- )
- (close fn)
- )
- (print "\n the file error! ")
- )
- (setvar "cmdecho" HOLDECHO)
- (princ)
- )
- (defun draw_grid (pointlist /) (setq polypoints (apply 'append pointlist)
- (setq VLADataPts (list->variantArray polypoints))
- (setq pline (vla-addLightweightPolyline
- *ModelSpace*
- VLADataPts)
- )
- (vla-put-closed pline t)
- pline
- )
- (defun list->variantArray (ptsList / arraySpace sArray)
- (setq arraySpace (vlax-make-safearray
- vlax-vbdouble
- (cons 0
- (- (length ptsList) 1)
- )
- )
- )
- (setq sArray (vlax-safearray-fill arraySpace ptsList))
- (vlax-make-variant sArray)
- )
输入文件格式:(x1 y2)(x2 y2)(x3 y3)...........[/U][/U] |