乐筑天下

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

[编程交流] Lisp Won't Continue to Ne

[复制链接]

55

主题

325

帖子

274

银币

后起之秀

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

铜币
280
发表于 2022-7-6 09:07:46 | 显示全部楼层 |阅读模式
I am just learning to write lisp and I wrote this basic function to erase any miscellaneous data that might be outside my drawing area, but it won't continue to the next command in the whole lisp routine.  What am I missing to move to the next command in my lisp?
 
  1. (COMMAND "ZOOM" "E")(COMMAND "ZOOM" "SC" "0.75X")(COMMAND "ERASE" (SSGET"X") "R")
回复

使用道具 举报

0

主题

101

帖子

103

银币

限制会员

铜币
-2
发表于 2022-7-6 09:13:55 | 显示全部楼层
I think I know this one.
 
Sorry if I am wrong this is my first attempt at answering a Lisp question
but you need a space follwing the command and option.
The space is interpreted as newline or pressing enter
 
"Zoom "
回复

使用道具 举报

55

主题

325

帖子

274

银币

后起之秀

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

铜币
280
发表于 2022-7-6 09:14:20 | 显示全部楼层
Sorry Jeff, but that wasn't it.  In the ERASE command, I have to make selection window(s) to remove the items that I don't want deleted.  After I do this, the lisp stops and doesn't continue to the rest of commands within the lisp.  Thanks for trying.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 09:19:35 | 显示全部楼层
First adjust your view in the acad dwg and try this .
 
  1. (defun c:test (/ p1 p2 ss i sset s j e) (if   (and     (setq p1 (getvar 'vsmin))     (setq p2 (getvar 'vsmax))   )    (progn      (setq ss (ssget "_w" p1 p2))      (repeat (setq i (sslength ss))        (setq sset (cons (ssname ss (setq i (1- i))) sset))      )      (setq s (ssget "_x"))      (repeat (setq j (sslength s))        (if (not (member (setq e (ssname s (setq j (1- j)))) sset))          (entdel e)        )      )    )    (princ) ) (princ))
 
Tharwat
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 09:23:21 | 显示全部楼层
FYI future reference (COMMAND "ERASE" (SSGET"X") "R") this asking for 2 selection inputs the "X" is all then asking for a seperate remove they are independant of each other. You probably can not use the "R" to remove objects from the ssget
 
eg (command "erase" "wp" "CP" "W")  is 3 seperate requests being added together.
 
Also not sure Z E, zooms total area and then going 75% would not necessarily get rid of junk. The view method above would be a better way.
回复

使用道具 举报

55

主题

325

帖子

274

银币

后起之秀

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

铜币
280
发表于 2022-7-6 09:25:05 | 显示全部楼层
The zoom extents is so I can see everything in the drawing file.  The zoom to 75% backs the view out just a little bit.  That way when I make a selection window I can get objects on the edges without panning around or zooming out manually.
 
Tharwat - thank you, but that does not allow me to make a selection window of what I want to keep.  In my very little experience with lisps, I am working on putting this functionality in what you have.  Is there not a way to use what I have and make it work (which is obviously a lot easier for a simple minded person like me to understand)?
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

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

铜币
358
发表于 2022-7-6 09:29:23 | 显示全部楼层
 
Hi ,
 
I think if you add only the zoom command to the routine it would work .
 
  1. (COMMAND "ZOOM" "SC" "0.75X")
 
Or you can use the command zoom only and select two points and the routine would do the rest .
 
Good luck.
 
Tharwat
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 09:30:26 | 显示全部楼层
Let me try to explain what I *believe* is happening....
 
Using this code as an example:
 

[code](COMMAND "ZOOM" "E")(COMMAND "ZOOM" "SC" "0.75X")(COMMAND "ERASE" (SSGET "X") "R")(command "._line") ;  Animate), you will see that the code steps through this line BEFORE the Editor shows the selection set from which objects can be removed. The erase command is effective at allowing objects to be de-selected, however the code "doesn't continue" because it's already been passed over.</p> 
Hope this helps!
回复

使用道具 举报

55

主题

325

帖子

274

银币

后起之秀

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

铜币
280
发表于 2022-7-6 09:36:00 | 显示全部楼层
So you are saying lisps don't necessarily always read left to right, top to bottom?
回复

使用道具 举报

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 09:38:41 | 显示全部楼层
Give this a try:
 
  1. (defun c:FOO  (/ ss keep all) (vl-load-com) (if (setq ss (ssget "_:L"))   (progn     ((lambda (i / e)        (while (setq e (ssname ss (setq i (1+ i))))          (setq keep (cons e keep))))       -1)     (mapcar       'entdel       (vl-remove-if         '(lambda (e)            (vl-position e keep))         ((lambda (i ss / e)            (while (setq e (ssname ss (setq i (1+ i))))              (setq all (cons e all))))           -1           (setq ss (ssget "_x"))))))   (prompt "\n** Nothing selected ** ")) (princ))
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-1 07:26 , Processed in 0.758776 second(s), 72 queries .

© 2020-2025 乐筑天下

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