Text Prompt in a MACRO

Text Prompt in a MACRO

Anonymous
Not applicable
2,448 Views
19 Replies
Message 1 of 20

Text Prompt in a MACRO

Anonymous
Not applicable

Hello,

 

I have created some rather long multi step Macro's and am getting somewhat lost in the routine.

Is there anyway to ad text prompts!?

I read that vbLf pre and post text works but this failed for me.

Does anyone know of another way to write it in?!

 

Thanks in advance.

0 Likes
Accepted solutions (1)
2,449 Views
19 Replies
Replies (19)
Message 2 of 20

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... Macro's .... Is there anyway to ad text prompts!?

.....


If you're not using AutoCAD LT, you can use certain [not all] AutoLisp expressions in command macros, including (get...) functions with prompts in them.  So, for instance, you can have:

 

(setq whatever (getpoint "Pick a point: "))

 

within a command macro.  [In that case, follow it with a \ for the User to pick the requested point.]  However, I find that the \n new-line element, which one would typically put at the beginning of the prompt part of something like that in a regular AutoLisp routine, causes a macro to hang up.  But when I left that out, it worked, though it's not as "elegant" as in a fully-AutoLisp routine -- it shows that whole (setq ... (get...)) function at the Command: line before repeating the prompt.

Kent Cooper, AIA
0 Likes
Message 3 of 20

scot-65
Advisor
Advisor
>> ...causes a macro to hang up.

Have you tried ^C^C^Q?

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 4 of 20

Anonymous
Not applicable
I'm just simply trying to add a line of text to prompt the user.

(setq whatever (getpoint "Pick a point: "))

Not really sure how to apply this method as I am new to macro and my commands to not include (setq (.......)). Is there another way!?
0 Likes
Message 5 of 20

ВeekeeCZ
Consultant
Consultant

Have you tried eval?

 

$(eval, str)

$(eval,"Current layer: " $(getvar,clayer))

 

See the help system here and here

0 Likes
Message 6 of 20

Anonymous
Not applicable
No sorry that still doesn't make any sense to me as a newbie!

Am I right in thinking that the

"Current layer: " will be the prompt and that

$(getvar,clayer)) is the command with clayer to be input command and getvar the trigger so to speak.

Am I right?
0 Likes
Message 7 of 20

ВeekeeCZ
Consultant
Consultant

Could you post your macro?

Why are you need a macro?

Are you using AutoCAD LT?

 

Remember... Macros are very limited. If you have something more complex I do recommend rewrite it to LISP (unless you have LT)

0 Likes
Message 8 of 20

CADaSchtroumpf
Advisor
Advisor
0 Likes
Message 9 of 20

Anonymous
Not applicable
Here is the macro.

^C^C_pasteorig;'_.zoom;e;_ai_selall;QSELECT;(LOAD "IPITNO");IPITNO;b;\;y;_ai_selall;QSELECT;\;(LOAD "txt2mtx");TXT2MTX;0;y;_ai_selal;QSELECT;(LOAD "ADDTOTEXT");ADDTOTEXT; %%C;

This is for changing drainage export from 12d AutoCAD standard.
As you can see the MACRO has a LISP in it already.

Not for AutoCAD LT.

Please help.
0 Likes
Message 10 of 20

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:
I'm just simply trying to add a line of text to prompt the user.
.... my commands to not include (setq (.......)). Is there another way!?

The (prompt) AutoLisp function will do that:

 

(prompt "This is your prompt text.")

 

But I expect [without trying], as in my previous Reply, it's going to put the whole (prompt) function on the Command: line and then repeat the prompt itself.

Kent Cooper, AIA
0 Likes
Message 11 of 20

Anonymous
Not applicable
Here is the macro do you believe it will work now?!

^C^C_pasteorig;'_.zoom;e;_ai_selall;(prompt "Select Pit Numbers for Capsule")QSELECT;(LOAD "IPITNO");IPITNO;b;\;y;_ai_selall;QSELECT;(prompt "Change Pit Capsule Layer.")\;(prompt "Select Text to Convert to Mtext.")(LOAD "txt2mtx");TXT2MTX;0;y;_ai_selal;QSELECT;(prompt "Select a Pipe Text to add Diameter.")(LOAD "ADDTOTEXT");ADDTOTEXT; %%C;

Thanks in advance.
0 Likes
Message 12 of 20

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:
Here is the macro do you believe it will work now?!

^C^C_pasteorig;'_.zoom;e;_ai_selall;(prompt "Select Pit Numbers for Capsule")QSELECT;(LOAD "IPITNO");IPITNO;b;\;y;_ai_selall;QSELECT;(prompt "Change Pit Capsule Layer.")\;(prompt "Select Text to Convert to Mtext.")(LOAD "txt2mtx");TXT2MTX;0;y;_ai_selalL;QSELECT;(prompt "Select a Pipe Text to add Diameter.")(LOAD "ADDTOTEXT");ADDTOTEXT; %%C;

Thanks in advance.

You have a typo...

 

I you would be interested... this workflow could be much more automated with LISP. All QSELECT could be automated...
But you need to elaborate your steps for us. One by one. Some are obvious from the macro... but what properties you're specify in QSELECT.....
Post some sample with pre and after situation (dwg)
Post the routines you have using. Post all we need to test the whole workflow.

0 Likes
Message 13 of 20

Anonymous
Not applicable
Ok I will when I'm at work thanks.

So adding -
(prompt "Select Pit Numbers for Capsule")
Is not the correct method for adding a line of text to prompt the user!?

Can you recommend any good instructional videos?

Thanks
0 Likes
Message 14 of 20

Anonymous
Not applicable

Here are drawing files.

 

The first one is a standard 12d export the 2nd is a standard drawing for presentation.

 

Idealy i would like to keep the routine as a macro as it will be going on to a tool pallette.

 

Thanks for your help.

0 Likes
Message 15 of 20

Anonymous
Not applicable

Here are all the files required to get routine running.

Also Word document of the work flow.

 

Thanks BeeKeeCZ I would really appreciate the Help

0 Likes
Message 16 of 20

ВeekeeCZ
Consultant
Consultant
Accepted solution

@Anonymous wrote:

Hello,

 

I have created some rather long multi step Macro's and am getting somewhat lost in the routine.

Is there anyway to ad text prompts!?

I read that vbLf pre and post text works but this failed for me.

Does anyone know of another way to write it in?!

 

Thanks in advance.


 

Ok... here is the way how to add some text prompts. I used (pricn), but you can use (prompt) as well (as Kent suggested).

 

 

^C^C_pasteorig;'_.zoom;e;_ai_selall;(princ ">> Choose TEXT, color GREEN:")(princ);QSELECT;(LOAD "IPITNO");IPITNO;b;\;y;_ai_selall;(princ ">> Choose BLOCK, name PITNO-CAPSULE:")(princ);QSELECT;\;(LOAD "txt2mtx");TXT2MTX;0;y;_ai_selall;(princ ">> Choose MTEXT, color WHITE:")(princ);QSELECT;(LOAD "ADDTOTEXT");ADDTOTEXT; %%C;

 

BUT, that was the easy part. Does the macro even work for you? It does not for me - because I cannot pass the red backslash. The backslash is a special character in macros (pause for user input) and I don't know how to suppress this special functionality to make it a regular string. Maybe someone else would know...

 

...if not, you can use this lisp to replace \ to /

 

Spoiler
(vl-load-com)

(defun c:TextReplaceSlash ( / ss i txt ed)
  (if (setq ss (ssget "_X" '((0 . "TEXT") (1 . "*\\*"))))
    (repeat (setq i (sslength ss))
      (setq txt (cdr (assoc 1 (setq ed (entget (ssname ss (setq i (1- i))))))))
      (entmod (subst (cons 1 (vl-string-translate "\\" "/" txt))
		     (cons 1 txt)
		     ed))))
  (princ)
)

 

0 Likes
Message 17 of 20

vladimir_michl
Advisor
Advisor

I would recommend to abandon DIESEL menu macros (spiced up with AutoLISP) for such more complicated functions and to do it completely in AutoLISP. Replace the "\" input prompts with an appropriate (getpoint) or (getstring) or (getdist) functions in AutoLISP.

 

Vladimir Michl, www.cadstudio.cz  www.cadforum.cz

 

0 Likes
Message 18 of 20

ВeekeeCZ
Consultant
Consultant

@vladimir_michl wrote:

I would recommend to abandon DIESEL menu macros (spiced up with AutoLISP) for such more complicated functions and to do it completely in AutoLISP. Replace the "\" input prompts with an appropriate (getpoint) or (getstring) or (getdist) functions in AutoLISP.

 

Vladimir Michl, www.cadstudio.cz  www.cadforum.cz

 


@vladimir_michl, @Anonymous

 

I was recommending the same thing (see my post #7), but that was before I see the whole thing.
Dustin used three routines in his macro, each has some user prompts which is filled by the macro. That's the advance of macro which makes this programming simple... but this is not simply replicable using lisp. So all three routines must be modified to get rid of this user prompts.

 

So I offered to the OP this little routine called TextReplaceSlash which should be the OP able to fix his macro with by it's own. To Dustin - try and let know how it goes and if you need any more help.

 

Btw Unfortunately in this case the backslash was used as text separator "25\7" in the drawing and needs to be replaced (probably with "/"). So it's in conflict with a special symbol \ for pause for user input.

 

 

 

0 Likes
Message 19 of 20

Anonymous
Not applicable
Thanks to everyone who has helped me figure this out.
0 Likes
Message 20 of 20

Satoews
Advocate
Advocate

^C^C_pasteorig;'_.zoom;e;_ai_selall;(princ ">> Choose TEXT, color GREEN:")(princ);QSELECT;(LOAD "IPITNO");IPITNO;b;\;y;_ai_selall;(princ ">> Choose BLOCK, name PITNO-CAPSULE:")(princ);QSELECT;/;(LOAD "txt2mtx");TXT2MTX;0;y;_ai_selall;(princ ">> Choose MTEXT, color WHITE:")(princ);QSELECT;(LOAD "ADDTOTEXT");ADDTOTEXT; %%C;

 

Don't know if you have took the leap to lisp or not but I thought I would share a fix for the backslash problem in macros. Use forwardslash in subsitute, this should work now if that was the only think stopping this macro. 

Shawn T
0 Likes