乐筑天下

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

[编程交流] Macros: How to bypass "invalid

[复制链接]

14

主题

59

帖子

45

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 17:18:54 | 显示全部楼层 |阅读模式
Is there a macro expression that will allow you to bypass the "invalid keyword option" and continue with a custom macro?
回复

使用道具 举报

2

主题

439

帖子

536

银币

限制会员

铜币
-14
发表于 2022-7-6 17:26:01 | 显示全部楼层
I think your macro has wrong syntax. Button macro hasn't any error trap.
回复

使用道具 举报

14

主题

59

帖子

45

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 17:32:25 | 显示全部楼层
What I have is 2 macros. 1 turns multiple lines into 1 polyline, and the other turns multiple polylines into 1 polyline. I am trying to find a way to fuse the 2 commands together.
If my selection set has any regular lines in it, 1 macro turns those into polylines then connects them into 1. If my selection set is all polylines, the 2nd macro just connects them together because it doesn't ask to turn them into polylines since they already are.
I am trying to find a way so that I can use 1 macro to do this. If the selection set happens to have any lines in it, then turn them into polylines then fuse them together, and if the selection set is just polylines, then continue to fuse them.
I guess it is kind of a "if this condition exists, yes is the answer, then continue the command. If condition does not exist, continue with the command".
Any ideas?
 
...Edit...Additional info...
The macros I have created are compound macros that not only fuse the lines together by adding a segment, but also reselects the newly-made polyline and fillets it automatically all in 1 step.
回复

使用道具 举报

4

主题

940

帖子

961

银币

初来乍到

Rank: 1

铜币
12
发表于 2022-7-6 17:40:12 | 显示全部楼层
Try this, I put it in my acaddoc.lsp file and use it often.
  1. (defun c:pj () (setq pa (getvar "peditaccept")) (setvar "peditaccept" 1)   (setq ssj (ssget))   (command "pedit" "m" ssj ""  "j" "0.01" "") (setvar "peditaccept" pa)(princ))
回复

使用道具 举报

14

主题

59

帖子

45

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 17:45:06 | 显示全部楼层
I am trying to use just the Macro because I am more familiar with it than Lisp, although I am trying to learn it. Essentially, the only difference in the macro code for both macros is the addition of "y:"
 
If there are any regular lines, the "y;" tells it "yes, turn into polylines" then continues to create the polyline and fillet it. Otherwise, if they are all polylines, the "y:" makes it say "invalid option keyword" and the macro will not automatically continue the rest of the commands.
 
I am trying to make the macro continue past this point so that I can just have the 1 macro to do what I need instead of 2 different ones.
回复

使用道具 举报

14

主题

59

帖子

45

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 17:50:12 | 显示全部楼层
Oh, another question I have is about repeating the whole operation. If I right click to repeat the command, it just repeats the last part of it, the fillet. I need to be able to repeat the entire command sequence because it would be faster and easier to do that than to have to click on the icon every time.
 
I really appreciate your guy's help today. Hopefully there is a way to do what I am wanting to do because I am almost there.
回复

使用道具 举报

4

主题

940

帖子

961

银币

初来乍到

Rank: 1

铜币
12
发表于 2022-7-6 17:57:21 | 显示全部楼层
Try setting Peditaccept=1, there should be no need for the"Y" prompt.
 
A menu macro is essentially a series of commands; when you rt-clk to repeat, acad just repeats the last command executed.
 
That being said, here's a lisp that should do what you want
  1. (defun c:test () (setq old-pa (getvar "peditaccept")) (setq old-rad (getvar "filletrad")) (setvar "peditaccept" 1) (setq ent (entsel "\nSelect object to join/fillet: ")) (setq pt (osnap (cadr ent) "nea")) (setq ename (car ent)) (princ "\nSelect objects to join to: ") (setq    ss1 (ssget)   ssj (ssadd ename ss1) ) (setvar "filletrad" (getreal "Enter radius: ")) (command "pedit" "m" ssj "" "j" "0.01" "") (command "fillet" "p" pt) (setvar "peditaccept" old-pa) (setvar "filletrad" old-rad) (princ))
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 18:03:05 | 显示全部楼层
i wrote this a while back for joining lines, arcs & plines, it will work with either peditaccept setting and will NOT change it.
  1. ;join multiple lines/arcs;created: alan thompson, 4.23.08(defun c:mj (/ lines)(princ "\nSelect lines & arcs to JOIN: ")(setq lines (ssget '((0 . "*LINE,ARC")))) (if lines  (progn   (if (equal (getvar 'peditaccept) 1)    (command "pedit" "m" lines "" "j" "" "")    (command "pedit" "m" lines "" "y" "j" "" "")   );if  );progn  (alert (strcat "\nHey " (getvar "loginname") " it helps if you actually select something to work with!")) );if (princ));defun
回复

使用道具 举报

14

主题

59

帖子

45

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 18:09:08 | 显示全部楼层
Thanks lpseifert! I set up my macro to turn peditaccept "on" anytime I use it. I was able to consolidate my 2 commands into 1! Just too bad there wasn't a way to right click to bring up the entire macro command sequence instead of just the last command.
 
Thanks everyone for their suggestions!
回复

使用道具 举报

4

主题

940

帖子

961

银币

初来乍到

Rank: 1

铜币
12
发表于 2022-7-6 18:15:33 | 显示全部楼层
I think if you put an asterisk before the ^C^C in your macro it will repeat.
But if you use lisp instead of a menu macro, you can define it as an acad command, allowing you to rt-clk to repeat.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 16:22 , Processed in 0.460643 second(s), 72 queries .

© 2020-2025 乐筑天下

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