乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: godofcad

[编程交流] 拆分文字

[复制链接]

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-6 08:33:10 | 显示全部楼层
 
总是继续编码
回复

使用道具 举报

4

主题

23

帖子

19

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 08:38:32 | 显示全部楼层
哇,这是我第一次尝试帮助别人(可能是因为我觉得我有什么需要帮助的,但我承认问要有趣得多)。
 
  1. ---------------------------------------------------------------------
  2. (defun Splitter  (str md / d l str)
  3.      (while (setq d (vl-string-position md str nil T))
  4.            (setq l (cons (substr str (+ 2 d)) l)
  5.                  str (substr str 1 d)))
  6.      (cons str l)
  7. )
  8. ---------------------------------------------------------------------
  9. (defun c:csv_import (/ snp lay file opn rd point est lvl north base_pt
  10.              sno_pt rmrk_pt sno code )
  11. (setq snp(getvar "osmode"))
  12. (setq lay(getvar "clayer"))
  13. (setvar "cmdecho" 0)
  14. (setvar "osmode" 0)
  15. (command "_.UNDO" "G")
  16. -------------------------------------------------------------------
  17. (command "_.LAYER" "M" "Serial_No" "c" "1" "" "")
  18. (command "_.LAYER" "M" "Level" "c" "2" "" "")
  19. (command "_.LAYER" "M" "Remark" "c" "3" "" "")
  20. (command "_.LAYER" "M" "Point" "c" "4" "" "")
  21. -------------------------------------------------------------------
  22. (setq file(getfiled "Select File To Import" "" "csv" 4))
  23. (setq opn(open file "r"))
  24. (while
  25.    (setq rd(read-line opn))
  26.    (setq str rd)
  27.    (setq Point (Splitter str 44))
  28.    -----------------------------------------------------------------
  29.    (setq Est(atof(nth 1 point))) (setq north(atof (nth 2 point)))
  30.    (setq Lvl(atof (nth 3 point))) (setq base_pt (list est north lvl))
  31.    -----------------------------------------------------------------
  32.    (setq sno_pt(list est (+ north 0.7) lvl))
  33.    (setq rmrk_pt(list est (- north 0.7) lvl))
  34.    (setq sno(nth 0 point))
  35.    (setq Code(nth 4 point))
  36.    (command "TEXT" "J" "MC" sno_pt "0.5" "0" sno)
  37.    (Command "Change" (entlast) "" "p" "la" "Serial_No" "c" "bylayer" "")
  38.    (command "TEXT" "J" "MC" rmrk_pt "0.5" "0" code)
  39.    (Command "Change" (entlast) "" "p" "la" "Remark" "c" "bylayer" "")
  40.    (command "TEXT" "J" "MC" Base_pt "0.5" "0" (rtos lvl))
  41.    (Command "Change" (entlast) "" "p" "la" "Level" "c" "bylayer" "")
  42.    (command "point" base_pt)
  43.    (Command "Change" (entlast) "" "p" "la" "Point" "c" "bylayer" "")
  44.    
  45. );while
  46. (command "pdmode" 35)
  47. (command "pdsize" 0.5)
  48. (setvar "cmdecho" 1)
  49. (setvar "osmode" snp)
  50. (setvar "clayer" lay)
  51. (command "_.UNDO" "E")
  52. (command "Zoom" "e")
  53. (princ)
  54. );end defun

 
我有一个类似的问题,我认为这件事帮助了我。它可以修改为分割字符串的标准,我不记得细节了。
很抱歉,我不记得我把这个带到哪里了。
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-6 08:40:29 | 显示全部楼层
首先
  1. (defun LM:str->lst ( str del / pos )
  2.    (if (setq pos (vl-string-search " " str))
  3.        (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del))
  4.        (list str)
  5.    )

 
这里有一个提示
  1. 10
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
211
发表于 2022-7-6 08:45:59 | 显示全部楼层
回复

使用道具 举报

4

主题

23

帖子

19

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 08:48:14 | 显示全部楼层
 
Tank u pBe ...hmm.....Tats ok ....
 
I will  Not Feel Bad and Not Closing  My Account
 
Tanks for your support
 
 
:):):):)
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
211
发表于 2022-7-6 08:52:56 | 显示全部楼层
 
All the time. keep on coding
回复

使用道具 举报

23

主题

102

帖子

79

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
115
发表于 2022-7-6 08:55:39 | 显示全部楼层
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.
 
  1. (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.
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
211
发表于 2022-7-6 08:58:09 | 显示全部楼层
First of all
  1. (setq pos (vl-string-search [b][color=blue]del [/color][/b]str))
 
and here's a hint
  1. [b][color=blue]LM[/color][/b]:str->lst
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-9 20:49 , Processed in 0.603626 second(s), 77 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表