乐筑天下

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

[编程交流] points,lines,polylines,splines

[复制链接]

18

主题

99

帖子

91

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
84
发表于 2022-7-5 16:10:06 | 显示全部楼层 |阅读模式
Hello.
Does anyone have a routine that would round the coordinates of selected points,lines,polylines and splines to 2 decimal places(not just cut the rest of decimal places but ROUND it, so .384=.38 and .385=.39) and move them to that coordinates.That applies to height also. In case of polys and splines the vertices should also be rounded... thanx
回复

使用道具 举报

49

主题

177

帖子

130

银币

后起之秀

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

铜币
243
发表于 2022-7-5 16:29:27 | 显示全部楼层
You can parse through your entities one by one with a while loop and use the following syntax
 
  1. (atof (rtos 0.384 2 2))
 
An example for lines and points would be as follows. You will need to elaborate a bit for other kinds of entities but the principle is the same.
 
  1. (defun fixl (/ round_decimals ss cnt pt10 pt11 lndt)(setq round_decimals 6)(if (setq ss (ssget "_A" '((-4 . ""))))        (progn                (setq cnt (sslength ss))                (while (>= (setq cnt (1- cnt)) 0)                        (setq lndt (entget (ssname ss cnt)))                        (setq pt10 (mapcar 'atof (mapcar '(lambda (x) (rtos x 2 round_decimals)) (cdr (assoc 10 lndt)))))                        (setq lndt (subst (cons 10 pt10) (assoc 10 lndt) lndt))                        (entmod lndt)                                                (if (assoc 11 lndt)                                ; this condition is used for lines                                (progn                                        (setq pt11 (mapcar 'atof (mapcar '(lambda (x) (rtos x 2 round_decimals)) (cdr (assoc 11 lndt)))))                                        (setq lndt (subst (cons 11 pt11) (assoc 11 lndt) lndt))                                        (entmod lndt)                                )                        )                )        )))
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 16:37:28 | 显示全部楼层
I posted an example here some time ago:
https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-of-line-and-pline-vertices/m-p/4396563#M314796
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

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

铜币
325
发表于 2022-7-5 16:46:44 | 显示全部楼层
 
Awesome routine, Lee!
I've found that thread some time ago, but then I lost it and couldn't find it again, thanks for reposting it !
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 17:06:56 | 显示全部楼层
Thanks!
回复

使用道具 举报

18

主题

99

帖子

91

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
84
发表于 2022-7-5 17:20:47 | 显示全部楼层
thank you all for your help  , I guess I'll try to implement rounding for splines too, if that's possible...
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 19:50 , Processed in 0.425819 second(s), 75 queries .

© 2020-2025 乐筑天下

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