Sambuddy Posted April 24, 2020 Posted April 24, 2020 Hey guys, This may be easiest question or a no solution question but I am going to ask anyways. I am inserting a tag "G" after going through a customized lisp that someone else wrote a while back. The path to get to G is entering MP then 3. I tried a simple (command "MP" "3" "G") and I am guessing because it is a customized lisp it does not recognizes it. I also know that I could make a button in CUI but rather write a couple of lines to get to "G" on lisp as I have other routines to execute after this. ^C^C_MP;3;G; works but I am not looking for this. I could separate the part of the routine but it has so many ties to page size, page number, client type that I would have to copy almost all the MP routine in order to get to "G". Is there a way on list to make this happen? 3 and G are of course keywords under MP lisp routine. (C:MP) "3" "G" Thanks Quote
Jonathan Handojo Posted April 24, 2020 Posted April 24, 2020 You can just record macro and save it as a new command name. Quote
Sambuddy Posted April 24, 2020 Author Posted April 24, 2020 27 minutes ago, Jonathan Handojo said: You can just record macro and save it as a new command name. not sure how to do it as it save the recording as .actm never have used an action recorder so I do not know the procedure. Quote
Jonathan Handojo Posted April 24, 2020 Posted April 24, 2020 (edited) It's similar to recoding macros in Excel. You click on the record macro, do all your actions, stop recording, then save the macro as a new command name. You can also (after recording) open the action tree and set some of the step to "Pause for user input", but in your case, you don't wanna do that because you want fixed inputs 3G. After that, you call the command, and it will repeat all the actions that were recorded. It may not be the solution you're after though because it will just store as a command with how you described it "^C^C_MP;3;G". Still, why not that? Edited April 24, 2020 by Jonathan Handojo Quote
Sambuddy Posted April 24, 2020 Author Posted April 24, 2020 @Jonathan Handojo did not work for me. Thanks anyways. Quote
BIGAL Posted April 24, 2020 Posted April 24, 2020 (edited) Your MP should expect a getreal,getint,getdist if it asks for a string will not work, but in saying that sometimes autocad accepts a number string answer, this has caught me out a few times. maybe ^c^c(c:mp)(command "3" "G") a macro can have multiple lisp execution. Edited April 24, 2020 by BIGAL Quote
hanhphuc Posted April 25, 2020 Posted April 25, 2020 can't comment 5 hours ago, BIGAL said: Your MP should expect a getreal,getint,getdist if it asks for a string will not work, but in saying that sometimes autocad accepts a number string answer, this has caught me out a few times. maybe ^c^c(c:mp)(command "3" "G") a macro can have multiple lisp execution. agree, perhaps write as function (defun MP (page Tag / ) ;;;<snippet> ) macro C^C^P (MP "3" "G") ^P recent discussions Quote
tombu Posted April 26, 2020 Posted April 26, 2020 You say ^C^C_MP;3;G; works but that's not what you're looking for so I'm guessing you're trying to call this from another lisp routine. My guess since we haven't seen the code is that the routine is expecting an interger. Try (c:mp)(command 3 "G") instead of (c:mp)(command "3" "G") Quote
Sambuddy Posted April 27, 2020 Author Posted April 27, 2020 14 hours ago, tombu said: You say ^C^C_MP;3;G; works but that's not what you're looking for so I'm guessing you're trying to call this from another lisp routine. My guess since we haven't seen the code is that the routine is expecting an interger. Try (c:mp)(command 3 "G") instead of (c:mp)(command "3" "G") It is correct, I do have "initget" function on under MP defun. (c:MP) will execute the entire routine whereby I have to enter 3 and then under another sub0menu G. So "3" is not a recognizable command by itself nor is G. The macro MP;3;G does work, the question is how is it that I can have it implemented on a lisp routine to get to "G" starting from "MP" and then "3". On 25/04/2020 at 01:18, hanhphuc said: agree, perhaps write as function (defun MP (page Tag / ) ;;;<snippet> ) @hanhphuc how would I write it as a function? Quote
BIGAL Posted April 28, 2020 Posted April 28, 2020 "I do have "initget" function on under MP defun." try something like this (defun c:mpp ( ) (initget "Lines Plines aRrcs Splines All") (setq Opsum (getkword "\nGet the sum of: [Lines/Plines/aRcs/Splines/All] <All=>: " )) ) (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "mpp a ") (alert opsum) Quote
Sambuddy Posted April 28, 2020 Author Posted April 28, 2020 16 hours ago, BIGAL said: "I do have "initget" function on under MP defun." try something like this (defun c:mpp ( ) (initget "Lines Plines aRrcs Splines All") (setq Opsum (getkword "\nGet the sum of: [Lines/Plines/aRcs/Splines/All] <All=>: " )) ) (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "mpp a ") (alert opsum) I ended up using your line and it is amazing how much knowledge one possesses! (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "MP 3 G ") Thank you @BIGAL Quote
BIGAL Posted April 28, 2020 Posted April 28, 2020 happy to help took a couple of go's to get it to work method is used in reactors thanks Lee. Quote
Sambuddy Posted April 29, 2020 Author Posted April 29, 2020 @BIGAL @Lee Mac @hanhphuc you are in a completely different level when it comes to programming. It is a blessing to have you on this forum. 1 Quote
hanhphuc Posted May 1, 2020 Posted May 1, 2020 On 4/27/2020 at 9:51 PM, Sambuddy said: @hanhphuc how would I write it as a function? ^C^C^P (foo "P") ^P FWIW it was just a concept with argument, may not practical in your task similar cond (defun foo (k) (eval (cdr (assoc k '(("L" . (princ "\nDo something with lines")) ("P" . (princ "\nDo something with Plines")) ("R" . (princ "\nDo something with Arcs")) ("S" . (princ "\nDo something with Splines")) ("A" . (princ "\nDo something with All")) ) ) ) ) ) (foo "P") ;"\nDo something with Plines" i can't assume your MP function execution & output i.e: just KISS principle as BIGAL suggested p/s: flattered but to be honest as amateur i'm still very far to reach giant's shoulder like Lee, BIGAL etc.. Quote
BIGAL Posted May 2, 2020 Posted May 2, 2020 This is a nice lisp pick an existing object and it auto starts that command and extra stuff like layer. I have it as zzz The toolbar draw has most of the common commands ? copycommand.lsp Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.