Jump to content

Recommended Posts

Posted

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

Posted

You can just record macro and save it as a new command name.

Posted
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.

Posted (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 by Jonathan Handojo
Posted (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 by BIGAL
Posted

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

Posted

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

Posted
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?

Posted

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

 

Posted
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

Posted

happy to help took a couple of go's to get it to work method is used in reactors thanks Lee.

Posted

@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.

  • Like 1
Posted

 

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..

 

Posted

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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...