lisp - 使用 autolisp 从表对象中提取数据

标签 lisp cell autocad autolisp

我想从存储在绘图表或表对象中的信息的比较中提取某些信息,如您更喜欢这样调用它,如果比较成功,则将相关值存储到变量中。我是 Visual lisp 或 Auto Lisp 的新手。所以请你帮我解决这个问题,并逐步解释我。

Example of table

因此,例如,如果我的表在第一列 D1 中,我想将信息存储在它旁边的接下来的三列中,但在同一行中。

enter image description here

所以在这个例子中,它将是132156432 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/

相关文章:

lisp - CLISP Lambda 微积分 Div 实现

ios - 错误-swift-Tableview-自定义单元格

css - 当 Firefox 4 报告表格单元格的 offsetWidth 不一致时的解决方法是什么

git - 我可以将 git 与 .dwg (autocad) 一起使用吗?

vb.net - 如何以编程方式编辑 AutoCAD PC3 文件

lisp - 读取宏 : what do you use them for?

performance - CLOS make-instance 真的很慢,导致 SBCL 中的堆耗尽

python - 使用ezdxf描述图层属性描述时出现错误

functional-programming - Common Lisp 中的 (compose)

ios - UITableViewAutomaticDimension 不适用于自定义表格单元格