Search This Blog

Tuesday, December 14, 2004

Detecting AutoCAD Flavors with vlax-product-key

Are you working with multiple flavors of AutoCAD? Do you want to perform different tasks, set different variables, load different routines based on which application is currently running? Its really quite easy with a little visual lisp and a short conditional. Did you know about the built in function >vlax-product-key ? This function returns the product and language key pair from the registry by querying the active profile. The following example was copied from my acad.lsp file so that it performs certain functions for particular products only on application launch.

I support Architectural Desktop, Land Development Desktop, and Building Systems products. I have been unable to find any documentation for other products, so if you happen to run another product not listed, please comment and include the pair found using vlax-product-key

;;; Get Product Key to detect Product Name and Type
(setq tmpProd (vlax-product-key))
(princ)
;;; Do something depending on which product is chosen
(if (/= (vl-string-search "308:409" tmpProd) nil)
(progn
(setq curProd "LDT2005")
;;; Do something unique for Land Development Desktop Here
(princ)
);progn T
(princ)
)
(if (/= (vl-string-search "306:409" tmpProd) nil)
(progn
(setq curProd "ABS2005")
;;; Do something unique for Building Systems Here
(princ)
);progn T
(princ)
)
(if (/= (vl-string-search "304:409" tmpProd) nil)
(progn
(setq curProd "ADT2005")
;;; Do something unique for Architectural Desktop Here
(princ)
);progn T
(princ)
)
(princ)

I chose to set variables in the example above because the variable will be used in other functions as well. It is really quite simple once you know the pairs. Hopefully we can generate the complete list with a little participation.

1 comment:

Anonymous said...

Having done this ourselves in the past, here are some more numbers for you.

Autocad 2004 English: 201:409
ADT 2004 English: 204:409
MDT 2004 English: 203:409
Mechanical 2004 English: 205:409
Building Systems 2004 English: 206:409
Map 2004 English: ACAD-202:409
LDDT 2004 English: 208:409
Civil Design 2004 English: Same as LDDT
Survey 2004 English: Same as LDDT