我想从存储在绘图表或表对象中的信息的比较中提取某些信息,如您更喜欢这样调用它,如果比较成功,则将相关值存储到变量中。我是 Visual lisp 或 Auto Lisp 的新手。所以请你帮我解决这个问题,并逐步解释我。
因此,例如,如果我的表在第一列 D1 中,我想将信息存储在它旁边的接下来的三列中,但在同一行中。
所以在这个例子中,它将是132156、432 y 11 存储在三个不同变量或数组中的数字。请帮助我并逐步向我解释可能的解决方案,我真的是 Lisp 的新手
最佳答案
首先你需要得到表。您可以要求用户选择一个,例如这样:
(setq table (vlax-ename->vla-object (car (entsel ))) )
如果用户不想选择 ,您应该记得捕获错误。 此外,您应该检查用户选择的表是否不是其他实体。但现在让我们想象一下用户选择表 所以现在你可以试试这个
(setq columns (vlax-get-property table 'Columns))
(setq rows (vlax-get-property table 'rows))
(setq row 1 ) ; 0 is header
(repeat rows
(setq vals nil)
(setq column 0)
(setq txtval (vlax-invoke-method table 'GetText row column ))
; now we have value from first cell in row.
; and now You can go at least two ways.
; 1 check value and make Your analyse, read values from other columns or anything You need
; 2 build array of all values from all cells and after that analyse only array of texts (remove dependency from object table)
; for this sample I choose 1 way.
(if (= txtval "D1") (progn
(repeat 3 ; because You "want to store the information in the next three columns"
(setq column (1+ column))
(setq vals ( append vals (list (vlax-invoke-method table 'GetText row column ))))
)
))
(if (not (null vals )) (progn
(setq arrayOfVals (append arrayOfVals (list vals)))
))
(setq row (1+ row ))
)
(print arrayOfVals)
关于lisp - 使用 autolisp 从表对象中提取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41818685/