How do I make AutoCAD ignore "\" as a user input in a button macro?!

How do I make AutoCAD ignore "\" as a user input in a button macro?!

Anonymous
Not applicable
1,578 Views
12 Replies
Message 1 of 13

How do I make AutoCAD ignore "\" as a user input in a button macro?!

Anonymous
Not applicable

Hi all,

 

I am trying to create a custom button to change the dimpost command to "\P

But every time it stops at \, thinking it's supposed to be a user input.

 

How can I put "\P as text that I want inputted, instead of it doing " and then stopping for user input?  I don't want to type in "\P in the middle of the command every time.

 

dimpost;"\P;

 

I thought maybe parenthesis or brackets would work, but so far it hasn't.

Thanks for any help!!

 

Joe

0 Likes
Accepted solutions (2)
1,579 Views
12 Replies
Replies (12)
Message 2 of 13

CodeDing
Advisor
Advisor

@Anonymous ,

 

I'm still a bit unclear as to what exactly you're trying to accomplish.

Are you missing your end quote? --> "\P" <--

dimpost;"\P";  ...or...  dimpost;"\\P"

Or are you trying to put the literal string --> "\P <--

dimpost;"\"\P";  ...or...  dimpost;"\"\\P";

One of these 4 hopefully works for you!

Best,

~DD

Message 3 of 13

cadffm
Consultant
Consultant

You can not use backslashs in menumacro, just as placeholde for one user-input.

Fullversion user? then use LISP in commandline:

(setvar "DIMPOST" "\\P")

 

 

Sebastian

Message 4 of 13

Kent1Cooper
Consultant
Consultant
Accepted solution

This works for me:

(setvar 'dimpost (strcat (chr 92) "P"))

[Some, but not all, AutoLisp functions can be used in menu macros.  The (chr) function lets you avoid the actual \ character itself.]

Kent Cooper, AIA
Message 5 of 13

Kent1Cooper
Consultant
Consultant

@cadffm wrote:

.... use LISP in commandline:

(setvar "DIMPOST" "\\P")


 

[That doesn't do it.  It leaves you with:

(setvar "DIMPOST" "

at the command line, awaiting further input.]

Kent Cooper, AIA
Message 6 of 13

DannyNL
Advisor
Advisor

Since you also want the " the code below should be the one. You should be able to use this as your button macro as well. 

 

(setvar "DIMPOST" "\"\\\\P")

 

 

0 Likes
Message 7 of 13

ВeekeeCZ
Consultant
Consultant
Accepted solution

(setvar 'dimpost (strcat (chr 34) (chr 92) "P"))

... if " should be included.

0 Likes
Message 8 of 13

Kent1Cooper
Consultant
Consultant

@DannyNL wrote:

Since you also want the " the code below should be the one.

(setvar "DIMPOST" "\"\\\\P")

 

[That doesn't work either -- same result as in Message 5.  Testing before posting is always a good idea....]

Kent Cooper, AIA
0 Likes
Message 9 of 13

DannyNL
Advisor
Advisor

@Kent1Cooper I did test genius, as I always do before posting. And this code works fine on my side in AutoCAD 2017.

0 Likes
Message 10 of 13

DannyNL
Advisor
Advisor

DimPost.gif

 

0 Likes
Message 11 of 13

Kent1Cooper
Consultant
Consultant

@DannyNL wrote:

.... And this code works fine on my side in AutoCAD 2017.



It doesn't for me in 2019.  I took the wording "the code below should  be the one" as an indication that it hadn't been tested.  And I see from your screencast now that you appear to have done all your testing at the command line.  Did you test it in a menu macro button?   That's what they want to do, but that's where it runs into trouble -- it's not the same as doing it at the command line.

Kent Cooper, AIA
0 Likes
Message 12 of 13

DannyNL
Advisor
Advisor

I stand corrected.....I did test only on the command line. Used in a function should also be fine, but in a macro it shows the same issues.

@ВeekeeCZ 's code is the working one to be used in a macro.

0 Likes
Message 13 of 13

Anonymous
Not applicable

This one worked for me!  Thank you!!

0 Likes