August 9, 2011

Hacking Visual Lisp IDE to be a little more awesome!

Filed under: AutoCAD,Development — Tags: , — Darrin Maidlow @ 11:12 am

Even though it’s the year 2011 and is available in all its glory for .NET I still spend a lot of time in the IDE (VLIDE).   While ObjectARX is powerful and full of awesome, it comes at a cost of a lot of overhead to setup a project, add all the needed references, heck even compiling / debugging is a huge pain in the ass in comparison to Lisp.  Lisp is still hands down the most efficient way to do most batch modifications within an AutoCAD session for those who have made the time to learn it.lispide

There are a couple of problems with Visual Lisp right now though.  One of my biggest complaints about the VLIDE is the default colors.  The high contrast white background is an eye killer.   The IDE is configurable though and we’re given full a 16 bit color palette – with which I was able to configure a color scheme that was more to my liking.   If you start Visual Lisp, go to the Tools menu and choose Window Attributes you are presented with the dialog that should let you configure your colors.   Before opening this configuration dialog select a code window in Visual Lisp to modify. Set the properties accordingly. If you are happy with the colors when you press Ok on the dialog you will be prompted to “Use current as EDITOR prototype?”. Clicking yes here will update you editor prototype, resulting in future windows using these defaults.

One key limitation here is that on x64 editions of AutoCAD this dialog is broken.  You may also see the following error when you attempt to close the dialog:

; warning: unwind skipped on exception
; error: Exception occurred: 0xC0000094

**Update May 11th 2012 – This appears to have been fixed in AutoCAD 2013 x64.  Hurray!

It seems that Autodesk has let this code go to some extent. I’ve seen a number of of  people mentioning the unwind error.  This is a shame and partly why I’m writing this post!  First off – if you have an x86 release of AutoCAD you are in luck.  You can configure your IDE no problem using the UI.  For you x64 users, all is not lost.  Lucky for us Visual Lisp saves all this configuration information to a text file named VLIDE.dsk.  On my Vista x64 machine its found in the following locations:

AutoCAD 2006 – C:\Users\dmaidlow\AppData\Roaming\Autodesk\AutoCAD 2006\R16.2\enu

AutoCAD 2009 – C:\Users\dmaidlow\AppData\Roaming\Autodesk\AutoCAD 2009\R17.2\enu

AutoCAD 2010 – C:\Users\dmaidlow\AppData\Roaming\Autodesk\AutoCAD 2010\R18.0\enu

AutoCAD 2011 – C:\Users\dmaidlow\AppData\Roaming\Autodesk\AutoCAD 2011\R18.1\enu

AutoCAD 2012 – C:\Users\dmaidlow\AppData\Roaming\Autodesk\AutoCAD 2012 – English\R18.2\enu

These paths should be the same or similar on Windows 7.

If you open up this file you’ll see a large list of dotted pair lists full of settings.  The one I’m most interested in here is the *editor-sample-window property.  This is the “default” configuration to use when opening a lisp file.

   1: (*editor-sample-window* (:AUTOLISP :FGC 16777215 :BGC 0 :LXC T :CLV #40(nil nil 16711935 nil nil nil 16776960 nil 32768 nil 32768 nil 8421376 nil 8388736 12632256 8388736 12632256 8388736 12632256 255 nil 128 nil 8388608 nil 128 nil 12632256 nil 16777215 0 16777215 16750899 16777215 255 nil 8388608 nil 16776960) :TW 4 :LM 10))

Two values of importance are FGC (foreground color) and BGC (background color).  I was having a hard time finding a color wheel that did integer based color codes – but you can convert your favorite hex color codes to decimal ().  The next bit is a little ugly.  Within the :CLV property we have a list.  This list is basically a list of 16 bit integers containing a color code of the foreground and background color of each window property.  If the color is set to nil – it is transparent.  This list appears to be in the order in which the properties are displayed within the UI:

  • :LEX-SPACE
  • :LEX-STR
  • :LEX-SYM
  • :LEX-NUM
  • :LEX-INT
  • :LEX-REAL
  • :LEX-COMM
  • :LEX-COMM1
  • :LEX-COMM2
  • :LEX-PAREN
  • :LEX-SPEC
  • :LEX-SPEC1
  • :LEX-UNKN
  • :WINDOW-TEXT
  • :WINDOW-SELECTION
  • :ERROR-HIGHLIGHT
  • :INPUT-ZONE
  • :CONSOLE-MESSAGE

TW and LM contain the tab width and left margin respectively.  So go wild editing these values and configure your new IDE!  Keep in mind when editing the Visual Lisp settings using the UI, the vlide.dsk file is not saved  until AutoCAD is shutdown cleanly.  If AutoCAD crashes, you will lose your configuration.  If you would like to try out my IDE settings – I’ve attached a zip file containing  a copy of my .DSK file.  I also recommend you make a backup of the .dsk file before you start tinkering.

Now, if only I could figure out some way to build a vlx file from the command line so as to integrate it into my automated build system..

Update!

For those of you who don’t read the comments – Dennis Hill was cool enough to share his digging into the DSK file and also his IDE colors which I’ve been running for a week or so now.  Take a minute to read the comments and check out his color scheme.  Thanks Dennis!

Technorati Tags: ,,

8 Comments »

  1. [...] Hacking Visual Lisp IDE to be a little more awesome! « GeospeciallingAug 9, 2011 … Hacking Visual Lisp IDE to be a little more awesome! … One key limitation here is that on x64 editions of AutoCAD this dialog is broken. … [...]

    Pingback by Hacking autocad | Seemusicvideos — September 15, 2011 @ 6:00 pm

  2. THANK YOU!!!!!!

    I’ve been hounding Autodesk and the ADN to get the VLIDE context color option fixed for years.
    I also find the default colors to be a horrific eye strain.
    Actually, with your location direction, I was able to copy a 2005 version of my VLIDE.DSK into the enu directory.
    When I restarted Map and the VLIDE, my old color settings were restored so I didn’t have to ‘hack’ the file.
    You might suggest this approach to others who might have an archived or backup copy of a former ‘colorized’ VLIDE.DSK file someplace.

    Thanks again!!

    OS: Windows 7 Pro 64 bit
    AutoCAD Map 3D 2011 64 bit

    Comment by Dennis Hill — September 28, 2011 @ 3:28 pm

  3. Glad I could help Dennis! I wonder if I can track down a copy of R14. (ADN only goes back to 2007! ) I have a feeling this file might be backwards compatible all the way back to this first release of AutoCAD with Visual Lisp. Anyone have that installed still and feel like sending me a copy of the .dsk file? :)

    Comment by Darrin Maidlow — September 28, 2011 @ 3:39 pm

  4. I would expect the VLIDE.DSK file only goes back to the first version of Visual Lisp.
    I don’t recall which AutoCAD release that was, but in R12 it was still called AutoLISP.

    Comment by Dennis Hill — September 28, 2011 @ 6:36 pm

  5. I’ve been exploring this color stuff for a while and I’ve found you can use any RGB color with some manipulation.
    Find the Hex code for the color you want, flip the first and last pairs, convert that value to decimal and use it.
    Think of the VLIDE version of the ‘RGB’ hex color codes as being ‘BGR’.

    Also, you won’t see your new color values until you open a LSP file or create a new one. The file names that are open when you close the VLIDE get stored in the VLIDE.DSK file including the colors they were displayed with, so when you just reopen ACAD & the VLIDE, the files that were open in the previous session will not reflect your changes to the VLIDE.DSK editor-sample-window codes (unless you close and reopen them of course).
    You might be able to use this to experiment with more than one color scheme at a time. Each open LSP file has its own CLV #40 entry in the VLIDE.DSK file. If you change the color values in those lists, you should be able to open the VLIDE and see different color schemes by switching between the open LSP files (I haven’t tried it yet).
    The open file colors are coded using the same format except the Foreground & Background colors and Lexical flag are on separate lines.

    By the way, I also found that the FGC-Foreground & BGC-Background color pairs are in sequence as follows: :LEX-SPACE, :LEX-STR, ????, :LEX-SYM, :LEX-NUM, :LEX-INT, :LEX-REAL, :LEX-COMM, :LEX-COMM1, :LEX-COMM2, :LEX-PAREN, :LEX-SPEC, :LEX-SPEC1, ????, :LEX-UNKN, :WINDOW-TEXT, :WINDOW-SELECTION, BPT-ACTIVE, BPT-DISABLE & :ERROR-HIGHLIGHT. I don’t know what the ???? pairs control; probably a legacy thing. And of course, Nil values are replaced by the applicable FGC/BGC color value and are represented by a check-mark in the ‘Transparent’ box.

    Hope you find this usefull.

    Comment by Dennis Hill — September 29, 2011 @ 2:46 pm

  6. A very in-depth analysis of the contents of the DSK file, thank you very much for sharing that Dennis! R14 was the first version of AutoCAD with Visual Lisp but it was an addon at that time that cost something like 99$ if I recall. It was added as a feature in R15. I believe Autodesk purchased a product named Vital Lisp and added all the needed goodies to AutoCAD to support the ActiveX calls and named it Visual Lisp. Man, what I change it was going from R12 and Lisp to R14 and Visual Lisp. (Yes, with the exception of doing some QA on AutoCAD Map 1, we skipped R13 :]) I remember the guys at Kanotech taking the stack dumps of R12 and trying to figure out where the error occurred. So spoiled now with breakpoints, error handlers, and step through debugging :)

    Comment by Darrin Maidlow — September 29, 2011 @ 8:27 pm

  7. After a lot of experimentation I’ve settled on these colors:
    (*editor-sample-window* (:AUTOLISP :FGC 6155515 :BGC 3686423 :LXC T :CLV #40(nil nil 16777215 nil nil nil 32767 nil 16776960 nil 65280 nil 16711935 nil 16776960 nil 14211215 nil 16776960 nil 12292863 nil 0 nil 13311 nil 128 nil 128 32768 nil nil 0 65535 16777215 255 65535 8388608 16777215 255) :TW 3 :LM 8))
    I’ve always used a tab width of 3 so I can get more code together; you would use :TW 4 :LM 10.
    This is a ways down the street from your colors, but you might try them out. It would at least give you an idea of what’s possible. I focused on keeping things cool and soft, but with enough contrast for the different elements to ‘jump’. I also changed the consol to White on Teal :FGC 16777215 – :BGC 8421376, and I left the Trace window alone.

    By the way, I like to put a descriptive header at the top of my routines so I can make sense of them after I’ve been away for a few months or years. I note what routines it uses and what routines use it (or just “General Utility”), when I worked on it last (AltE-X-R), what it does, and a line of dashes that matches my printers max line width. I set the whole thing off using the ;| and |; comment controls. That way the list is colored by the :LEX-COMM2 setting so it appears different from a standard comment and it also serves as a good visual separator when you’re scrolling through a file with more than one routine in it.

    Thanks again for giving me the ability to escape from those LOUD default colors, recapture my Lisp environment, and even enhance it.

    Comment by Dennis Hill — September 30, 2011 @ 12:17 pm

  8. Hey Dennis – Just had a chance to try out your color scheme and after getting used to the change a bit I really like it. At first it bothered me but I gave it a chance and after adjusting to the new colors I’m pretty happy with them. Thanks for sharing!

    Comment by Darrin Maidlow — October 7, 2011 @ 2:37 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress

Switch to our mobile site