乐筑天下

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

[编程交流] Cary Hulse项目

[复制链接]

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 11:52:26 | 显示全部楼层 |阅读模式
感谢大家对我的积分经理计划Cary的兴趣,我意识到它并不能完全满足您的需求,所以希望这能满足您的需求
 
新年快乐!
 
回复

使用道具 举报

33

主题

267

帖子

213

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
197
发表于 2022-7-6 11:56:42 | 显示全部楼层
李,太棒了,谢谢!
我今天要玩它(回去工作)
我正在重新构建我的主模板,所以它来得正是时候
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 12:00:17 | 显示全部楼层
嗯,我忍不住。。。
 
让我知道你进展如何!
回复

使用道具 举报

33

主题

267

帖子

213

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
197
发表于 2022-7-6 12:02:35 | 显示全部楼层
如果你有时间的话,我可以请你像上次那样给我评论一下吗?
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 12:06:41 | 显示全部楼层
这就是我的全部时间:
 
  1. (defun c:attpop (/ *error* StrBrk                 
  2.                   ALST ATT BNME DDEL DOC FILE LST NL OBJ OFILE PT SPC UFLAG X Y )
  3. ;; by Lee Mac ~ 01.01.10
  4. ;; --{ Commented Version }--
  5. (vl-load-com) ;; Load Visual LISP Console
  6. ;; --{  Error Handler Function  }--
  7. (defun *error* (msg)  ;; Localised with variables
  8.    
  9.    (and ofile (close ofile)) ;; If ofile still non-nil, close the open file
  10.    
  11.    (and uflag (vla-EndUndoMark doc))  ;; If uflag still non-nil, End the Undo Mark.
  12.    
  13.    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")  ;; Suppress Cancel messages
  14.       
  15.        (princ (strcat "\n** Error: " msg " **"))) ;; Print fatal errors
  16.    
  17.    (princ))
  18. ;; -----------------------------------------------
  19. ;; --{  StrBrk Function  }--
  20. ;; By Lee Mac  ~  Used to break a string into a list of elements,
  21. ;;                using a delimiter.
  22. (defun StrBrk (str chrc / pos lst)
  23.    (while (setq pos (vl-string-position chrc str))
  24.      (setq lst (cons (substr str 1 pos) lst)
  25.            str (substr str (+ pos 2))))
  26.    (reverse (cons str lst)))
  27. ;; -----------------------------------------------
  28. (if (and
  29.        ;; Block selection
  30.        (setq bNme (getfiled "Select Block to Insert" (cond (*block_file*) ("")) "dwg"     16))
  31.        ;; Data File Selection
  32.        (setq file (getfiled "Select Input File"      (cond (*load_file*)  ("")) "txt;csv" 16)))
  33.    
  34.    (progn
  35.      ;; Start the Undo Mark before we proceed uflag = T
  36.      
  37.      (setq uflag (not (vla-StartUndoMark
  38.                         (setq doc (vla-get-ActiveDocument
  39.                                     (vlax-get-acad-object)))))
  40.            ;; Get the Active Space
  41.            spc (if (zerop (vla-get-activespace doc))
  42.                  (if (= (vla-get-mspace doc) :vlax-true)
  43.                    (vla-get-modelspace doc)
  44.                    (vla-get-paperspace doc))
  45.                  (vla-get-modelspace doc)))
  46.      ;; Get the correct delimiter, if CSV, comma, else space.
  47.      
  48.      (setq dDel (if (eq ".CSV" (vl-filename-extension file)) 44 32)
  49.            ;; Save the defaults for next time, and open the file, ofile = non-nil
  50.            
  51.            *block_file* bNme *load_file* file ofile (open file "r"))
  52.      ;; Read the file and break the strings
  53.      (while (setq nl (read-line ofile))
  54.        (setq lst (cons (StrBrk nl dDel) lst)))
  55.      ;; Close the file, ofile = nil  and reverse the lst.
  56.      
  57.      (setq ofile (close ofile) lst (reverse lst))
  58.      ;; While there are attribs in the list, AND the user has clicked a point
  59.      (while (and (setq x  (car lst))
  60.                  (setq pt (getpoint "\nSpecify Point for Block: ")))
  61.        ;; Catch any errors that occur when inserting the block
  62.       
  63.        (if (vl-catch-all-error-p
  64.              (setq obj
  65.                (vl-catch-all-apply (function vla-InsertBlock)
  66.                  (list spc (vlax-3D-point pt) bNme 1. 1. 1. 0.))))
  67.          
  68.          (princ "\n** Error Inserting Block **")
  69.          ;; Else populate the Attribs using the values in the list.
  70.          (progn
  71.            ;; Get a list of VLA-objects (attribs)
  72.            (setq aLst (vlax-invoke obj 'GetAttributes))
  73.            ;; While there is an attrib and value
  74.            (while (and (setq y   (car x))
  75.                        (setq att (car aLst)))
  76.             
  77.              ;; Populate the attribs
  78.              (vla-put-TextString att y)
  79.              (setq x (cdr x) aLst (cdr aLst)))))
  80.        ;; Move onto next item
  81.        (setq lst (cdr lst)))
  82.      ;; End the Undo Mark,  uFlag = nil
  83.      (setq uFlag (vla-EndUndoMark doc))))
  84. ;; Clean exit
  85. (princ))

 
希望这有点帮助。
回复

使用道具 举报

33

主题

267

帖子

213

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
197
发表于 2022-7-6 12:09:19 | 显示全部楼层
我相信会的,谢谢!
回复

使用道具 举报

33

主题

267

帖子

213

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
197
发表于 2022-7-6 12:14:17 | 显示全部楼层
好的,你激励了我,让我更进一步。我找到了一些用于填充动态属性的函数,我正在尝试将它们添加到您的代码中。这对我来说是一个很好的开始,我自己都做不到。
 
不过,首先,我已经更改了您的代码,使其不需要块,而只需要使用我需要的块(它始终是相同的)。
 
我的问题是:我的块只有一个属性,但有3个动态(线性)属性。目前,当我添加块时,它用列表中由逗号分隔的所有值填充one属性。这是它的初衷吗?
我想尝试的是将该列表分解为只获取一个属性的第一个值,然后将剩余值用于其他函数?
 
我将张贴我在这里有一点。。。
再次感谢您的大力帮助!
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 12:16:09 | 显示全部楼层
 
沃泽。。。谢谢你注意我的打字错误!比较文件扩展名时缺少strcase。我已经更新了第一个帖子。
 
我会尽我所能帮助Cary,但我警告你,我没有使用动态块的经验。。。
回复

使用道具 举报

33

主题

267

帖子

213

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
197
发表于 2022-7-6 12:19:56 | 显示全部楼层
好吧,我想我有点进展了。。。
 
你能帮我确保我理解这个过程/把事情按正确的顺序安排好吗?
我想这就是我遇到的问题。。。
完整代码随附。
 
  1. (progn
  2.            ;; Get a list of VLA-objects (attribs)
  3.            (setq aLst (vlax-invoke obj 'GetAttributes)) ;;Can I assign this to the attribute tag "TREE#"?
  4.            ;; While there is an attrib and value
  5.            (while (and (setq TRNUM   (car x))
  6.                        (setq att (car aLst))
  7.   ;;;set variables for dynamic values, not sure if this is in the correct place?
  8.   (setq CANOP (cadr x))
  9.   (setq CRZ (caddr x))
  10.   (setq CRD (cadddr x))
  11. );end and
  12.             
  13.              ;; Populate the attribs
  14.              (vla-put-TextString att TRNUM)
  15.              ;;(setq x (cdr x) aLst (cdr aLst));;;edited by CH - only one attribute in block
  16.       
  17. ;;;Set Dynamic Properties using "myModifyBk" function
  18. (myModifyBk (list "CRD Radius" CRD))
  19. (myModifyBk (list "CRZ Radius" CRZ))
  20. (myModifyBk (list "Canopy Radius" CANOP))
  21.      
  22. );end while
  23. );end progn

树lsp
回复

使用道具 举报

33

主题

267

帖子

213

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
197
发表于 2022-7-6 12:22:38 | 显示全部楼层
我会在这里更改什么(假设这是正确的位置)以在对话框中默认为CSV?
 
  1. (setq file (getfiled "Select Input File"      (cond (*load_file*)  ("")) "txt;csv" 16)))
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-5 10:25 , Processed in 0.673189 second(s), 72 queries .

© 2020-2025 乐筑天下

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