PDA

View Full Version : autocad version in text field



jeff.smith
2011-01-21, 08:37 PM
Does anyone know if AutoCAD allows you to insert a field using text that tells you what version AutoCAD the drawing is save as?

cadtag
2011-01-21, 11:55 PM
well, you could use the System Variable "acadver" in a field, which will tell you the version of AutoCAD currently running, which also happens to _always_ be the version that the active drawing is in.

If you want something that will tell you what it was before your opened it, then no. You would have to do that outside the AutoCAD editor. Possibly ObjectDBX, read the information, and write it to DWGProps ?

Opie
2011-01-27, 03:38 PM
When you open the drawing the dwg version is displayed on the text screen. You can also open the drawing in a text editor and check the first 6 characters of the file. You can cross reference that information with the list of values (http://autodesk.blogs.com/between_the_lines/autocad-release-history.html) provided by Shaan Hurley.

BlackBox
2011-01-27, 06:29 PM
(defun c:GETVRSN (/ f line vrsn)
(if (and (= 1 (getvar 'dwgtitled))
(setq f
(open (strcat (getvar 'dwgprefix) (getvar 'dwgname)) "r"))
(setq line (read-line f))
(not (close f)))
(prompt
(cond
((= "AC1015" (setq vrsn (substr line 1 6)))
(setq vrsn
"\n\n >> DWG from AutoCAD 2000/2000i/2002 (or LT, Map or relative Desktop version) "))
((= "AC1018" vrsn)
(setq vrsn
"\n\n >> DWG from AutoCAD 2004/2005/2006 (or other product in the \"2004\", \"2005\" or \"2006\" family) "))
((= "AC1021" vrsn)
(setq vrsn
"\n\n >> DWG from AutoCAD 2007/2008/2009 (or other product of the \"2007\", \"2008\" and \"2009\" families) "))
((= "AC1024" vrsn)
(setq vrsn
"\n\n >> DWG from AutoCAD 2010 (or other product of the \"2010\" family) "))
((setq vrsn "\n <!> Invalid Drawing Version <!> ")))))
(princ))

BlackBox
2011-01-27, 06:35 PM
Perhaps adding this to your ACADDOC.lsp would prove more useful?



;;;--------------------------------------------------------------------;
;;; Show autocad file format version function:
(defun c:SHOWVRSN (/ f line vrsn)
(if (and (= 1 (getvar 'dwgtitled))
(setq f
(open (strcat (getvar 'dwgprefix) (getvar 'dwgname)) "r"))
(setq line (read-line f))
(not (close f)))
(setvar
'modemacro
(cond
((= "AC1015" (setq vrsn (substr line 1 6)))
(setq vrsn
"Drawing Format >> DWG from AutoCAD 2000/2000i/2002 (or LT, Map or relative Desktop version) "))
((= "AC1018" vrsn)
(setq vrsn
"Drawing Format >> DWG from AutoCAD 2004/2005/2006 (or other product in the \"2004\", \"2005\" or \"2006\" family) "))
((= "AC1021" vrsn)
(setq vrsn
"Drawing Format >> DWG from AutoCAD 2007/2008/2009 (or other product of the \"2007\", \"2008\" and \"2009\" families) "))
((= "AC1024" vrsn)
(setq vrsn
"Drawing Format >> DWG from AutoCAD 2010 (or other product of the \"2010\" family) "))
((setq vrsn "\n <!> Invalid Drawing Version <!> ")))))
(princ))
;;;--------------------------------------------------------------------;
;;; Autorun SHOWVRSN function:
(c:SHOWVRSN)
;;;--------------------------------------------------------------------;
(princ)

cadtag
2011-01-27, 06:50 PM
(defun c:GETVRSN (/ f line vrsn)
(if (and (= 1 (getvar 'dwgtitled))....))



That's rather nice! Opening an open drawing ... slick.

-- can you think of anyway to identify the version of the vertical in that drawing? eg C3d 2008 vs c3d 2007 ?

BlackBox
2011-01-27, 07:04 PM
That's rather nice! Opening an open drawing ... slick.

I do what I can... and strive for more.



-- can you think of anyway to identify the version of the vertical in that drawing? eg C3d 2008 vs c3d 2007 ?

Hmmmm.... Very interesting-k, Comrad Cadtag. Very interesting-k.
(in a russian accent)

Success of this will obviously vary, depending on the user's setup, but in my case this will work:



(defun c:SHOWVRSN (/ f line vrsn appName)
(vl-load-com)
(if (and
(= 1 (getvar 'dwgtitled))
(setq f
(open (strcat (getvar 'dwgprefix) (getvar 'dwgname)) "r"))
(setq line (read-line f))
(not (close f))
(setq appName (vla-get-name (vlax-get-acad-object)))
(cond
((vl-string-search "R16.2" (setq vrsn (vlax-product-key)))
(setq appName (strcat appName " 2006"))) ; 2006
((vl-string-search "R17.0" vrsn)
(setq appName (strcat appName " 2007"))) ; 2007
((vl-string-search "R17.1" vrsn)
(setq appName (strcat appName " 2008"))) ; 2008
((vl-string-search "R17.2" vrsn)
(setq appName (strcat appName " 2009"))) ; 2009
((vl-string-search "R18.0" vrsn)
(setq appName (strcat appName " 2010"))) ; 2010
((vl-string-search "R18.1" vrsn)
(setq appName (strcat appName " 2011"))))) ; 2011
(setvar
'modemacro
(cond
((= "AC1015" (setq vrsn (substr line 1 6)))
(setq vrsn
(strcat appName
" >> Drawing Format >> "
" 2000/2000i/2002")))
((= "AC1018" vrsn)
(setq vrsn
(strcat appName
" >> Drawing Format >> 2004/2005/2006 ")))
((= "AC1021" vrsn)
(setq vrsn
(strcat appName
" >> Drawing Format >> 2007/2008/2009 ")))
((= "AC1024" vrsn)
(setq vrsn
(strcat appName
" >> Drawing Format >> 2010 ")))
((setq vrsn "\n <!> Invalid Drawing Version <!> ")))))
(princ))


Edit: Although, this displays what application is opening the drawing, as oposed to which application created the drawing.

Hmmm.... I may have to get back to you.

BlackBox
2011-01-27, 07:32 PM
-- can you think of anyway to identify the version of the vertical in that drawing? eg C3d 2008 vs c3d 2007 ?

I'm at a loss.... I've revised the code to detect which version year application has opened the drawing, and paired that with the (vla-get-name (vlax-get-acad-object)), but that does not meet your request for which application (and version year) last saved the drawing.

Edit: Code revised above.

If only I knew where to look, I could cull that information. :(

cadtag
2011-01-27, 07:42 PM
huhmm,,,, if it's possible to open an open drawing in lsp for READ access, perhaps ObjectDBX could open that same open drawing and pull the acvadver setvar info?

an ugly kludge if not, could be to copy the dwg file to the TEMP folder, and then use ObjectDBX to open and read. of course, that would be a bear on big files

BlackBox
2011-01-27, 08:23 PM
huhmm,,,, if it's possible to open an open drawing in lsp for READ access, perhaps ObjectDBX could open that same open drawing and pull the acvadver setvar info?

an ugly kludge if not, could be to copy the dwg file to the TEMP folder, and then use ObjectDBX to open and read. of course, that would be a bear on big files

Using ObjectDBX (ODBX) does not expose any new properties/methods from which to extract the necessary information... Keep in mind, the drawing is already open, and is not subject to the limitations of ODBX (no selection sets, standard commands, etc.).

Besides, if the information needed is already part of the drawing file itself, then there should be a means of locating it via the object model's properties and methods (without ODBX)... if not perhaps it is stored in the registry?

Edit: Also, ODBX cannot open the ActiveDocument (again).

Again, if only I knew where to look... in the registry (if not within the ActiveDocument object itself).

Opie
2011-02-02, 08:07 PM
You might look into RegApps. You would need to manually compare the different ids that are available between the two versions to maybe be able to use them. Just a thought.

arshiel88
2011-02-09, 10:07 AM
in VBA




Sub ReadWriteVersion()

Dim TextLine$, Filename$, SaveVersion
Dim FileHandle As Integer

Filename$ = ThisDrawing.path + "\" + ThisDrawing.Name

' Test if the file exists
If Dir(Filename$) = "" Then
MsgBox "Please save the file first before using this utility."
Exit Sub
End If

FileHandle = FreeFile

Open Filename$ For Input As #FileHandle

Line Input #FileHandle, TextLine$

Select Case Left(TextLine$, 6)

Case "AC1014"
MsgBox "File version is AutoCAD R14"
SaveVersion = "ver. AutoCAD R14"
Case "AC1015"
MsgBox "File version is AutoCAD 2000"
SaveVersion = "ver. AutoCAD 2000"
Case "AC1018"
MsgBox "File version is AutoCAD 2004"
SaveVersion = "ver. AutoCAD 2004"
Case "AC1021"
MsgBox "File version is AutoCAD 2007"
SaveVersion = "ver. AutoCAD 2007"
Case "AC1024"
MsgBox "File version is AutoCAD 2010"
SaveVersion = "ver. AutoCAD 2010"

End Select

Close #FileHandle

On Error Resume Next
With ThisDrawing.SummaryInfo
.RemoveCustomByKey "SaveVersion"
.AddCustomInfo "SaveVersion", SaveVersion
End With

End Sub




This will create a custom document property "SaveVersion" then you can use

%<\AcVar CustomDP.SaveVersion>% in a text field.

arshiel88
2011-02-20, 07:00 AM
I have attach the .dvb file. paste it in a directory in your support search paths then add

(command "vbarun" "ReadWriteVersion.dvb!ReadWriteMacros.ReadWriteVersion")

in your acad####doc.lsp so that SaveVersion updates upon opening the drawing.

Use SaveVersion field in Document field category.

Opie
2011-02-21, 03:24 PM
Shielbern, please do not use the acad####doc.lsp file for your autoload needs. You might have a look at Comparing the acad*.lsp files (http://usa.autodesk.com/adsk/servlet/ps/dl/item?siteID=123112&id=2897258&linkID=9240617). It appears it was written for AutoCAD 2000, but it works for all versions since then.

arshiel88
2011-02-21, 07:37 PM
I'm really not into AutoLisp. Honestly, I don't know the difference of these files. Sorry if I broke some protocols, All I know is that It loads in startup. :D I'll check on that article. Thanks for the info Opie.