TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: rlxozzang on October 09, 2012, 08:46:02 PM

Title: you can check the version of the file dwg?
Post by: rlxozzang on October 09, 2012, 08:46:02 PM
Know that the version of the CAD file, function or system variable?
Title: Re: you can check the version of the file dwg?
Post by: Gu_xl on October 10, 2012, 03:59:48 AM
Code - Auto/Visual Lisp: [Select]
  1. ;;Get Dwg/Dxf file version
  2. ;|'(("AC1.50" "AutoCAD R2.05")
  3.     ("AC1002" "AutoCAD R2.6")
  4.     ("AC1004" "AutoCAD R9")
  5.     ("AC1006" "AutoCAD R10")
  6.     ("AC1009" "AutoCAD R11 or R12")
  7.     ("AC1012" "AutoCAD R13")
  8.     ("AC1014" "AutoCAD R14")
  9.     ("AC1015" "AutoCAD 2000 or 2000i or 2002")
  10.     ("AC1018" "AutoCAD 2004 or 2005 or 2006")
  11.     ("AC1021" "AutoCAD 2007 or 2008 or 2009")
  12.     ("AC1024" "AutoCAD 2010")
  13.   )|;
  14. ;;Test : (DWGVer (getfiled "" "" "dwg;dxf" 8))
  15. (defun DWGVer  (filename / fh cnt dv inp)
  16.   (setq cnt 10
  17.         dv  "")
  18.   (if (setq fh (open filename "r"))
  19.     (progn
  20.       (cond ((= ".DWG" (strcase (VL-FILENAME-EXTENSION filename)))
  21.              (while
  22.                (and
  23.                  (> (setq cnt (1- cnt)) 0)
  24.                  (setq inp (read-char fh))
  25.                  (> inp 0)
  26.                  )
  27.                 (setq dv (strcat dv (chr inp)))
  28.                 )
  29.              )
  30.             ((= ".DXF" (strcase (VL-FILENAME-EXTENSION filename)))
  31.              (repeat 8
  32.              (setq dv (READ-LINE fh))
  33.                )
  34.              )
  35.             )
  36.       (close fh)
  37.       )
  38.     )
  39.   (if (and (> cnt 0) (> (strlen dv) 0))
  40.     dv)
  41.   )
  42.  
Title: Re: you can check the version of the file dwg?
Post by: Lee Mac on October 10, 2012, 07:00:41 AM
Another variation:

Code - Auto/Visual Lisp: [Select]
  1. ;; Get Drawing Version  -  Lee Mac
  2. ;; Returns the version of the supplied filename (dwg/dws/dwt/dxf)
  3.  
  4. (defun LM:getdwgversion ( fn / fd vr )
  5.     (cond
  6.         (   (null
  7.                 (and
  8.                     (setq fn (findfile fn))
  9.                     (setq fd (open fn "r"))
  10.                 )
  11.             )
  12.         )
  13.         (   (wcmatch (strcase fn t) "*`.dw[gst]")
  14.             (setq vr (strcase (substr (read-line fd) 1 6)))
  15.         )
  16.         (   (wcmatch (strcase fn t) "*`.dxf")
  17.             (repeat 7 (read-line fd))
  18.             (setq vr (strcase (read-line fd)))
  19.         )
  20.     )
  21.     (if (= 'file (type fd)) (close fd))
  22.     (cdr
  23.         (assoc vr
  24.            '(
  25.                 ("AC1027" . "2013-2015")
  26.                 ("AC1024" . "2010-2012")
  27.                 ("AC1021" . "2007-2009")
  28.                 ("AC1018" . "2004-2006")
  29.                 ("AC1015" . "2000-2002")
  30.                 ("AC1014" . "Release 14")
  31.                 ("AC1012" . "Release 13")
  32.                 ("AC1009" . "Release 11/12")
  33.                 ("AC1006" . "Release 10")
  34.                 ("AC1004" . "Release 9")
  35.                 ("AC1003" . "Release 2.60")
  36.                 ("AC1002" . "Release 2.50")
  37.                 ("AC1001" . "Release 2.22")
  38.                 ("AC2.22" . "Release 2.22")
  39.                 ("AC2.21" . "Release 2.21")
  40.                 ("AC2.10" . "Release 2.10")
  41.                 ("AC1.50" . "Release 2.05")
  42.                 ("AC1.40" . "Release 1.40")
  43.                 ("AC1.2"  . "Release 1.2")
  44.                 ("MC0.0"  . "Release 1.0")
  45.             )
  46.         )
  47.     )
  48. )

Code - Auto/Visual Lisp: [Select]
  1. ;; Prints the version of the active drawing file
  2.  
  3. (defun c:getversion ( / v )
  4.     (if (zerop (getvar 'dwgtitled))
  5.         (princ "\nThe current drawing is unsaved.")
  6.         (if (setq v (LM:getdwgversion (strcat (getvar 'dwgprefix) (getvar 'dwgname))))
  7.             (princ (strcat "\nThis is an AutoCAD " v " format file."))
  8.             (princ "\nThe format of this file could not be determined.")
  9.         )
  10.     )
  11.     (princ)
  12. )
Title: Re: you can check the version of the file dwg?
Post by: rlxozzang on October 10, 2012, 07:56:08 AM
Thanks Lee-mac, very!! very!! goooooooooooooooooooooooooood ^^ :lmao:
Well as study materials that we will utilize.!
Title: Re: you can check the version of the file dwg?
Post by: Lee Mac on October 10, 2012, 08:09:06 AM
Thanks Lee-mac, very!! very!! goooooooooooooooooooooooooood ^^ :lmao:
Well as study materials that we will utilize.!

 :-)
Title: Re: you can check the version of the file dwg?
Post by: jbuzbee on October 10, 2012, 04:24:35 PM
Why is Release 1.0 "MC0.0"?  Did AutoDESK purchase AutoCAD from another vendor?
Title: Re: you can check the version of the file dwg?
Post by: Lee Mac on October 10, 2012, 04:34:22 PM
Why is Release 1.0 "MC0.0"?  Did AutoDESK purchase AutoCAD from another vendor?

Quote from: Wikipedia Article on DWG format
DWG (denoted by the .dwg filename extension) was the native file format for the Interact CAD package, developed by Mike Riddle in the late 1970s, and subsequently licensed by Autodesk in 1982 as the basis for AutoCAD.

[potentially unreliable] Source (http://en.wikipedia.org/wiki/.dwg)
Title: Re: you can check the version of the file dwg?
Post by: rlxozzang on October 10, 2012, 08:59:37 PM
Why is Release 1.0 "MC0.0"?  Did AutoDESK purchase AutoCAD from another vendor?

Quote from: Wikipedia Article on DWG format
DWG (denoted by the .dwg filename extension) was the native file format for the Interact CAD package, developed by Mike Riddle in the late 1970s, and subsequently licensed by Autodesk in 1982 as the basis for AutoCAD.

[potentially unreliable] Source (http://en.wikipedia.org/wiki/.dwg)
thank you!!  :laugh:
Title: Re: you can check the version of the file dwg?
Post by: Lee Mac on October 11, 2012, 08:45:15 AM
You're welcome  :-)