Lee Mac 发表于 2022-7-5 17:44:10

在不测试代码的情况下,我怀疑出现错误的原因是其中一个属性值为null,因为在将foreach循环推送到主数据列表之前,在评估foreach循环之后,没有测试包含每个属性值的变量的有效性:
测试该理论的一种简单方法是在评估外部vlax for循环后打印attdata的值。

marko_ribar 发表于 2022-7-5 17:47:50

 
 
正确,其中一个块属性名称与foreach循环中的名称不对应。
 
 
谢谢你的帮助。

Tharwat 发表于 2022-7-5 17:52:27

不客气!

Spaj 发表于 2022-7-5 17:54:07

Spaj 发表于 2022-7-5 17:56:47

Hi Marko
 
Thanks for the input, but that did not seem to work. The routine does not recognize the specified blocks.

Lee Mac 发表于 2022-7-5 18:01:20

 
Table names (i.e. layers, blocks, linetypes etc.) which contain the pipe character are xref-dependent items, with the content to the left of the pipe equal to the name of the xref from which they are derived.
 
 
Can you post your current modified code?

Spaj 发表于 2022-7-5 18:04:35

 
Aha, helps if you understand these nuances.
 
 
Sure...
 
CList_Duct.LSP

Lee Mac 发表于 2022-7-5 18:06:52

Without testing the code, I suspect that the error arises because one of the attribute values is null, as the variables holding each attribute value are not tested for validity following evaluation of the foreach loop before being pushed onto the main data list:
(progn         (setq atts (vlax-invoke x 'getattributes))       (foreach att atts             (cond ((wcmatch (vla-get-tagstring att) "DUCT_START")                  (setq a1 (vla-get-textstring att))            ;(setq coordStart (vlax-get att insertionpoint))                   )                   ((wcmatch (vla-get-tagstring att) "DUCT_END")                  (setq a2 (vla-get-textstring att))                  ;(setq coordEnd (vlax-get att insertionpoint))                   )                   ((wcmatch (vla-get-tagstring att) "DUCT_TYPE")                  (setq a3 (vla-get-textstring att))                   )             ) ;end Cond         ) ; end ForEach         (setq attdata (cons (list a1 a2 a3) attdata))         )An easy way to test this theory is to print the value of attdata after evaluation of the outer vlax-for loop.

Spaj 发表于 2022-7-5 18:10:03

 
 
Correct, one of the block attribute names did not correspond with the name in the foreach loop.   
 
 
Thank you kindly for the help.

Lee Mac 发表于 2022-7-5 18:13:40

You're welcome!
页: 1 [2]
查看完整版本: 动态块提取到表