乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 83|回复: 3

[编程交流] 如何在中打印变量

[复制链接]

4

主题

12

帖子

8

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-5 17:34:19 | 显示全部楼层 |阅读模式
我将选择一条三维多段线。
  1. (defun c:coord ( / e r)
  2.        (prompt "\nchoose a onject!")
  3. (setq e (entget (car (entsel))))
  4. (setq r 1)
  5.        (setq count 0)
  6. (while r
  7.    (setq e (entget (entnext (cdr (car e)))))
  8.    
  9.    (if (/= (cdr (assoc 0 e)) "SEQEND")
  10.    
  11.         (progn
  12.        
  13.           (terpri)
  14.           
  15.           (princ (cdr (assoc 10 e)))
  16.           ;print the co-ordinates
  17.           (setq count(1+ count))
  18.         )
  19.         (setq r nil)
  20.        
  21.    )
  22.         )
  23. (prompt "\nThere are total " );In here how to print "There are total (count ;number) vertexes in this object."  
  24. (princ)
  25. );defun
  26. (princ)

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

使用道具 举报

BKT

1

主题

124

帖子

123

银币

初来乍到

Rank: 1

铜币
7
发表于 2022-7-5 18:03:31 | 显示全部楼层
将提示代码更改为:
 
  1. (prompt (strcat "\nThere are total " (itoa count) " vertices in this object"))
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
325
发表于 2022-7-5 18:32:18 | 显示全部楼层
或者:
  1. (princ "\nThere are total ") (print (itoa count)) (princ " vertices in this object.")

但我通常使用BKT的例子。
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 18:42:17 | 显示全部楼层
查看以下MOD:
  1. (defun c:3dCoords  (/ i s e)
  2. (if (and (setq i 0 s (car (entsel "\nPick on 3Dpolyline :")))
  3.           (member '(100 . "AcDb3dPolyline") (entget s))
  4.           )
  5. (while (/= (cdr (assoc 0 (setq e (entget (setq s (entnext s)))))) "SEQEND")
  6.        (terpri)
  7.        (princ (cdr (assoc 10 e)))
  8.        (setq i (1+ i))
  9.      )      
  10.    )
  11. (and (< 0 i) (princ (strcat "\nThere are total [ " (itoa i) " ] vertices in this object")))
  12. (princ)
  13. )
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-13 05:37 , Processed in 0.665264 second(s), 71 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表