Luís Augusto 发表于 2022-7-6 00:11:43

 
亲爱的bhull1985,请原谅我没有看到你的评论。
本质上这就是想法。
非常感谢您对这个主题的兴趣,很抱歉之前没有回答。
如果你有任何建议或想法要补充,请随意。
 
你好,路易斯·奥古斯托。

Tharwat 发表于 2022-7-6 00:17:06

 
没关系的
 
我刚刚完成了例行工作,希望它能像你所期待的那样好用。
 
试试看,让我知道。
 

(defun c:Test (/ *error* Deconstruct_String right left con1 con2 xl ok o st l lst a b c d f fp bn p go vl name ch)
;;                  ;;
;;    Author : Tharwat Al Shoufi    ;;
;;                  ;;
(or doc (setq doc (vla-get-activedocument (vlax-get-acad-object))))
(defun *error* (u)
   (if ch
   (setvar 'CMDECHO ch)
   )
   (princ "\n*Cancel*")
)

(defun Deconstruct_String (st delimiter / p l)
   (while (setq p (vl-string-search delimiter st 0))
   (setq l(cons (substr st 1 p) l)
         st (substr st (+ p 2) (strlen st))
   )
   )
   (if st
   (setq l (cons st l))
   )
   (setq l (reverse l))
)

(if (setq xl (getfiled "Select the required Excel file :" (getvar 'DWGPREFIX) "csv" 16))
   (progn (setq ok t
                ch (getvar 'CMDECHO)
                o(open xl "r")
          )
          (setvar 'CMDECHO 0)
          (while (setq st (read-line o))
            (setq l   (cons (setq st (Deconstruct_String st ",")) l)
                  lst (cons (strcase (car st)) lst)
            )
          )
          (close o)
   )
   (setq ok nil)
)

(if (and ok
          (/= (setq bn (getstring t "\n Specify Attributed Block name to insert :")) "")
          (if (member (setq bn (strcase bn)) lst)
            t
            (progn (alert "Block name is not included in the Excel file <!>") nil)
          )
          (if (not (tblsearch "BLOCK" bn))
            (if (setq fp (findfile (strcat bn ".dwg")))
            (progn (command "_.-insert" fp nil) t)
            (progn (alert "Block Name is not found in Support Folder <!>") nil)
            )
            t
          )
   )
   (progn (setvar 'CMDECHO ch)
   (vla-StartUndoMark doc)
          (while (setq p (getpoint "\n Specify insertion point :"))
            (setq vl (vla-insertblock (vla-get-block (vla-get-activelayout doc)) (vlax-3d-point p) bn 1.0 1.0 1.0 0.))
            (foreach x (vlax-invoke vl 'getattributes)
            (foreach tg l
                (if (and (eq (car tg) (strcase bn)) (eq (strcase (vla-get-tagstring x)) (cadr tg)))
                  (vla-put-textstring x (caddr tg))
                )
            )
            )
          )
   (vla-EndUndoMark doc)
   )
)
(princ)
)
(vl-load-com)

Luís Augusto 发表于 2022-7-6 00:19:46

 
Tharwat,很抱歉延迟回复。
我的朋友做得很好。
这个节目很好,这确实是一个想法,但在我看来,有两件事会很有趣。
 
第一种方法是指向文件位置。资源管理器的Csv。
 
在我看来,第二个也是更重要的一个,不会将例程局限于某些连接器(名称)。
我认为插入块的列表应该基于读取文件的第一行。BHULL1985引用的Csv。这样,程序将变得动态。
 
感谢您的宝贵贡献。
我相信这个程序可以被很多人使用。
 
你好,路易斯·奥古斯托。

Tharwat 发表于 2022-7-6 00:23:34

嗨,路易斯。
 
很抱歉这么晚才回复,因为有几件急事,我无法及时回复您。
 
为了允许用户选择Excel文件,这很容易做到,但是块呢?
 
您计划在每个图形中插入多少块,然后向它们提供属性值/字符串?

Luís Augusto 发表于 2022-7-6 00:24:43

 
别担心塔尔瓦特。
 
块的路径将在之前通知。我将使用支持文件搜索路径,这种方式不需要由程序处理。
 
区块的数量可以从2到30不等,这取决于项目的规模。
 
我想象了如下。该程序将读取第一列并生成一个可分辨名称列表以供插入。对于每个列表项,然后输入值​​. 程序的这一部分已经运行良好。

Tharwat 发表于 2022-7-6 00:27:22

 
这是否意味着支持文件夹中有所有需要的块?并在Excel表中列为您在此之前上传的?

Tharwat 发表于 2022-7-6 00:32:09

第12号邮政编码更新
 
试试看,让我知道。

Luís Augusto 发表于 2022-7-6 00:35:41

Tharwat,节目越来越精彩了!
我能问你最后一个零钱吗?
程序能不能让我知道连接器的名称而不是手动输入?

Tharwat 发表于 2022-7-6 00:38:14

你这是什么意思?

Luís Augusto 发表于 2022-7-6 00:40:49

 
我确定你的名字了吗。
Tharwat,我写错了,对不起。
 
这里有一个建议。
 
提示:指定插入点:
然后具体。。。
下一个
 
提示:指定插入点:
然后具体。。。
下一个
 
直到它用尽可能。。。
页: 1 [2]
查看完整版本: 插入多个块