【问题标题】:Extract data from a table object using autolisp使用 autolisp 从表对象中提取数据
【发布时间】:2017-06-08 16:35:01
【问题描述】:

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

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

所以在本例中,将是 132156432 y 11 存储在三个不同变量或数组中的数字。请帮助我并逐步向我解释可能的解决方案,我对 Lisp 真的很陌生

【问题讨论】:

    标签: lisp cell autocad autolisp


    【解决方案1】:

    首先你需要得到桌子。您可以要求用户选择一个,例如:

    (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)
    

    【讨论】:

      猜你喜欢
      • 2020-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-01
      • 1970-01-01
      相关资源
      最近更新 更多