乐筑天下

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

[编程交流] Carriage return in lisp-create

[复制链接]

12

主题

25

帖子

13

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-5 18:39:02 | 显示全部楼层 |阅读模式
Hello,
 
I have the following lisp which displays the coordinates of a selected point with a leader:
 
  1. (defun c:xy ()(setq pt (getpoint " Pick Point: "))(setq x (rtos (car pt)))(setq y (rtos (cadr pt)));(setq z (rtos (caddr pt)))(setq ptcoord (strcat x "mE, " y "mN"))(command "QLEADER" pt pause "" "" ptcoord ""))
 
This give me:
 
"123.45mE, 678.90mN"
 
But I would like:
 
"123.45mE
678.90mN"
 
How do I amend the strcat line so it uses a carriage return?
 
Thanks,
 
Rob
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 18:42:28 | 显示全部楼层
  1. (setq ptcoord (strcat x "mE, \n" y "mN"))
回复

使用道具 举报

12

主题

25

帖子

13

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-5 18:48:03 | 显示全部楼层
Thank you!
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 18:50:36 | 显示全部楼层
 
You're welcome .
 
A few modification if you'd like .
 
  1. (defun c:xy (/ pt) (while (setq pt (getpoint "\n Pick Point : "))   (command "_.QLEADER" "_none" pt "_none" pause "" ""            (strcat (rtos (car pt)) "mE, \n" (rtos (cadr pt)) "mN") "") ) (princ))
回复

使用道具 举报

12

主题

25

帖子

13

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-5 18:54:20 | 显示全部楼层
I'd like very much, thanks again.
 
Is there any way to make the text in the Mtext right-justified when it is created or would I have to do that manually?
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 18:58:06 | 显示全部楼层
 
Does it mean that you always place the text on the left hand side ?
 
Cause if you place the text on the right side hand with right-justified property of the Mtext , you'd have irregular shape of the Leader .
回复

使用道具 举报

12

主题

25

帖子

13

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
65
发表于 2022-7-5 18:59:03 | 显示全部楼层
I have been using the xy routine above (post 4) with great success, thank you Tharwat.
 
Would somebody be kind enough to help me to enhance this routine?
 
I would like to be able to have it so that it gives the coordinates of the currently selected UCS but creates the text square to the world system.  Is this possible?
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 19:03:21 | 显示全部楼层
 
Happy to hear that .
 
 
Can you give an example ( or a drawing ) ?
回复

使用道具 举报

1

主题

116

帖子

115

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 19:07:14 | 显示全部楼层
This is a little lazy of me, but I need to get to bed . There are better ways, perhaps Tharwat might help you with one of them.
 
This takes advantage of the fact that a QLEADER is made up of two entities and the MTEXT is created last.
  1. (defun c:xy ( / el pt rot ) (setq rot (cons 50 (- (apply 'atan (cdr (reverse (getvar "UCSXDIR"))))))) (while (setq pt (getpoint "\n Pick Point : "))   (command "_.QLEADER" "_none" pt "_none" pause "" ""            (strcat (rtos (car pt)) "mE, [url="file://\\P"]\\P[/url]" (rtos (cadr pt)) "mN") "")   (entmod (subst rot (assoc 50 (setq el (entget (entlast)))) el))   ) (princ) )
 
Oh, and I did change the "\n" to "\\P" in the string. Change it back if you want. It just seems to me that most (not all) of the functions floating around the web that extract formatting strings remember "\\P" and forget "\n".
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-5 19:09:50 | 显示全部楼层
 
That's because \n will yield a soft return (shift + enter), whereas \\P is an actual hard carriage return.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 13:33 , Processed in 0.594803 second(s), 72 queries .

© 2020-2025 乐筑天下

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