CAD Forums > CAD General

CAD version without opening the drawing?

<< < (2/3) > >>

MP:
I'm kinda surprised no one has anted up a pre-rolled solution as just about every CAD manager / support geek has written one.

Anyway, here's one I have in my library:


--- Code - Auto/Visual Lisp: ---(defun mp-get-dwg-ver ( dwg / handle stream )     ;;  Return the specified drawing's version as a string representing    ;;  the AutoCAD versions that create and support the version natively,    ;;  e.g. "2018/2019/2020/2021". Of course drawings saved by Civil3D    ;;  enjoy a special versioning hell that doesn't precisely follow this    ;;  schema. Thanks Autodesk.     (cond        ((null (setq handle (open dwg "r"))) nil) ;; could not open drawing, return nil        ((progn (setq stream (substr (read-line handle) 1 6))(close handle)))        ((eq "AC1032" stream) "2018/2019/2020/2021")        ((eq "AC1027" stream) "2013/2014/2015/2016/2017")        ((eq "AC1024" stream) "2010/2011/2012")        ((eq "AC1021" stream) "2007/2008/2009")        ((eq "AC1018" stream) "2004/2005/2006")        ((eq "AC1015" stream) "2000/2000I/2002") ;; was 2000i, forced uppercase        ((eq "AC1014" stream) "R14")        ((eq "AC1012" stream) "13")        ((eq "AC1009" stream) "11,12")        ((eq "AC1006" stream) "10")        ((eq "AC1004" stream) "9")        ((eq "AC1003" stream) "2.6")        ((eq "AC1002" stream) "2.5")        ((eq "AC2.10" stream) "2.10")        ((eq "AC1.50" stream) "2.0")        ((eq "AC1.4" (setq stream (substr stream 1 5))) "1.4")        ((eq "AC1.2" stream) "1.2")        ((eq "MC0.0" stream) "1.1")        ("Doesn't appear to be an AutoCAD dwg, cue sad trombone.")    ))
Cheers.

Keith™:
Once upon a time I had a utility that ran in the background that captured the file version and automatically opened it in the correct version so as to prevent users from saving it to a newer file type back when we had several different versions installed. That was 15 years ago .. and sadly, I can no longer find my code repository from back then. I have it, I just don't know where :-/

Crank:
Here's an idea (Q&D):

--- Code: ---(defun dwg-ver ( / handle stream OpenSave)
    (vl-load-com)
    (setq OpenSave (vla-get-preferences (vlax-get-acad-object)))
    (cond
        ((null (setq handle (open (strcat (getvar "DWGPREFIX")(getvar "DWGNAME")) "r"))) nil) ;; could not open drawing, return nil
        ((progn (setq stream (substr (read-line handle) 1 6))(close handle)))
        ((eq "AC1032" stream) (vla-put-saveastype (vla-get-opensave OpenSave) "64")); 2018/2019/2020/2021
        ((eq "AC1027" stream) (vla-put-saveastype (vla-get-opensave OpenSave) "60")); 2013/2014/2015/2016/2017
        ((eq "AC1024" stream) (vla-put-saveastype (vla-get-opensave OpenSave) "48")); 2010/2011/2012
        ((eq "AC1021" stream) (vla-put-saveastype (vla-get-opensave OpenSave) "36")); 2007/2008/2009
        ((eq "AC1018" stream) (vla-put-saveastype (vla-get-opensave OpenSave) "24")); 2004/2005/2006
        ((eq "AC1015" stream) (vla-put-saveastype (vla-get-opensave OpenSave) "12")); 2000/2000i/2002
;        ((eq "AC1014" stream) "R14")
;        ((eq "AC1012" stream) "13")
;        ((eq "AC1009" stream) "11,12")
;        ((eq "AC1006" stream) "10")
;        ((eq "AC1004" stream) "9")
;        ((eq "AC1003" stream) "2.6")
;        ((eq "AC1002" stream) "2.5")
;        ((eq "AC2.10" stream) "2.10")
;        ((eq "AC1.50" stream) "2.0")
;        ((eq "AC1.4" (setq stream (substr stream 1 5))) "1.4")
;        ((eq "AC1.2" stream) "1.2")
;        ((eq "MC0.0" stream) "1.1")
        ("Doesn't appear to be an AutoCAD dwg, cue sad trombone.")
    )
)
--- End code ---

MP:
Ummm no. We have clients that have drawings spanning the 80s to now. That said, abuse it as you see fit, indeed all sample code posted to the swamp enjoys that future. Cheers.

Keith™:

--- Quote from: MP on October 21, 2020, 08:27:09 AM ---Ummm no. We have clients that have drawings spanning the 80s to now. That said, abuse it as you see fit, indeed all sample code posted to the swamp enjoys that future. Cheers.

--- End quote ---


que

I feel like there is a missing post somewhere before this one

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version