明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2346|回复: 4

[讨论] 测井曲线的读取-问题何在

[复制链接]
发表于 2009-11-23 14:02:00 | 显示全部楼层 |阅读模式


(defun C:WTCJ ()
  (command "osnap" "off" )
  (COMMAND "insert" "c:\\Temp\\AB线CD段EF隧道DZ-01-023孔.dwg" "0,0,0" "1" "1" "0")
  (COMMAND "_explode" "all")
  (COMMAND "_zoom" "e")
  (princ "\n读取综合测井文件数据,绘制曲线。")
  (if (setq FILE (getfiled "选择dat文件"
      ""
      "dat"
      4
   )
      )
    (progn
      ;;读模式打开lsp文件
      (setq A1 (open FILE "r"))
      ;;逐行读入
      (while (/= A1 nil)
 (setq STR (repeat 2 (read-line F1)))
 (if(= F1 "自然电位")
 (progn
        (setq min1 (getreal "请输入自然电位最小值"))
        (setq max1 (getreal "请输入自然电位最大值"))
        (rtos (setq mid1 (/ max1 4)));转成字符串
        (rtos (setq mid2 (/ max1 2)))
        (rtos (setq mid3 (* (/ max1 4) 3)))
        (setq mid (strcat mid1 "   " mid2 "   " mid3))
        (command "text" "s" "BG_ST" "j" "bc" "110.012,2.375,0" "2.5" "90d" mid)
        (setq STR (repeat 4 (read-line F1)));钻孔编号
        (setq LST STR)
        (command "text" "s" "BG_ST" "j" "bl" "-140.524,42.492,0" "3.6" "90d" LST);写图签
        (setq len (strlen STR))
             (setq LST1 (strcat(substr STR 1 1) "  "))
             (setq len (- len 1))
             (if (/= len 0)
                (progn
;                      (setq n 1)
                      (setq n (+ n 1))
                      (setq LST1 (strcat LST1 (substr LST1 n 1) "  "))
                      (setq len (- len 1))
                )
             )
        (command "text" "s" "BG_ST" "j" "bl" "90.960,48.634,0" "5.0" "90d" LST1);写标题
        (setq STR (repeat 3 (read-line F1)));套管长度
        (setq LST2 (strcat STR "m"))
        (command "text" "s" "BG_ST" "j" "bl" "217.39,32.308,0" "2.5" "90d" LST2)
        (atoi LST2)
        (setq LST3 (* LST2 2));1:500故乘2
       
        (setq pa1 (polar '(30.0 0.0) (* pi 1.5) LST3))
        (setq pa2 (polar '(80.0 0.0) (* pi 1.5) LST3))
        (setq pa3 (polar '(32.382 -2.608) (* pi 1.5) (- LST3 2)))
        (setq pa4 (polar '(32.154 -2.608) (* pi 1.5) (- LST3 2)))
        (command "pline" '(32.382 -2.608) pa3 "")
        (command "pline" '(32.154 -2.608) pa4 "")
        (command "pline" pa1 pa2 "")
        (command "text" "s" "BG_ST" "j" "bc" "55,-116,0" "2.0" "90d" LST3)
        (command "text" "s" "BG_ST" "j" "bc" "70,-116,0" "2.0" "90d" "套管")
        (setq STR (read-line F1));测试日期
        (command "text" "s" "BG_ST" "j" "mc" "-58.524,11.258,0" "2.4" "90d" STR)
        (setq STR (repeat 2 (read-line F1)));钻孔标高
        (setq LST4 (strcat STR "m"))
        (command "text" "s" "BG_ST" "j" "bl" "103.604,32.308,0" "2.5" "90d" LST4)
        (setq STR (repeat 140 (read-line F1)));测井数据152行
        (atof STR);转成实数
        (list STR);转到串行
        (setq data1 (car STR))
        (setq data2 (cadr STR))
        (setq data11 (atof data1))
        (setq data21 (atof data2))
        (setq Y (* data11 -2));1:500计算Y坐标
        (if(< data21 min1) (setq X 90))
        (if(> data21 max1) (setq X 130))
        (if(and (> data21 min1) (< data21 max1))
             (setq X (+ (* (/ (- data21 min1) (- max1 min1)) 40) 90));min1<data21<max1时,X=[(data21-min1)/(max1-min1)]*40+90
             (setq G1 '(X,Y))
         )   
             (while (/= STR nil)
                    (line-line())
                    (command "layer" "s" "图层8" "")
                    (command "pline" G1 G2 "w" "0.0" "0.0")
                    (setq G1 G2)
             )
             (defun line-line (STR)
             (progn
                   (setq STR (read-line F1))
                   (atof STR)
                   (list STR)
                   (setq data1 (car STR))
                   (setq data2 (cadr STR))
                   (setq data11 (atof data1))
                   (setq data21 (atof data2))
                   (setq Y (* data11 -2))
                   (if(< data21 min1) (setq X 90))
                   (if(> data21 max1) (setq X 130))
                   (if(and (> data21 min1) (< data21 max1))
                       (setq X (+ (* (/ (- data21 min1) (- max1 min1)) 40) 90))
                       (setq G2 '(X,Y))
                   )
                  
              )
              )
     ))   
   )          
      ))
     (close A1)
     (princ "\nOK!")
     (prompt "\n********* << C:WTCJ >> *********")
)
      
 问题:函数的功能是读测井曲线,并画在CAD图上。为什么会是参数类型错误呢?要怎么改?

本帖子中包含更多资源

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

x
 楼主| 发表于 2009-11-28 19:21:00 | 显示全部楼层
高手何在?进来帮帮忙吧.
发表于 2009-11-28 22:08:00 | 显示全部楼层
源程序乱得一团糟,硬的头皮改了一下
  1. (defun C:WTCJ ()
  2.   (defun line-line ()
  3.     (setq STR (read-line F1))
  4.     (setq lst (strParse STR " ")) ;转换成列表
  5.     (setq data1 (car lst))
  6.     (setq data2 (cadr lst))
  7.     (setq data11 (atof data1))
  8.     (setq data21 (atof data2))
  9.     (setq Y (* data11 -2))
  10.     (if (< data21 min1)
  11.       (setq X 90)
  12.     )
  13.     (if (> data21 max1)
  14.       (setq X 130)
  15.     )
  16.     (if (and (> data21 min1) (< data21 max1))
  17.       (setq
  18.         X
  19.   (+ (* (/ (- data21 min1) (- max1 min1)) 40) 90)
  20.       )
  21.     )
  22.     (setq G2 (list X Y))
  23.   )
  24.   
  25.   (command "osnap" "off")
  26.   (COMMAND "insert"
  27.     "C:\\Downloads\\AB线CD段EF隧道DZ-01-023孔\\AB线CD段EF隧道DZ-01-023孔.dwg"
  28.     "0,0,0"       "1"
  29.     "1"        "0"
  30.    )
  31.   (COMMAND "_explode" "all")
  32.   (COMMAND "_zoom" "e")
  33.   (princ "\n读取综合测井文件数据,绘制曲线。")
  34.   (if (setq FILE (getfiled "选择dat文件"
  35.       ""
  36.       "dat"
  37.       4
  38.    )
  39.       )
  40.     (progn
  41.       ;;读模式打开lsp文件
  42.       (setq F1 (open FILE "r"))
  43.       ;;逐行读入
  44.       (while (/= A1 nil)
  45. (setq STR (repeat 2 (read-line F1)))
  46. (if (= STR "自然电位")
  47.    (progn
  48.      (setq min1 (getreal "请输入自然电位最小值"))
  49.      (setq max1 (getreal "请输入自然电位最大值"))
  50.      (setq mid (strcat (rtos (setq mid1 (/ max1 4))) ;转成字符串
  51.          "  "
  52.          (rtos (setq mid2 (/ max1 2)))
  53.          "  "
  54.          (rtos (setq mid3 (* (/ max1 4) 3)))
  55.         )
  56.      )
  57.      (command "text"  "s"      "BG_ST"  "j"
  58.        "bc"  "110.012,2.375,0"  "2.5"
  59.        "0"  mid
  60.       )
  61.      (setq STR (repeat 4 (read-line F1))) ;钻孔编号
  62.      (setq LST STR)
  63.      (command "text"  "s"      "BG_ST"  "j"
  64.        "bl"  "-140.524,42.492,0"  "3.6"
  65.        "0"  LST
  66.       )   ;写图签
  67. ;;;     (setq len (strlen STR))
  68. ;;;     (setq LST1 (strcat (substr STR 1 1) "  "))
  69. ;;;     (setq len (- len 1))
  70. ;;;     (if (/= len 0)
  71. ;;;       (progn
  72. ;;;     ;                      (setq n 1)
  73. ;;;  (setq n (+ n 1))
  74. ;;;  (setq LST1 (strcat LST1 (substr LST1 n 1) "  "))
  75. ;;;  (setq len (- len 1))
  76. ;;;       )
  77. ;;;     )
  78.      (command "text"  "s"      "BG_ST"  "j"
  79.        "bl"  "90.960,48.634,0"  "5.0"
  80.        "0"  LST
  81.       )   ;写标题
  82.      (setq STR (repeat 3 (read-line F1))) ;套管长度
  83.      (setq LST2 (strcat STR "m"))
  84.      (command "text"  "s"      "BG_ST"  "j"
  85.        "bl"  "217.39,32.308,0"  "2.5"
  86.        "0"  LST2
  87.       )
  88.      
  89.      (setq LST3 (* (atof  STR) 2)) ;1:500故乘2
  90.      (setq pa1 (polar '(30.0 0.0) (* pi 1.5) LST3))
  91.      (setq pa2 (polar '(80.0 0.0) (* pi 1.5) LST3))
  92.      (setq pa3 (polar '(32.382 -2.608) (* pi 1.5) (- LST3 2)))
  93.      (setq pa4 (polar '(32.154 -2.608) (* pi 1.5) (- LST3 2)))
  94.      (command "pline" '(32.382 -2.608) pa3 "")
  95.      (command "pline" '(32.154 -2.608) pa4 "")
  96.      (command "pline" pa1 pa2 "")
  97.      (command "text" "s" "BG_ST" "j" "bc" "55,-116,0" "2.0" "0"
  98.        LST3)
  99.      (command "text" "s" "BG_ST" "j" "bc" "70,-116,0" "2.0" "0"
  100.        "套管")
  101.      (setq STR (read-line F1)) ;测试日期
  102.      (command "text"  "s"      "BG_ST"  "j"
  103.        "mc"  "-58.524,11.258,0"  "2.4"
  104.        "0"  STR
  105.       )
  106.      (setq STR (repeat 2 (read-line F1))) ;钻孔标高
  107.      (setq LST4 (strcat STR "m"))
  108.      (command "text"  "s"      "BG_ST"  "j"
  109.        "bl"  "103.604,32.308,0"  "2.5"
  110.        "0"  LST4
  111.       )
  112.      (setq STR (repeat 140 (read-line F1))) ;测井数据152行
  113.      (setq lst (strParse STR " "));转换成列表
  114.      (setq data1 (car lst))
  115.      (setq data2 (cadr lst))
  116.      (setq data11 (atof data1))
  117.      (setq data21 (atof data2))
  118.      (setq Y (* data11 -2)) ;1:500计算Y坐标
  119.      (if (< data21 min1)
  120.        (setq X 90)
  121.      )
  122.      (if (> data21 max1)
  123.        (setq X 130)
  124.      )
  125.      (if (and (> data21 min1) (< data21 max1))
  126.        (setq X (+ (* (/ (- data21 min1) (- max1 min1)) 40) 90))
  127.      ;min1<data21<max1时,X=[(data21-min1)/(max1-min1)]*40+90
  128.      )
  129.      (setq G1 (list X Y))
  130.      (while (/= STR nil)
  131.        (line-line)
  132.        (command "layer" "s" "图层8" "")
  133.        (command "pline" G1 G2 "w" "0.0" "0.0" "")
  134.        (setq G1 G2)
  135.      )
  136.      
  137.    )
  138. )
  139.       )
  140.     )
  141.   )
  142.   (close A1)
  143.   (princ "\nOK!")
  144. )
  145. ;;;将具有分隔符的字符串解析为列表
  146. (defun strParse (Str Delimiter / SearchStr StringLen return n char)
  147.   (setq SearchStr Str)
  148.   (setq StringLen (strlen SearchStr))
  149.   (setq return '())
  150.   (while (> StringLen 0)
  151.     (setq n 1)
  152.     (setq char (substr SearchStr 1 1))
  153.     (while (and (/= char Delimiter) (/= char ""))
  154.       (setq n (1+ n))
  155.       (setq char (substr SearchStr n 1))
  156.     ) ;_ end of while
  157.     (setq return (cons (substr SearchStr 1 (1- n)) return))
  158.     (setq SearchStr (substr SearchStr (1+ n) StringLen))
  159.     (setq StringLen (strlen SearchStr))
  160.   ) ;_ end of while
  161.   (reverse return)
  162. ) ;_ end of defun
发表于 2009-11-28 22:12:00 | 显示全部楼层

本帖子中包含更多资源

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

x
 楼主| 发表于 2009-12-1 13:22:00 | 显示全部楼层
谢谢楼上的,有空来长沙,请你喝茶。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-10-1 19:37 , Processed in 0.188158 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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