乐筑天下

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

[编程交流] 每行新图层

[复制链接]

8

主题

1133

帖子

1164

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 16:05:46 | 显示全部楼层
 
你说得对,那么我如何准确地定位那些用相同id创建的线呢?(这就是层名称)
我正在处理旧的地下历史地图。这些线表示采样器和绘图人员获取岩石样本的样本切割。这些线有单独的金和铜价值。。。具有相同ID的线是“面”样本,其中包含不同的线计数。具有单个ID的线是墙样本。但并非所有单个ID都是墙样本,还有其他只有1个ID的面样本。
这一切都在一个jpeg文件中,我必须将其数字化,并在每一行输入黄金和铜的值。
我想让这个Lisp程序,以帮助我使我的工作更快。
这是怎么回事????
如果你给了一个更好的主意,那么请我洗耳恭听!
 
单个地图可以包含80k个样本。这是我输入黄金和铜的8万行。这是80k行,我输入哪些行应该有相同的ID,哪些行应该是单。。。
如果你有更好的主意,请告诉我。。
回复

使用道具 举报

66

主题

180

帖子

119

银币

后起之秀

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

铜币
341
发表于 2022-7-5 16:11:10 | 显示全部楼层
也许张贴你的画。同时,尝试一下:
  1. (vl-load-com) (princ)
  2. ; CountWithLayer reactor thats not full-proof.
  3. (defun CountWithLayer:CB ( rtr args / o lyr f n )
  4. (cond
  5.    ( (not (and *Han* *Lyrs*)) (prompt "\n#1") )
  6.    ( (vl-catch-all-error-p (setq lyr (vl-catch-all-apply 'vla-Item (list *Lyrs* (getvar 'clayer))))) (prompt "\n#2") )
  7.    (
  8.      (not
  9.        (setq o
  10.          ( ; alternative to (entlast) with ActiveX
  11.            (lambda ( / spc r )
  12.              (setq spc (vla-get-Block (vla-get-ActiveLayout (vla-get-ActiveDocument (vlax-get-acad-object)))))
  13.              (setq r (vl-catch-all-apply 'vla-Item (list spc (1- (vlax-get-property spc 'Count)))))
  14.              (if (not (vl-catch-all-error-p r)) r)
  15.            )
  16.          )
  17.        )
  18.      ); not
  19.      (prompt "\n#3")
  20.    )
  21.    ( (not (vlax-property-available-p o 'Layer)) (prompt "\n#4") )
  22.    ( (eq o *lasto*) (prompt "\n#5") )
  23.    ; ( (not (wcmatch (vlax-get-property *lasto* 'Layer) "cnt_*")) (prompt "\n#6") ) ; not perfect
  24.    ; ( (not (eq (vlax-get-property lyr 'Name) (vlax-get-property *lasto* 'Layer))) (prompt "\n#6") )
  25.    ( (not (setq f (eval (cdr (assoc (vlr-current-reaction-name) '((:VLR-objectAppended . 1+)(:VLR-ObjectErased . 1-)(:VLR-ObjectUnerased . 1+))))))) (prompt "\n#7") )
  26.    ( (not (eq *Han* (vla-get-Handle lyr))) (prompt "\n#8") )
  27.    ( (not (eq 'INT (type (setq n (read (vl-string-left-trim "cnt_" (vlax-get-property lyr 'Name))))))) (prompt "\n#9") )
  28.    ( (not (vlax-write-enabled-p lyr)) (prompt "#10") )
  29.    ( (vl-catch-all-apply 'vlax-put-property (list lyr 'Name (strcat "cnt_" (itoa (f n))))) ) ; duplicate layer name possibility
  30. ); cond
  31. ); defun CountWithLayer:CB
  32. ( ; Note Layers that wcmatch to "cnt_*" must be erased
  33. (lambda ( rtrnm / e)
  34.    (setq *Lyrs* (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object))))
  35.    (setq *Han* (vla-get-Handle (vla-Add *Lyrs* "cnt_0")))
  36.    (and (setq e (entlast)) (setq *lasto* (vlax-ename->vla-object e)))
  37.    (setvar 'clayer "cnt_0")
  38.    (foreach rtr (cdar (vlr-reactors :VLR-AcDb-reactor)) (if (= rtrnm (vlr-data rtr)) (vlr-remove rtr)) )
  39.    (vlr-set-Notification
  40.      (vlr-AcDb-reactor rtrnm '((:VLR-objectAppended . CountWithLayer:cb)(:VLR-ObjectErased . CountWithLayer:cb)(:VLR-ObjectUnerased . CountWithLayer:cb)))
  41.      'Active-Document-Only
  42.    ); vlr-set-Notification
  43. ); lambda
  44. "MyTestReactor"
  45. )
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 16:12:36 | 显示全部楼层
第二次尝试:
  1. (defun c:foo (/ i n p1 p2 p3 s)
  2. (setq        i (cond        ((setq s (ssget "_x" '((0 . "line"))))
  3.          (1+ (apply 'max
  4.                     (mapcar '(lambda (x) (fix (atof (cdr (assoc 8 (entget x))))))
  5.                             (mapcar 'cadr (ssnamex s))
  6.                     )
  7.              )
  8.          )
  9.         )
  10.         (1)
  11.   )
  12. )
  13. (while
  14.    (progn
  15.      (setq n 0)
  16.      (while (and (or (setq p1 p3) (setq p1 (getpoint "\nSpecify first point: ")))
  17.           (setq p2 (getpoint p1 "\nSpecify next point: "))
  18.      )
  19. (setq p3 nil)
  20. (and (entmakex (list '(0 . "line")
  21.                      (cons 10 p1)
  22.                      (cons 11 p2)
  23.                      (cons 8 (itoa i))
  24.                      (cons 62
  25.                            (if (= 0 (rem i 255))
  26.                              1
  27.                              (rem i 255)
  28.                            )
  29.                      )
  30.                )
  31.      )
  32.      (setq n (1+ n))
  33.      (princ (strcat "\nLine created on layer [" (itoa i) "]"))
  34. )
  35.      )
  36.      (if
  37. (setq p3 (getpoint (strcat "\nSpecify first point for next layer [" (itoa (+ n i)) "]: ")))
  38. (setq i (+ n i))
  39.      )
  40.    )
  41. )
  42. (princ)
  43. )
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 16:16:50 | 显示全部楼层
回复

使用道具 举报

66

主题

180

帖子

119

银币

后起之秀

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

铜币
341
发表于 2022-7-5 16:20:53 | 显示全部楼层
 
 
wow! almost sir. the layer is not right...
if i made 2 lines on layer 1 the next layer should be 3, if I make 5 lines on layer 3 the next layer should be 7... and so on
 
 
 
 
here is a 2nd sample map...
this is the first lisp i made. you will see that the layer is individual...
it sould be like the blue texts i put.. my layer name is supposed to be 0, 2, 5, 12, 16, 20, 21, 23......
thus i tried asking for help... because i know you guys could come up a better solution than i can.
EL1020.dwg
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 16:23:53 | 显示全部楼层
Not sure if I made a mistake but I drew multiple lines on one layer then incremented.
 
Oh just found bug need to put numero+1 in a different spot I create 2 5  9 12 etc
 
Yeah I am 12 hours out of sync but would appreciate any comments.
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 16:26:21 | 显示全部楼层
I updated the code above. Give it a try.
回复

使用道具 举报

66

主题

180

帖子

119

银币

后起之秀

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

铜币
341
发表于 2022-7-5 16:31:30 | 显示全部楼层
 
 
Thank you sir ill try to use this for polylines!  thank you so much!
 
 
wow this is what my problem was.. thank you you solved it  i will try to use this for my routine
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 16:34:25 | 显示全部楼层
Glad to help out  .. BTW you should copy the code above again .. had an error.
 
  1.   (setq        i (cond        ([color="red"](mapcar 'cadr (ssnamex (setq s (ssget "_x" '((0 . "line"))))))[/color] This will bomb if no selection is found.         (1+ (apply 'max                    (mapcar '(lambda (x) (fix (atof (cdr (assoc 8 (entget x))))))                            (mapcar 'cadr (ssnamex s))                    )             )         )        )        (1)  ) )
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-14 23:32 , Processed in 2.155326 second(s), 68 queries .

© 2020-2025 乐筑天下

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