找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1674|回复: 4

[编程申请]:请高手帮忙修改程序

[复制链接]

已领礼包: 39个

财富等级: 招财进宝

发表于 2002-11-12 13:15:44 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×

  1. [FONT=courier new]
  2. (defun c:pm(/ x0 y0 x y p0 n m x1 y1 p1 g high i)
  3.   (setq y0 4000)
  4.   (setq x0 3000)
  5.   (setq g 1000)
  6.   (setq y1 (- y0 2))
  7.   (setq p1 (list x0 y1))
  8.   (setq high (strcat (rtos x0) "," (rtos y0)))
  9.   (setq x x0)
  10.   (setq y y0)
  11.   (setq p0 (list x0 y0))
  12.   (setq n 5)
  13.   (setq m 5)
  14.   (setq x1 x0)
  15.   (setq y1 (+ y0 (* m 100)))
  16.   (setq p1 (list x1 y1))
  17. ;--------vertical line---------------
  18.   (repeat n
  19.         (setq x (+ x 100))
  20.         (setq p0 (list x y0))
  21.         (setq p1 (list x y1))
  22.    )   
  23. ;-------------hor-line----------------
  24.   (setq p0 (list x0 y0))
  25.   (setq x1 (+ x0 (* n 100)))
  26.   (setq p1 (list x1 y0))
  27.   (repeat m
  28.         (setq y (+ y 100))
  29.         (setq p0 (list x0 y))
  30.         (setq p1 (list x1 y))
  31.   )   
  32. ;-----------Post of [xmy]------------------
  33.   (setq i 1)
  34.   (while i
  35.     (setq x(getreal "\nEnter[x,y]:"))
  36.     (setq y(getreal "\nEnter[x,y]:"))
  37.     (setq x1 (+ x0 (/ (* 1000.0 (- y x0)) g)))
  38.     (setq y1 (+ y0 (/ (* 1000.0 (- x y0)) g)))
  39.     (setq p0 (list x1 y1))
  40.     (setq p1 (list (+ x1 1) y1))
  41.     (setq high (getstring "High:"))
  42.     (if (= high "-1")
  43.       (setq i NIL)
  44.       (progn
  45.          (command "donut" 0 0.3 p0 "")
  46.          (command "text" "j" "ML" p1 1.5 0 high)
  47.       ))
  48.   )      ;while
  49. )


  50. 最后一段能不能从手工输入改为以文件形式输入,如文件为:
  51. 1000,2000,1678.23
  52. 1050,2080,1656.78
  53. ...........
  54. x,y,high[/FONT]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2002-11-14 03:31:46 | 显示全部楼层
读数据文件的代码
说明:
1、一时偷懒,字符串分隔引用了晓东API函数
2、省略对数据文件格式进行完整性校验的代码


  1. (defun Read_File (/ f_nam f_id lst_pt str_line x y high)
  2.   (setq f_nam (getfiled "选择数据文件" "" "" 12)
  3.   (if f_nam (progn
  4.     (setq f_id (open f_nam "r"))
  5.     (while (setq str_line (read-line f_id))
  6.       (setq lst_pt (xdrx_string_split str_line ","))
  7.       (setq x (atof (car lst_pt))
  8.             y (atof (cadr lst_pt))
  9.             high (atof (caddr lst_pt))
  10.       );setq

  11.       ;;;这里可以加入你的代码
  12.       
  13.     );while
  14.     (close f_id)
  15.   ));if
  16. );end
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 39个

财富等级: 招财进宝

 楼主| 发表于 2002-11-14 13:00:28 | 显示全部楼层
上边那段程序怎样才能完整地加入到我的程序里
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2002-11-14 13:38:08 | 显示全部楼层
(setq x (atof (car lst_pt))
            y (atof (cadr lst_pt))
            high (atof (cadr lst_pt))
      );setq
>>> high (atof (last lst_pt))
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2002-11-17 14:12:24 | 显示全部楼层
谢谢梦断江南的修改

帮人帮到底:
加入文件读取功能后的代码:
(需要先加载晓东API)

  1. (defun c:pm (/ x0 y0 x y p0 n m x1 y1 p1 g high i)
  2.   (setq y0 4000)
  3.   (setq x0 3000)
  4.   (setq g 1000)
  5.   (setq y1 (- y0 2))
  6.   (setq p1 (list x0 y1))
  7.   (setq high (strcat (rtos x0) "," (rtos y0)))
  8.   (setq x x0)
  9.   (setq y y0)
  10.   (setq p0 (list x0 y0))
  11.   (setq n 5)
  12.   (setq m 5)
  13.   (setq x1 x0)
  14.   (setq y1 (+ y0 (* m 100)))
  15.   (setq p1 (list x1 y1))
  16. ;--------vertical line---------------
  17.   (repeat n
  18.         (setq x (+ x 100))
  19.         (setq p0 (list x y0))
  20.         (setq p1 (list x y1))
  21.    )   
  22. ;-------------hor-line----------------
  23.   (setq p0 (list x0 y0))
  24.   (setq x1 (+ x0 (* n 100)))
  25.   (setq p1 (list x1 y0))
  26.   (repeat m
  27.         (setq y (+ y 100))
  28.         (setq p0 (list x0 y))
  29.         (setq p1 (list x1 y))
  30.   )   
  31. ;-----------Post of [xmy]------------------
  32.   (Read_dataFile)
  33. );end

  34. (defun Read_dataFile (/ f_nam f_id lst_pt str_line cmd)
  35.   (setq f_nam (getfiled "选择数据文件" "" "" 12))
  36.   (if f_nam (progn
  37.     (setq f_id (open f_nam "r"))

  38.     (setq cmd (getvar "cmdecho"))
  39.     (setvar "cmdecho" 0)
  40.    
  41.     (while (setq str_line (read-line f_id))
  42.       (setq lst_pt (xdrx_string_split str_line ","))
  43.       (setq x (atof (car lst_pt))
  44.             y (atof (cadr lst_pt))
  45.             high (caddr lst_pt)
  46.       );setq
  47.       
  48.       ;;;以下加入你的代码
  49.       (setq x1 (+ x0 (/ (* 1000.0 (- y x0)) g)))
  50.       (setq y1 (+ y0 (/ (* 1000.0 (- x y0)) g)))
  51.       (setq p0 (list x1 y1))
  52.       (setq p1 (list (+ x1 1) y1))
  53.       (command "donut" 0 0.3 p0 "")
  54.       (command "text" "j" "ML" p1 1.5 0 high)
  55.     );while
  56.     (close f_id)
  57.     (setvar "cmdecho" cmd)
  58.   ));if
  59. );end
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-9-26 09:30 , Processed in 0.368534 second(s), 40 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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