by Bill Fane
A reader was wondering, "Is there a sysvar (or any other way) for AutoLISP to determine if a vertical such as Civil 3D is running?"
An initial response was, "No sysvar or regular Lisp routine does this. I suspect it's available in the higher order APIs, like ARx or VLX."
Then I found it. The menu system for Civil 3D is quite different from generic AutoCAD. The following bit of code...
(setq VERT (getvar "menuname")
VERT (substr VERT (- (strlen VERT) 2)
)
)
...returns the last three characters of the full path/name of the current menu. This is "c3d" for Civil 3D and "cad" for generic AutoCAD. I assume similar results would come from other AutoCAD-based verticals.
I can't guarantee that it is 100% reliable, because it turns out that generic AutoCAD has 11 menu files in its support folder while Civil 3D has 26. Now for the interesting bit; all AutoCAD menus are also in the Civil 3D folder, which is logical, because Civil 3D can be switched back and forth between Civil 3D and generic AutoCAD by switching profiles.
Further complicating matters is the fact the MENULOAD command shows that 6 are loaded into generic AutoCAD and 10 into Civil 3D, with some overlaps. My only hope is that MENULOAD seems to display additional customization menu files that have been loaded. It does not seem to display the "Main customization file" which is what is returned by (getvar "menuname") so my routine is probably correct, but as I said I can't 100% guarantee it.
As indicated in the comments, it probably returns an appropriate value for other verticals. Here is an the LISP routine indented with comments:
;; Variable VERT contains the last 3 path/filename
;; characters of the to the current menu file:
;; "cad" = AutoCAD
;; "c3d" = Civil 3D
;; Other vertical apps probably return suitable
;; appropriate values.
;; by Bill Fane
;; 19 December 2016(setq VERT (getvar "menuname")
VERT
(substr
VERT
(- (strlen VERT) 2)
)
)
Here are some alternative solutions: http://blog.jtbworld.com/2013/10/how-to-know-what-service-pack-is.html
Posted by: Jimmy Bergmark - JTB World | Jan 04, 2017 at 11:27 PM
Yeah, can't really use MENUNAME because that assumes a vanilla setup. Our environment isn't vanilla and anything using MENUNAME to determine the vertical will have a 100% failure rate. Jimmy's registry read suggestions are the way to go.
Posted by: Steve Johnson | Jan 09, 2017 at 12:40 AM
Agree with Steve that Jimmy's page is the way to go.
If you could not do that for some reason, and you knew what product you were testing for, you could do something like this, to test for the presence of a certain program file, like this
Posted by: R.K. McSwain | Jan 25, 2017 at 05:26 AM