Jump to content

Restore Osnap's


Seath

Recommended Posts

I use an addon called Hydratec with AutoCAD 2007. One of our commands presets the Osnaps. I want to make a button so after I finish with the Hydratec command I can restore my Osnap settings. I want to be able to use it in the middle of a command with out breaking the command if possable. Thanks for any help!

Link to comment
Share on other sites

  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • Seath

    5

  • rshort9900

    5

  • lpseifert

    3

  • yawdapaah

    2

Guest LElkins

Off the top of my head, I can think it may be possible, but you would either (a) have to click a button before using the tool to 'mark' the snap settings, or (b) use a standard list of snaps, then activate any additional afterwards.

would this be ok?

Link to comment
Share on other sites

use this macro for a new command and make a toolbar button from it.

(setvar "osmode" 1) 

the integer after "osmode" is the sum of the bitcodes for the snaps you want on. The above will turn endpoint on. See Help for the system variable Osmode for a listing of the bitcodes.

Link to comment
Share on other sites

use this macro for a new command and make a toolbar button from it.

(setvar "osmode" 1) 

the integer after "osmode" is the sum of the bitcodes for the snaps you want on. The above will turn endpoint on. See Help for the system variable Osmode for a listing of the bitcodes.

 

That worked for creating a new button thanks! Is there a way to make the button not break my current command? ie. I am in the middle of a move command and need to reset my Osnaps I click the button and my command doesnt break. Currently while in a command it does break the command.

 

Thanks for all the help so far!

Link to comment
Share on other sites

That worked for creating a new button thanks! Is there a way to make the button not break my current command? ie. I am in the middle of a move command and need to reset my Osnaps I click the button and my command doesnt break. Currently while in a command it does break the command.

If you have ^C^C in your macro remove them.

Link to comment
Share on other sites

If you have ^C^C in your macro remove them.

 

I removed the ^C^C it is still breaking my command. I have tryed putting a ' infront of the command but all that seems to do is mess up the command all together. Any other suggestions?

Link to comment
Share on other sites

  • 8 months later...

I found this to work for getting you preset osnap variables and restoring them back after the program is finished.

 

Put this first inside the lisp program

(setq osn (getvar "osmode"))

 

Put this last inside the lisp program

(command "osmode" osn)

Link to comment
Share on other sites

I use an addon called Hydratec with AutoCAD 2007. One of our commands presets the Osnaps. I want to make a button so after I finish with the Hydratec command I can restore my Osnap settings. I want to be able to use it in the middle of a command with out breaking the command if possable. Thanks for any help!

 

In writing various LISP routines I always want to turn the Osnaps off and then reset them to whatever the user had them set at previously. To capture the initial settings I use something like:

 

(setq old_mode (getvar "osmode") )

(setvar "osmode" 0)

 

This captures the current setting into the variable old_mode and then turns all of the Osnap settings off.

 

To return to the initial Osnap state I would use:

 

(setvar "osmode" old_mode)

Link to comment
Share on other sites

Yeah, I do too. I was just copying a piece of code as an option to the original question. Here's what I pasted from:

 

(defun c:2at ()

(defun dtr (a)

(* pi(/ a 180.0))

)

(command "layer" "S" "fan" "")

(command "orthomode" "1")

(setq osn (getvar "osmode"))

(command "osnap" "center")

(setq pick (getpoint "\Select isolator hole on base: "))

(setq rot1 (polar pick (dtr 0.0) 0.6))

(command "osmode" "0")

(command "insert" "2a-isolatortop=" pick "" "" "")

(command "insert" "2a-isoplatetop=" pick "" "" "")

(command "rotate" "c" pick rot1 "l" "" pick pause)

(command "osmode" osn)

(command "layer" "S" "casing" ""))

 

It's an isolator top view that places them on A/C fans.

Link to comment
Share on other sites

i use this:

(defun c:AS ( / )
(setvar 'osmode 105)
(princ "\nActive Osnaps: End, Insertion, Intersection, & Node")
(princ)
);defun

i can run it real quick to set my desired snaps, or i can run it transparently (typing: 'as)

Link to comment
Share on other sites

Good idea for a stand alone machine.

The only problem I can see with setting a specific snap, is in the case of sharing a server with AutoCAD & the programs. Each individual person, as you probably already know, have their own settings and style they prefer. The getvar osmode grabs each persons settings and holds on to it until it completes the function of the program, then resetting it back to each individual persons settings with the "osmode" re-call.

Link to comment
Share on other sites

  • 4 weeks later...
Good idea for a stand alone machine.

The only problem I can see with setting a specific snap, is in the case of sharing a server with AutoCAD & the programs. Each individual person, as you probably already know, have their own settings and style they prefer. The getvar osmode grabs each persons settings and holds on to it until it completes the function of the program, then resetting it back to each individual persons settings with the "osmode" re-call.

 

That is my problem; we have a command (which i cannot edit) which sets my OSnap settings to Nearest. I edited my CUI file so that Shift + Button 3 will set my Osnap to 4263. The problem is that I want to do this whilst the "faulty" command is running, not after. Thanks.

 

Hello everyone BTW :D

Link to comment
Share on other sites

That is my problem; we have a command (which i cannot edit) which sets my OSnap settings to Nearest. I edited my CUI file so that Shift + Button 3 will set my Osnap to 4263. The problem is that I want to do this whilst the "faulty" command is running, not after. Thanks.

 

yawdapaah, the string (setvar "osmode" 4263)(princ) will set the osnaps while in a command, you can make a tollbar button to reset the settings while in a command, or a keyboard shortcut

Link to comment
Share on other sites

yawdapaah,

How is this command or program that your talking about, initiated? From a Toolbar button located in the CUI? Shortcut keys? Command prompt from your appload? Just curious..........

Link to comment
Share on other sites

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