Community
AutoCAD LT Forum
Welcome to Autodesk’s AutoCAD LT Forums. Share your knowledge, ask questions, and explore popular AutoCAD LT topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

What's wrong with this macro

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
hwalker
465 Views, 9 Replies

What's wrong with this macro

 

^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

9 REPLIES 9
Message 2 of 10
pendean
in reply to: hwalker

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;
Message 3 of 10
hwalker
in reply to: pendean

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

Message 4 of 10
steven-g
in reply to: hwalker

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.

Message 5 of 10
pendean
in reply to: hwalker

@hwalker you might have to customize it for the other user in the interim until someone jumps in with something else to try.
Message 6 of 10
Paul_Gander
in reply to: hwalker

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

 

Message 7 of 10
hwalker
in reply to: hwalker

@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

Message 8 of 10
pendean
in reply to: hwalker


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

Message 9 of 10
pendean
in reply to: hwalker

@hwalker 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.
Message 10 of 10
hwalker
in reply to: pendean

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report