What's wrong with this macro

h_s_walker
Mentor
Mentor

What's wrong with this macro

h_s_walker
Mentor
Mentor

 

^c^c^c_setenv;osnaps;$m=$(getvar,osmode);setvar "osmode" 32;-la;m;COVERMETER;;.text;mc;M2P;\;XX;layerp;-la;c;GREEN;COVERMETER;;setvar "osmode";$(getenv,"osnaps");

 

So the gist of it is I get my current snaps and then I change it to only intersection. Then I put some text onto a layer between 2 selected points. All good so far.

The problem is at the end. I want to get my previous snaps back and it doesn't work at all. HOWEVER it does save the correct binary value in the "osnaps" variable. 

I've just tried it a few times and it "remembers" the previous setting for the variable and puts that in instead of the "current setting"

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes
Reply
Accepted solutions (1)
656 Views
9 Replies
Replies (9)

pendean
Community Legend
Community Legend
why not just set your OSMODE back to what your preferred setting is vs. trying to capture/retain what might not be your preferred setting in the first place? Using 1147 in this example as the preferred setting, my favorite default

^C^C_osmode;32;-la;m;COVERMETER;;.text;mc;M2P;\;XX;_layerp;-la;c;GREEN;COVERMETER;;_osmode;1147;
0 Likes

h_s_walker
Mentor
Mentor

Because I might send it to my fellow worker and her preferred settings might not be the same as mine.

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes

steven-g
Mentor
Mentor

Difficult! The problem is that setenv doesn't get written into the variable until after the macro closes, which is why getenv is reading the old value. I would say leave the osnap value alone and use the command modifier 'int' before the pause for user pick points as it will only allow the intersection snap to be selected, but that is also a problem because the modifier 'm2p' only allows for one user pause in a macro but prompts for 2 pick points, the first point will indeed only select 'int' but the second point will accept any snap.

0 Likes

pendean
Community Legend
Community Legend
@h_s_walker you might have to customize it for the other user in the interim until someone jumps in with something else to try.
0 Likes

Paul_Gander
Advocate
Advocate
Accepted solution

You will need a second nested macro expression enclosed in quotation marks so that the getenv function doesn't get evaluated until after setenv command has been executed. Try this:

^C^C^C_setenv;osnaps;$m=$(getvar,osmode);setvar;osmode;32;-la;m;COVERMETER;;.text;mc;m2p;\;XX;layerp;-la;c;green;COVERMETER;;setvar;osmode;"$m=$(getenv,osnaps)";

or alternatively, use the cal command to determine the mid point between two intersection snaps without the need to modify the current running object snap setting:

^C^C^C-la;m;COVERMETER;;.text;mc;'cal;(int+int)/2;\\\;XX;layerp;-la;c;green;COVERMETER;;

 

h_s_walker
Mentor
Mentor

@Paul_Gander Your first solution is the one I needed. Cheers. The reason why I can't use the second one is I don't know which snaps my colleague prefers.

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes

pendean
Community Legend
Community Legend

@h_s_walker wrote:

@Paul_Gander Your first solution is the one I needed. Cheers. The reason why I can't use the second one is I don't know which snaps my colleague prefers.


OSNAPCOORD (System Variable) set to 1 may be the answer you need https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2021/ENU/AutoC...

0 Likes

pendean
Community Legend
Community Legend
@h_s_walker A quick reminder that manually breaking/stopping the macro mid-process will not restore OSMOADE settings back to the user default before they triggered the macro.
0 Likes

h_s_walker
Mentor
Mentor

No the person who will be using it knows how to use AutoCAD and it works just how I wanted it to now

Howard Walker
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Left Handed and Proud

0 Likes