Wwx95 发表于 2022-7-5 17:34:19

如何在中打印变量

我将选择一条三维多段线。
(defun c:coord ( / e r)
       (prompt "\nchoose a onject!")
(setq e (entget (car (entsel))))


(setq r 1)

       (setq count 0)
(while r


   (setq e (entget (entnext (cdr (car e)))))
   

   (if (/= (cdr (assoc 0 e)) "SEQEND")
   

        (progn
       

          (terpri)
          

          (princ (cdr (assoc 10 e)))
          ;print the co-ordinates
          (setq count(1+ count))
        )

      (setq r nil)
       

   )

        )
(prompt "\nThere are total " );In here how to print "There are total (count ;number) vertexes in this object."

(princ)

);defun

(princ)
 
我表达清楚吗??我想把变量“count”放在提示符中,例如,我得到的计数等于4,我想做的是在屏幕上打印:“这个对象中总共有4个顶点。“有可能吗?谢谢。

BKT 发表于 2022-7-5 18:03:31

将提示代码更改为:
 

(prompt (strcat "\nThere are total " (itoa count) " vertices in this object"))

Grrr 发表于 2022-7-5 18:32:18

或者:
(princ "\nThere are total ") (print (itoa count)) (princ " vertices in this object.")
但我通常使用BKT的例子。

Tharwat 发表于 2022-7-5 18:42:17

查看以下MOD:

(defun c:3dCoords(/ i s e)
(if (and (setq i 0 s (car (entsel "\nPick on 3Dpolyline :")))
          (member '(100 . "AcDb3dPolyline") (entget s))
          )
(while (/= (cdr (assoc 0 (setq e (entget (setq s (entnext s)))))) "SEQEND")
       (terpri)
       (princ (cdr (assoc 10 e)))
       (setq i (1+ i))
   )      
   )
(and (< 0 i) (princ (strcat "\nThere are total [ " (itoa i) " ] vertices in this object")))
(princ)
)
页: [1]
查看完整版本: 如何在中打印变量