总是继续编码 哇,这是我第一次尝试帮助别人(可能是因为我觉得我有什么需要帮助的,但我承认问要有趣得多)。
---------------------------------------------------------------------
(defun Splitter(str md / d l str)
(while (setq d (vl-string-position md str nil T))
(setq l (cons (substr str (+ 2 d)) l)
str (substr str 1 d)))
(cons str l)
)
---------------------------------------------------------------------
(defun c:csv_import (/ snp lay file opn rd point est lvl north base_pt
sno_pt rmrk_pt sno code )
(setq snp(getvar "osmode"))
(setq lay(getvar "clayer"))
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(command "_.UNDO" "G")
-------------------------------------------------------------------
(command "_.LAYER" "M" "Serial_No" "c" "1" "" "")
(command "_.LAYER" "M" "Level" "c" "2" "" "")
(command "_.LAYER" "M" "Remark" "c" "3" "" "")
(command "_.LAYER" "M" "Point" "c" "4" "" "")
-------------------------------------------------------------------
(setq file(getfiled "Select File To Import" "" "csv" 4))
(setq opn(open file "r"))
(while
(setq rd(read-line opn))
(setq str rd)
(setq Point (Splitter str 44))
-----------------------------------------------------------------
(setq Est(atof(nth 1 point))) (setq north(atof (nth 2 point)))
(setq Lvl(atof (nth 3 point))) (setq base_pt (list est north lvl))
-----------------------------------------------------------------
(setq sno_pt(list est (+ north 0.7) lvl))
(setq rmrk_pt(list est (- north 0.7) lvl))
(setq sno(nth 0 point))
(setq Code(nth 4 point))
(command "TEXT" "J" "MC" sno_pt "0.5" "0" sno)
(Command "Change" (entlast) "" "p" "la" "Serial_No" "c" "bylayer" "")
(command "TEXT" "J" "MC" rmrk_pt "0.5" "0" code)
(Command "Change" (entlast) "" "p" "la" "Remark" "c" "bylayer" "")
(command "TEXT" "J" "MC" Base_pt "0.5" "0" (rtos lvl))
(Command "Change" (entlast) "" "p" "la" "Level" "c" "bylayer" "")
(command "point" base_pt)
(Command "Change" (entlast) "" "p" "la" "Point" "c" "bylayer" "")
);while
(command "pdmode" 35)
(command "pdsize" 0.5)
(setvar "cmdecho" 1)
(setvar "osmode" snp)
(setvar "clayer" lay)
(command "_.UNDO" "E")
(command "Zoom" "e")
(princ)
);end defun
我有一个类似的问题,我认为这件事帮助了我。它可以修改为分割字符串的标准,我不记得细节了。
很抱歉,我不记得我把这个带到哪里了。 首先
(defun LM:str->lst ( str del / pos )
(if (setq pos (vl-string-search " " str))
(cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del))
(list str)
)
这里有一个提示
10
Tank u pBe ...hmm.....Tats ok ....
I willNot Feel Bad and Not ClosingMy Account
Tanks for your support
:):):):)
All the time. keep on coding Wow first time ever i'm trying help(maybe because i thing i have something to help with, but i admit asking is much more fun.
(defun LM:str->lst ( str del / pos ) (if (setq pos (vl-string-search " " str)) (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del)) (list str) )
I had a similar problem, and i think this thing helped me.it could be modified for criteria of dividing string, i don't remeber details.
I'm sorry that i dont remember where i aqcuired this to. First of all
(setq pos (vl-string-search del str))
and here's a hint
LM:str->lst
页:
1
[2]