大家好,
我对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 Bathymetry 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)
- )
这是块的图纸。
[ATTACH]35101[ATTACH]
此代码的文件应包含一行,因为(例如500000.0002150000.000,23.5)可以使用任何分隔符,但X和Y小数必须为3,Z必须为1。
我的要求和问题是:
1,我总是得到一个文本文件,它具有东距北距和高程,每行都有不同的小数,我如何使我的代码能够在不更改excel中的小数的情况下读取文件。
2,我还得到了包括正视图甚至负视图的文件(即500000.232154356.355,-25.1和500101.2,2155389.24,24.1),如何过滤所有负视图(-)并插入为(%.1)。
3,我可以为不同的值提供颜色作为用户给定的整数间隔吗。。
我希望我不要期望太高,但我需要帮助。
谢谢和问候
对不起,我错发了两次帖子,请忽略前一次。 |