乐筑天下

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

[编程交流] 从E更新块属性

[复制链接]

95

主题

477

帖子

383

银币

后起之秀

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

铜币
475
发表于 2022-7-5 16:40:00 | 显示全部楼层 |阅读模式
因此,我试图基于一个包含四列的csv文件更新一个块(名为DRN-BASIN)。第一列有盆地编号,接下来是英亩,接下来是CO-EF,接下来是CO-EF-2。我需要根据块的相应盆地编号属性更新图形中的块。块的所有属性都对应于Excel csv文件中的一列。我应该从哪里开始迭代块并找到每个块属性?
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:12:15 | 显示全部楼层
第一李mac有一个csv到一个“列表”为每一行,所以你得到4个值。
 
这里的许多块示例都是从ssget开始的(2.Blockname)
 
只需搜索选择集并使用标记名检查属性TEXTSTRING,如果是,则更新属性。
 
这需要更新多个标记
  1. ; update the COGG title blocks in a dwg
  2. ; change the 410 to layout name
  3. ;;-------------------=={ Parse Numbers }==--------------------;;
  4. ;;                                                            ;;
  5. ;;  Parses a list of numerical values from a supplied string. ;;
  6. ;;------------------------------------------------------------;;
  7. ;;  Author: Lee Mac, Copyright © 2011 - [url="http://www.lee-mac.com"]www.lee-mac.com[/url]       ;;
  8. ;;------------------------------------------------------------;;
  9. ;;  Arguments:                                                ;;
  10. ;;  s - String to process                                     ;;
  11. ;;------------------------------------------------------------;;
  12. ;;  Returns:  List of numerical values found in string.       ;;
  13. ;;------------------------------------------------------------;;
  14. (defun LM:ParseNumbers ( s )
  15. (
  16.    (lambda ( l )
  17.      (read
  18.        (strcat "("
  19.          (vl-list->string
  20.            (mapcar
  21.              (function
  22.                (lambda ( a b c )
  23.                  (if
  24.                    (or
  25.                      (< 47 b 58)
  26.                      (and (= 45 b) (< 47 c 58) (not (< 47 a 58)))
  27.                      (and (= 46 b) (< 47 a 58) (< 47 c 58))
  28.                    )
  29.                    b 32
  30.                  )
  31.                )
  32.              )
  33.              (cons nil l) l (append (cdr l) (list nil))
  34.            )
  35.          )
  36.          ")"
  37.        )
  38.      )
  39.    )
  40.    (vl-string->list s)
  41. )
  42. )
  43. (defun ah:sheetupdate1 ( / ss1 len lay plotabs tabname dwgname oldtag1 oldtag2 oldtag3 oldtag4 oldtag5)
  44. (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  45. (vlax-for lay (vla-get-Layouts doc)
  46. (setq plotabs (cons (vla-get-name lay) plotabs))
  47. )
  48. (IF (NOT AH:getval3)(LOAD "GETVALS"))
  49. (AH:getval3 "Please enter dwg number" 12 9
  50. "Please enter version for all sheets <Cr> no change" 8 5
  51. "Please enter line1 details " 40 38
  52. )
  53. (setq dwgname VAL1)
  54. (setq newstr4 VAL2)
  55. (SETQ NEWSTR6 VAL3)
  56. (princ "0")
  57. (setq len (length plotabs))
  58. (setq x 0)
  59. (setq bname "DA1DRTXT")
  60. (repeat len
  61. (setq tabname (nth x plotabs))
  62. (if (/= tabname "Model")
  63.    (progn
  64.      (setvar "ctab" tabname)
  65.      (command "pspace")
  66.      (setq ss1 (ssget "x"  (list (cons 0 "INSERT") (cons 2 bname)(cons 410 tabname))))
  67.      (setq dwgnum (Lm:parsenumbers tabname))
  68.      (setq sheetnum (car dwgnum))
  69.      (setq oldtag1 "SHT_NO") ;attribute tag name
  70.      (setq newstr1 (rtos sheetnum 2 0))
  71.      (setq oldtag2 "DRG_NO") ;attribute tag name
  72.      (setq oldtag3 "PROJ_NO") ;attribute tag name
  73.      (setq newstr3 dwgname)
  74.      (setq oldtag4 "REV_NO") ;attribute tag name
  75.      (setq oldtag5 "SHEETS") ;attribute tag name
  76.      (setq oldtag6 "STREET") ;attribute tag name
  77. ; if less than 10
  78. (if (< (car dwgnum) 10.0)
  79.      (setq newstr2 (strcat dwgname "-D0"  (rtos sheetnum 2 0)))
  80.      (setq newstr2 (strcat dwgname "-D"  (rtos sheetnum 2 0)))
  81. )
  82.      (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 0 )) 'getattributes)
  83.        (if (= oldtag1 (strcase (vla-get-tagstring att)))
  84.        (vla-put-textstring att newstr1)
  85.        ) ; end if
  86.        (if (= oldtag2 (strcase (vla-get-tagstring att)))
  87.        (vla-put-textstring att newstr2)
  88.        ) ; end if
  89.        (if (= oldtag3 (strcase (vla-get-tagstring att)))
  90.        (vla-put-textstring att newstr3)
  91.        ) ; end if
  92.        (if (and (/= newstr4 nil) (= oldtag4 (strcase (vla-get-tagstring att))) )
  93.        (vla-put-textstring att newstr4)
  94.        ) ; end if
  95.        (if (= oldtag5 (strcase (vla-get-tagstring att)))
  96.        (vla-put-textstring att (rtos (- len 1) 2 0))
  97.        ) ; end if
  98. (if (= oldtag6 (strcase (vla-get-tagstring att)))
  99.        (vla-put-textstring att newstr6)
  100.        ) ; end if
  101.       ) ; end foreach
  102.    ) ; end progn
  103. ) ; end if
  104. (setq x (+ x 1))
  105. ) ; end repeat
  106. (setq ss1 nil)  
  107. ) ; end defun ah
  108. (ah:sheetupdate1)
  109. (princ)
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 17:52:59 | 显示全部楼层
差点忘了如果你想删除生成csv的步骤,可以直接从excel中删除。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 13:51 , Processed in 0.551156 second(s), 58 queries .

© 2020-2025 乐筑天下

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