乐筑天下

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

[编程交流] Lisp: how to select all circle

[复制链接]

2

主题

14

帖子

12

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 23:03:03 | 显示全部楼层 |阅读模式
I'd like to know a code in LISP for selecting all circles inside a polygon I made and center them in the centre of the same polygon.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 23:10:39 | 显示全部楼层
Try this and let me know .
 
  1. (defun c:Test (/ s sn l i d lst p a b j k ss) ;;    Tharwat 15. may. 2014        ;; (princ "\n Select a 2Dpolyline ...") (if (setq s (ssget "_+.:S:E" '((0 . "LWPOLYLINE"))))   (progn (setq l (vlax-curve-getdistatparam (setq sn (ssname s 0)) (fix (vlax-curve-getendparam sn)))                i (/ l 1000.)                d i          )          (repeat 1000            (setq lst (cons (vlax-curve-getpointatdist sn i) lst)                  i   (+ i d)            )          )          (setq p (mapcar 'cdr (vl-remove-if-not '(lambda (x) (eq (car x) 10)) (entget sn)))                a (mapcar 'car p)                b (mapcar 'cadr p)                j (/ (apply '+ a) (length a))                k (/ (apply '+ b) (length b))          )          (if (setq ss (ssget "_CP" lst '((0 . "CIRCLE"))))            ((lambda (x / n e)               (while (setq n (ssname ss (setq x (1+ x))))                 (if (vlax-write-enabled-p (vlax-ename->vla-object n))                   (entmod (subst (cons 10 (list j k 0.)) (assoc 10 (setq e (entget n))) e))                 )               )             )              -1            )          )   ) ) (princ))(vl-load-com)
回复

使用道具 举报

2

主题

14

帖子

12

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 23:16:04 | 显示全部楼层
works great thank you but can you write after each code line what you did there so i can understand it?
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 23:17:41 | 显示全部楼层
You're welcome .
 
It is hard to explain everything in the routine but if you have any specific question , I can explain it for you .
回复

使用道具 举报

2

主题

14

帖子

12

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 23:22:16 | 显示全部楼层
Well i cant really understand much, i was thinking to say like
 
: here you check if the centre of circle is in polygon
; here you move the centre to the centre of polygon ...
 
a few comentaries would make the understanding of the code way more easy
回复

使用道具 举报

2

主题

14

帖子

12

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 23:27:29 | 显示全部楼层
also the meaning of each charater: s sn l i d lst p a b j k ss
What are they
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 23:34:43 | 显示全部楼层
Okay ,
 
First we select a polyline then write the codes to make a list of point along the selected polyline so after that we can a selection set with the help with these point to select only circle as shown in the feed code for the ssget function , so if circles found we get the centeriod point of the polyline then update the center of each circle to that point .
 
That's it
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 23:39:37 | 显示全部楼层
These called local variables .
回复

使用道具 举报

2

主题

14

帖子

12

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 23:42:58 | 显示全部楼层
yeah i'd like to know which each local variable means....
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-5 23:47:23 | 显示全部楼层
 
Read THIS about variables .
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-11 03:31 , Processed in 0.626925 second(s), 72 queries .

© 2020-2025 乐筑天下

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