aaryan 发表于 2022-7-6 07:53:57

“字符串”的帮助(列表)

大家好,
 
我对autolisp编程非常陌生,并尝试制作一个lisp例程,该例程从外部文件读取xyz,并将其z值作为块属性导入。到目前为止,我已经达到如下。
 
(defun c:bthy (/ tpath fd info Bs Bsc BSL eas nor ipt ba tpt x y xs ys)
(setq tpath (getfiled "Select XYZ File" "*.*" "" 4))
   (setvar "cmdecho" 0)
   (graphscr)
   (setq fd   (open tpath "r")
info (read-line fd)
   )
   (if        (/= info nil)
   (progn
(setq Soundings (getfiled "Select Sounding Block" "*.*" "dwg" 4))
(setq Bs (Getreal "\nScale factor for Bathymetry Block <1>:"))
(if (= Bs Nil)
(setq Bsc 1)
(setq Bsc Bs)
)
   )
   (progn (alert "Bathy file is empty") (exit))
   )
   (setq BSL (rtos Bsc 2 3))
   (while (/= info nil)
   (setq eas        (atof (substr info 1 10))
    nor        (atof (substr info 12 11))
    ipt        (list eas nor)
    ba        (atof (substr info 24 5))
    tpt        (list eas nor ba)
    x        (fix ba)
    y        (fix (* (- ba x) 10))
    xs        (itoa x)
    ys        (itoa y)
   )
   (command "insert" Soundings ipt BSL BSL 0 xs ys)
   (setq info (read-line fd))
   )
   (close fd)
   (COMMAND "zoom" "0.8x")
   (COMMAND "regen")
   (princ)
)
 
水深测量。图纸
 
此代码的文件应包含一行,因为(例如500000.0002150000.000,23.5)可以使用任何分隔符,但X和Y小数必须为3,Z必须为1。
 
我的要求和问题是:
1,我总是得到一个文本文件,它具有东距北距和高程,每行都有不同的小数,我如何使我的代码能够在不更改excel中的小数的情况下读取文件。
2,我还得到了包括正视图甚至负视图的文件(即500000.232154356.355,-25.1和500101.2,2155389.24,24.1),如何过滤所有负视图(-)并插入为(%U25.1)。
3,我可以为不同的值提供颜色作为用户给定的整数间隔吗。。
 
我希望我不要期望太高,但我需要帮助。
谢谢和问候

pBe 发表于 2022-7-6 08:53:30

(setq数据(读取(strcat)(“(vl字符串翻译”,“信息)”))))(setq ipt(列表(car数据)(cadr数据)))

aaryan 发表于 2022-7-6 09:16:13

非常感谢。。pBe。。
页: [1]
查看完整版本: “字符串”的帮助(列表)