乐筑天下

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

[编程交流] Select within Polyline Lisp -

[复制链接]

2

主题

4

帖子

2

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 22:18:48 | 显示全部楼层 |阅读模式
Morning All,
 
I realise this has been covered in various forms before - but I think the fact I am working on a Mac does change it a bit as it seems I can't support any Visual Lisp files.
 
Basically I am trying to select all the objects (in this case Polylines representing chairs) within a larger polyline. The end game after all these items are selected would be to move them to a different later, change their colour etc.
 
I found this Lisp file which I can load and works perfectly...up the point where i need to end the command - which I am trying to do by pressing enter.
 
http://www.cadforum.cz/cadforum_en/qaID.asp?tip=5697
 
I know pretty much nothing about LISP except how to load it...and that my options in Mac CAD are limited. Anyone got any ideas what I am doing wrong??
 
Cheers,
David
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 22:45:31 | 显示全部楼层
Hi David,
 
Please try the following code:
  1. (defun c:test ( / cmd lst ply sel )   (while       (progn (setvar 'errno 0) (setq ply (car (entsel "\nSelect bounding polyline: ")))           (cond               (   (= 7 (getvar 'errno))                   (princ "\nMissed, try again.")               )               (   (null ply) nil)               (   (not (wcmatch (cdr (assoc 0 (entget ply))) "*POLYLINE"))                   (princ "\nSelected object is not a polyline.")               )               (   (setq lst (polyvertices ply)                         cmd (getvar 'cmdecho)                   )                   (setvar 'cmdecho 0)                   (command "_.zoom" "_w"                       "_non" (apply 'mapcar (cons 'min lst))                       "_non" (apply 'mapcar (cons 'max lst))                   )                   (if (setq sel (ssget "_CP" lst '((0 . "*POLYLINE"))))                       (ssdel ply sel)                   )                   (command "_.zoom" "_p")                   (setvar 'cmdecho cmd)                   (sssetfirst nil sel)                   nil               )           )       )   )   (princ))(defun polyvertices ( ent / _lwvertices _polyvertices )   (defun _lwvertices ( enx / itm )       (if (setq itm (assoc 10 enx))           (cons (cdr itm) (_lwvertices (cdr (member itm enx))))       )   )   (defun _polyvertices ( ent )       (if (= "VERTEX" (cdr (assoc 0 (entget ent))))           (cons (cdr (assoc 10 (entget ent))) (_polyvertices (entnext ent)))       )   )   (if (= "POLYLINE" (cdr (assoc 0 (entget ent))))       (_polyvertices ent)       (_lwvertices (entget ent))   ))(princ)
 
The internal selection could be further refined to select polylines on a specific layer, colour, or other property.
 
I hope this helps.
 
Lee
回复

使用道具 举报

2

主题

4

帖子

2

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 23:04:36 | 显示全部楼层
Hi Lee,
 
Yep - done the trick perfectly! Thank you so much for the help - was wondering when I posted my problem if you would be the one to help  It can be a little tricky finding LISP routines that don't use Visual. I love my Mac...but it sure can be a pain with CAD word.
 
Cheers,
David
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 23:35:22 | 显示全部楼层
You're very welcome David, I'm happy to be of assistance.
 
Restricting the ActiveX (COM) component of Visual LISP certainly removes a lot of power from potential LISP programs, and severely limits the number of published programs that you are able to run... I hope the allure of a Mac is worth it!
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-12 12:49 , Processed in 1.615423 second(s), 60 queries .

© 2020-2025 乐筑天下

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