明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1769|回复: 4

[求助]神了! 坐标正确却乱画线????????

[复制链接]
发表于 2010-7-17 01:27:00 | 显示全部楼层 |阅读模式
  1. (defun c:399 (/ data data1 dat_file ff    high low op co tx x0 xco xhh xll xop xvv)
  2. ;(setvar "cmdecho" 0)
  3. (setq dat_file (getfiled "展点范例" "f:\\399" "txt" 2))
  4. (setq ff (open dat_file "r"))
  5. (setq data (read-line ff))
  6. (while data
  7.     (setq data1 data x0 0 op 0 co 0 high 0 low 0 tx "0" xop() xvv() xco() xhh() xll() )
  8.     (setq x0 (read data1))
  9.     (setq data1 (vl-string-left-trim (itoa x0) data1))
  10.     ;(setq data1 (vl-string-left-trim " " data1))
  11.     (setq op (read data1))
  12.     (setq data1 (vl-string-left-trim " " data1))
  13.     (setq data1 (vl-string-left-trim (itoa op) data1))
  14.     (setq high (read data1))
  15.     (setq data1 (vl-string-left-trim " " data1))
  16.     (setq data1 (vl-string-left-trim (itoa high) data1))
  17.     (setq low (read data1))
  18.     (setq data1 (vl-string-left-trim " " data1))
  19.     (setq data1 (vl-string-left-trim (itoa low) data1))
  20.     (setq co (read data1))
  21.     (setq data1 (vl-string-left-trim " " data1))
  22.     (setq data1 (vl-string-left-trim (itoa co) data1))
  23.     (setq tx (vl-string-left-trim " " data1))
  24.     (setq xop (list x0 op))
  25.     (setq xco (list x0 co))
  26.     (setq xhh (list x0 high))
  27.     (setq xll (list x0 low))
  28.     (setq xvv (list (- x0 1) (- low 10)))
  29.     (if (< op co)
  30.     (command "layer" "s" "399red" "")
  31.     (command "layer" "s" "399blue" "")
  32.     ) ;_ 结束if
  33.     (command "pline" xop "w" 2 2 xco "")
  34.     (command "line" xhh xll "")
  35.     (command "text" xvv 2 270 tx "")
  36.     (setq data (read-line ff))
  37.     ) ;_ 结束while
  38. (close ff)
  39. (prin1 "")
  40. ;(prompt "<< 10TEST2>>自动展点串行技巧程序")
  41. (prin1)
  42. ;(setvar "cmdecho" 1)
  43. ) ;_ 结束defun
  44. ;(command "layer" "m" "szblue" "")
  45. ;(command "layer" "m" "szred" "")

数据文件: 399.txt
  1. 0 984 1003 979 1003 1476
  2. 6 1003 1008 992 995 2005年04月11日1593
  3. 8 993 993 978 978 1022
  4. 10 988 1006 988 1000 1607
  5. 12 1004 1006 985 987 1294
  6. 14 982 982 971 974 1040
  7. 20 970 970 958 963 2005年04月18日859
  8. 22 962 968 957 965 921
  9. 24 964 964 946 950 885
复制代码

明明监视里显示 坐标都是正确的,但是到了第三个循环时,就开始乱画线?但后面又有会画对的?????


转用手工输入 数据文件,同样的数据文件内容。按以下代码输入  。结果到了第四个数据时出错开始乱画?第五个却又正确了??

实在是打破头也找不到原因。请高手指点???
  1. (defun  c:htt( / x0 op co hh ll vv xop xco xhh xll xvv )
  2. (setq tt 0)
  3. (while (= tt 0)
  4. (setq x0 (getint  "输入日期坐标值"))
  5. (setq op (getint  "开盘价 :"))
  6. (setq co (getint  "收盘价  :"))
  7. (setq hh (getint  "最高价  :"))
  8. (setq ll (getint   "最低价 :"))
  9. (setq vv (getint   "成交量  :"))
  10. (setq xop (list x0 op))
  11. (setq xco (list x0 co))
  12. (setq xhh (list x0 hh))
  13. (setq xll (list x0 ll))
  14. (setq xvv (list (- x0 1) (- ll 10)))
  15. (if (< op co)  (command "layer" "s" "399red" "" )
  16.   (command "layer" "s" "399blue" "" ) )
  17. (command "pline"  xop  "w"  2 2  xco "")
  18. (command "line" xhh  xll "" )
  19. (command "text" xvv  2 270 vv "" )
  20. (setq tt  (getint  " 0 继续/其他退出 : "))
  21.   )
  22. )
  23. ;(command "layer" "m" "str" )
  24. ;(command "layer" "m" "txt" "")
  25. ;(command "layer" "s" "red" "" ))
发表于 2010-7-17 01:40:00 | 显示全部楼层

程序开头加一个(setvar "osmode" 0)试试

发表于 2010-7-17 09:05:00 | 显示全部楼层

关闭对象捕捉

程序开头加上

(setq oldosmode (getvar "osmode“))

(setvar "osmode" 0)

 

程序结尾再加上(setvar "osmode"  oldosmode)还原对象捕捉

 

发表于 2010-7-17 09:30:00 | 显示全部楼层
  1. (defun c:tt ()
  2.   (prompt "\n稍候...")
  3.   (defun Str2Lst (str / i str1 s)
  4.     (setq i 0
  5.    str1 ""
  6.     )
  7.     (while (vl-string-search "  " str)
  8.       (setq str (vl-string-subst " " "  " str))
  9.     )
  10.     (while (/= "" (setq s (substr str (setq i (1+ i)) 1)))
  11.       (setq str1 (strcat str1
  12.     (if (= " " s)
  13.       "" ""
  14.       s
  15.     )
  16.    )
  17.       )
  18.     )
  19.     (read (strcat "("" str1 "")"))
  20.   )
  21.   (setq tn (getfiled "坐标数据文件(txt;dat;*)" "" "txt;dat;*" 2))
  22.   (if (setq fle (findfile tn))
  23.     (progn
  24.       (setq fn (open fle "r"))
  25.       (command "pline")
  26.       (while (setq tx (read-line fn))
  27. (setq b (Str2Lst tx))
  28. (command (list (atoi (nth 1 b)) (atoi (nth 2 b))))
  29. (command (list (atoi (nth 3 b)) (atoi (nth 4 b))))
  30.       )
  31.       (command "")
  32.       (close fn)
  33.     )
  34.   )
  35.   (princ)
  36. )
 楼主| 发表于 2010-7-17 15:18:00 | 显示全部楼层
行了。谢谢楼上两位指点
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-10-2 08:26 , Processed in 0.161574 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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