Author Topic: Execute code on Autocad exit?  (Read 2393 times)

0 Members and 1 Guest are viewing this topic.

matthewj

  • Newt
  • Posts: 42
  • Vanilla
Execute code on Autocad exit?
« on: October 05, 2009, 08:41:42 PM »
First off, this site's been a huge help over the past week.  So thanks for just being here.

This is my first post, and I haven't been able to find information on my current dilemma.  Heres hoping that people smarter than I am might help out.

The problem: I'm writing a routine that temporarily changes the crosshair color (part of a modal layer utility) & saves the user's original color to the blackboard namespace.  If the alternate color is active when Autocad exits (or crashes) the crosshair color stays the alternate color.  Right now I'm working around this by setting the crosshair color back to white(model)/black(layout) (& only if needed) at lisp load.  This is all fine and good, but it's pretty crappy for users who have custom crosshair colors & those that have embraced the v2010 off-white model-space background.

I was hoping that there might be an "execute on autocad exit" functionality in AutoLisp.  (Though this solution wouldn't help much if Autocad crashed.)

Is there another way to do this?  I'd like to not save any preference files to the user's computer if at all possible, but perhaps that's the way to go.  (I can post the routine if you want, just figured I'd keep the s/n ratio down.)

Thanks for your time,
Matt.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Execute code on Autocad exit?
« Reply #1 on: October 05, 2009, 09:18:58 PM »
A vlr-command-reactor can issue if the command matches a defined list.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

matthewj

  • Newt
  • Posts: 42
  • Vanilla
Re: Execute code on Autocad exit?
« Reply #3 on: October 05, 2009, 11:19:20 PM »
...Oh that is just too rad.

Thanks, got it working properly.  Unfortunately, now that I've started to explore reactors, my feature list for this utility just got longer.  :-D

I'll post the finished lisp in a few days.

Thanks again,

Matt

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Execute code on Autocad exit?
« Reply #4 on: October 05, 2009, 11:20:00 PM »
Why would you not reload the users profile to restore his/her preferences?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

matthewj

  • Newt
  • Posts: 42
  • Vanilla
Re: Execute code on Autocad exit?
« Reply #5 on: October 05, 2009, 11:57:15 PM »
You mean reload them through the script?  I hadn't thought of that.

Though I'm not sure how that would work if the users' are using an unnamed profile...  I guess there's probably a way to save a temporary profile and restore that later on through a script.  Though, I have to say, I'm very pleased with how its turned out so far.

Unfortunately, not everybody uses profiles.  I'll admit that sometimes I fiddle with my stuff and don't always update any of my profiles until (sometimes weeks!) later. Dumb, I know.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Execute code on Autocad exit?
« Reply #6 on: October 06, 2009, 09:33:30 AM »
An Un-named Profile would be no help.
I suppose your own registry save would be the way to go.  

« Last Edit: October 06, 2009, 09:44:06 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Execute code on Autocad exit?
« Reply #7 on: October 06, 2009, 10:21:01 AM »
You can set the "<< Unnamed Profile >>" as current profile.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox