明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1396|回复: 6

麻烦大家帮我看看这个程序怎么修改?

[复制链接]
发表于 2007-5-10 16:27 | 显示全部楼层 |阅读模式

(defun c:read (/ h x y z p)
  (setq h(findfile "高程点.txt"))
  (setq g(open h "r"))
  (setq q(read-line g))
  (while (/= q  nil)
    (setq x(substr q 3 10))
    (setq y(substr q 16 10))
    (setq z(substr q 29))
    (setq p(strcat """" x "," y "," z """"))
    (command "point" p);在图上展点
    (setq q(read-line g))
  );while
  (close g)
)

我编写了一个上面的程序,用来把数据文件中的点展到图上

现在有两个问题:

1.如果把数据文件从CAD系统路径中换到其他地方,就找不到文件,程序无法继续了,请问应该怎么办?

2.为什么展上的点看不到?应该不是点样式的问题,是不是图形边界设置的问题?怎么设置?

麻烦大家帮我看看,在此多谢了~~

 

 

 

发表于 2007-5-10 20:25 | 显示全部楼层
你能把这个程序的用途再详细说一遍吗? 我有点不太明白? 还有你把文件放在放在那格目录下了?
发表于 2007-5-12 08:43 | 显示全部楼层
  1. (defun c:read (/ h x y z p)
  2.   (setq h "高程点")
  3.   (setq h(getfiled "选择展点文件" h "txt" 2))
  4.   (if h(progn
  5.    (setvar "pdmode" 2)
  6.    (setvar "pdsize" -2)
  7.    (setq g(open h "r"))
  8.    (while (setq q(read-line g))
  9.     (setq x(substr q 3 10))
  10.     (setq y(substr q 16 10))
  11.     (setq z(substr q 29))
  12.     (setq p(strcat """" x "," y "," z """"))
  13.     (command "point" p);在图上展点
  14.    );while
  15.    (close g)
  16.   ))
  17.   (princ)
  18. )
发表于 2007-5-12 09:48 | 显示全部楼层

想求楼上的给修改一下楼上的程序!  
使得它能读取我的文件  
要求读取GIS文件内的点,然后根据出图比例生成一定宽度的PLING线并闭合!

;---------------------------------------------------------------
;功能 : 读取文本GIS文件,生成自定义的PL线。
;GIS文件内容形式为:   
; Y1;X1
; Y2;X2 
; Y3;X3   
; ……
; Yn;Xn
(defun c:GIS2PL (/ h x y z p)
  (setq gisname(getfiled "请选择GIS坐标数据文件" "" "GIS" 2))
  (if gisname(progn
   (setvar "pdmode" 2)
   (setvar "pdsize" -2)
   (setq gis(open gisname "r"))
   (while (setq q(read-line gis))
    (setq x(substr q 1 10))
    (setq y(substr q 12 10))
    (setq point(strcat """" y "," x """"))
    (command "pline" point);在图上画出pl线
   )
   (close gis)
  ))
  (princ)
)
;----------------------------------------------- 

发表于 2007-5-12 20:56 | 显示全部楼层
本帖最后由 作者 于 2007-5-13 16:23:48 编辑

;|;==============================================================
功能 : 读取文本坐标文件,生成PL线。
文本坐标文件内容格式为:

Y1;X1
Y2;X2
Y3;X3
……
Yn;Xn
|;
;;;日期:zml84 于 2007-05-12
(defun c:GIS2PL (/ gisname gis str lst tmp x y point)
(if (setq gisname (getfiled "请选择GIS坐标数据文件" "" "GIS" 2))
(progn
(setvar "pdmode" 2)
(setvar "pdsize" -2)
(setq gis (open gisname "r"))
;;设置多段线宽度
(setvar "PLINEWID" 3.5)
;;开始绘制多段线
(command "_.pline")
(while (and (setq str (read-line gis))
(wcmatch str "*;*")
)
;;初始化
(setq lst '()
tmp ""
i 1
)
;;判断分割符 ; 的位置并切割
(while (/= (setq stri (substr str i 1)) "")
(if (= stri ";")
(setq lst (cons tmp lst)
tmp ""
)
(setq tmp (strcat tmp stri))
)
(setq i (1+ i))
)
(setq lst (reverse (cons tmp lst)))

;;形成点位坐标
(if (>= (length lst) 2)
(progn (setq x (atof (nth 0 lst))
y (atof (nth 1 lst))
point (list x y)
)
(command "non" point)
)
)
)
;;结束绘制
(command "c")
(close gis)
)
)
(princ)
)
发表于 2007-5-12 23:18 | 显示全部楼层
谢谢楼上,不过就是有点乱了!
发表于 2007-5-13 16:40 | 显示全部楼层
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-6-18 02:13 , Processed in 0.163604 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表