brawleyman 发表于 2022-7-6 17:18:54

Macros: How to bypass "invalid

Is there a macro expression that will allow you to bypass the "invalid keyword option" and continue with a custom macro?

ASMI 发表于 2022-7-6 17:26:01

I think your macro has wrong syntax. Button macro hasn't any error trap.

brawleyman 发表于 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.

lpseifert 发表于 2022-7-6 17:40:12

Try this, I put it in my acaddoc.lsp file and use it often.

(defun c:pj () (setq pa (getvar "peditaccept")) (setvar "peditaccept" 1)   (setq ssj (ssget))   (command "pedit" "m" ssj """j" "0.01" "") (setvar "peditaccept" pa)(princ))

brawleyman 发表于 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.

brawleyman 发表于 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.

lpseifert 发表于 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

(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))

alanjt 发表于 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.

;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

brawleyman 发表于 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!

lpseifert 发表于 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.
页: [1] 2
查看完整版本: Macros: How to bypass "invalid