【问题标题】:How to print values in Autolisp?如何在 Autolisp 中打印值?
【发布时间】:2021-08-23 10:34:46
【问题描述】:

我正在 AutoCAD 中编写我的简单脚本来选择一个表并检索表中的一些数据并在控制台中打印它。

(defun C:test (/)
    (vl-load-com) 
    (setvar "CTAB" "Model")
(princ "\n*** Pick a table ***")
  (if (setq ss (ssget "_:S:E:L" '((0 . "ACAD_TABLE"))))
      (setq table (vlax-ename->vla-object (ssname ss 0)))
    )       
        
(setq  table_rows (vla-get-rows table)
       table_width (vla-get-width table)
 )  
    
(prinс (strcat "Num of rows is" table_rows ", table width is " table_width))
)

运行此脚本并在 Autocad 中选择一个包含 57 行的表后,它返回一个错误:

参数类型错误:stringp 57

我该如何解决?

【问题讨论】:

    标签: autolisp


    【解决方案1】:

    strcat 需要字符串参数。在您的情况下,table_rows 是整数,table_width 看起来像真实的。所以你需要通过itoartos

    试试这个:

    (prinс (strcat "Num of rows is" (itoa table_rows) ", table width is " (rtos table_width)))
    

    【讨论】:

      猜你喜欢
      • 2017-11-06
      • 2015-01-08
      • 2021-12-04
      • 2011-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-29
      相关资源
      最近更新 更多