本帖最后由 荒野孤行 于 2015-4-17 23:50 编辑
菜卷鱼 发表于 2015-4-17 14:19
非常感谢!可以了。
另:重新修改了下,把list_ok表reverse了下,加了\n,对应转出数据有了对应的描述。- ;;;*****导出多段线顶点坐标 程序开始*****
- (defun c:t1 (/ entnam dwg)
- (setvar "cmdecho" 0)
- (princ "\n★功能:导出多段线顶点坐标至文本文件.\n")
- (setq nam (rtos (* (getvar "cdate") 1E8)))
- (setq ffn (getfiled "指定文件存储路径及文件名" nam "dat" 1))
- (setq ff (open ffn "w"))
- (close ff)
- (princ "\n选取要导出标高的多段线:")
- (setq ss (ssget '((0 . "POLYLINE,LWPOLYLINE"))))
- (princ "\n选取要导出标高的多段线顶点处的块参照:")
- (setq ss_block (ssget '((0 . "INSERT") (2 . "GC200"))))
- (setq m 0
- i 0
- list_block
- nil
- )
- (setvar "pdmode" 35)
- (vl-load-com)
- (repeat (sslength ss_block)
- (setq ent_block (ssname ss_block m)
- data_block (entget ent_block)
- pt_block (cdr (assoc 10 data_block))
- list_block (cons pt_block list_block)
- )
- (setq m (1+ m))
- )
- (setq ff (open ffn "a"))
- (princ "顶点坐标的序号 X坐标 Y坐标 Z坐标\n" ff)
- (close ff)
- (repeat (sslength ss)
- (setq entnam (ssname ss i)
- obj (vlax-ename->vla-object entnam)
- pt_list nil
- list_ok nil
- )
- (setq j -1)
- (while (setq pp (vlax-curve-getpointatparam obj (setq j (1+ j))))
- (setq pt_list (cons (list (+ j 1) pp) pt_list))
- )
- (if
- (=
- nil
- (vl-position
- "nil"
- (mapcar '(lambda (a b) (equal a b 0.01))
- (mapcar '(lambda (x) (cdr (reverse (cadr x)))) pt_list)
- (mapcar '(lambda (x) (cdr (reverse x))) list_block)
- )
- )
- )
- (setq list_ok
- (reverse
- (mapcar
- '(lambda (x) (reverse x))
- (mapcar
- 'cons
- (mapcar '(lambda (x) (car (reverse x))) list_block)
- (mapcar
- '(lambda (x) (cdr (reverse (cons (car x) (cadr x)))))
- pt_list
- )
- )
- )
- )
- )
- )
- (setq ff (open ffn "a"))
- (mapcar '(lambda (x)
- (princ (strcat (itoa (car x))
- ","
- (rtos (cadr x) 2 4)
- ","
- (rtos (caddr x) 2 4)
- ","
- (rtos (last x) 2 4)
- "\n"
- )
- ff
- )
- )
- list_ok
- )
- (setq i (1+ i))
- (princ (strcat "↑第 " (itoa i) " 条多段线对应的顶点导出完毕。\n")
- ff
- )
- (princ "\n" ff)
- (close ff)
- )
- (princ (strcat "\n文件已保存至:" ffn))
- (princ)
- )
- ;;;*****导出多段线顶点坐标 程序结束*****
|