With much help from the people on AUGI I finially have what I was looking for.
The following LSP and DCL files will do the following:
When a Read-only copy of any dwg below 2007 is opened an alert button will appear stating that you've opened a dwg that is below an 07 version as read-only.
When a dwg has been opened fully that is below the 2007 version an alert button will appear stating the version number of the dwg that has been opened. Then a large and annoying pop-up will appear with 3 choices: Cancel, Convert to Read-only, or Open.
If they choose cancel, it closes out of the dwg completely (but does not affect any other dwgs they may have open).
If they choose read-only, it will close the original dwg and open a read-only copy of that dwg.
It will then show the "you've opened a read-only copy" alert again.
If they choose open, it will go ahead and open that dwg with full permissions.
This took quite a bit of work and I would like to share it if anyone would find it useful.
If you do use it, I ask that you do credit me with it.
Thank you!
LISP Code:
[code]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is designed to be used with the warnr14.dcl file.
;; They are to be stored locally on the users' machine under the product's support file area.
;; I.E.: C:Program Files_Autodesk Building Systems 2007_Support
;; This program uses the slide image "WarnImage.sld" that is stored here: F:HBEDT2K7_Setup
;; It was created to pop-up a warning when a dwg of a lower version is opened in a 2007 product.
;; The user will get a choice to cancel out of the open, or go ahead with the open.
;; Currently this pop-up will appear if the file is opened full out or read-only.
;; It will not affect any dwgs that are already open in that session of Acad (ADT or ABS).
;; Please do not use-alter-modify this file without contacting Abbie Meador first.
;; Created by Abbie Meador.
;; Special thanks to the AUGI members who helped!
;; Last modified on 10-01-08 by Abbie Meador.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq dwgfile (strcat (getvar "dwgprefix")(getvar "dwgname"))) ;;Setting value to dwfile variable, pulling info from dwg file
(setq rfile (open dwgfile "r")) ;;Set value to rfile
(setq dwgver (substr (read-line rfile) 1 6)) ;;Set value to dwgver by reading version info from dwg file
(close rfile) ;;Closes rfile where dwg version info was stored
(cond ;;Conditions to assign acadv variable text info based off of dwg version
((= dwgver "AC1021") ;;If it is a 2007 version dwg it will automatically close out of this lsp routine
(close)
)
((= dwgver "AC1014")
(setq acadv "AutoCAD R14")
)
((= dwgver "AC1012")
(setq acadv "AutoCAD R13")
)
((= dwgver "AC1009")
(setq acadv "AutoCAD R11 or R12")
)
((= dwgver "AC1006")
(setq acadv "AutoCAD R10")
)
((= dwgver "AC1004")
(setq acadv "AutoCAD R9")
)
((= dwgver "AC1002")
(setq acadv "AutoCAD R2.6")
)
((= dwgver "AC1.50")
(setq acadv "AutoCAD R2.05")
)
((= dwgver "AC1015")
(setq acadv "AutoCAD 2000")
)
((= dwgver "AC1016")
(setq acadv "AutoCAD 2000i")
)
((= dwgver "AC1017")
(setq acadv "AutoCAD 2002")
)
((= dwgver "AC1018")
(setq acadv "AutoCAD 2004")
)
((= dwgver "AC1019")
(setq acadv "AutoCAD 2005")
)
((= dwgver "AC1020")
(setq acadv "AutoCAD 2006")
)
;;;; ((= dwgver "AC1022") ;;For future use the 2008 ad 2009 version info is in here, but commented out
;;;; (setq acadv "AutoCAD 2008")
;;;; )
;;;; ((= dwgver "AC1023")
;;;; (setq acadv "AutoCAD 2009")
;;;; )
) ;;End of condition
(defun is_drawing_read_only (dwgver) ;;Checks to see if dwg has been opened as Read-Only
(if (eq(vla-get-readonly (vla-get-activedocument (vlax-get-acad-object))):vlax-true)
(progn
(if (not(or(or(= dwgver "AC1022")(= dwgver "AC1023"))(= dwgver "AC1021")))
(alert "Congratulations this is a READ-ONLY dwg.") ;;If dwg is Read-Only they get this alert
) ;;End of if
) ;;End of progn
(progn
(if (not(or(or(= dwgver "AC1022")(= dwgver "AC1023"))(= dwgver "AC1021")))
(progn
(alert acadv) ;;If dwg was fully opened they get an alert with the version
(drawing_is_read_write) ;;Calls the Read-Write subfunction
) ;;End of progn
) ;;End of if
) ;;End of progn
) ;;End of if
) ;;End of defun is_drawing_read_only
(defun drawing_is_read_write () ;;Read-Write subfunction
(setq mykey "sld") ;;Naming the slide image
(setq myslidename"F:\\HBEDT2K7\\Setup\\WarnImage.sld") ;;Locating the slide file
(setq dclid (load_dialog "warnr14.dcl")) ;;Loading the DCL file
(new_dialog "warnr14" dclid)
(defun edit_action1 (val)
(setq NT val)
) ;;End of defun
(setq width (dimx_tile mykey)) ;;Get the width of the slide
(setq height (dimy_tile mykey)) ;;Get the height of the slide
(start_image mykey) ;;Start the slide definition
(fill_image 0 0 width height -15) ;;Wipe out the background
(slide_image 0 0 width height myslidename) ;;Put the slide in the image area
(end_image) ;;Finish the slide definition
(action_tile "accept" "(unload_dialog)") ;;Closes dialog and leaves dwg open if Open button from DCL is clicked
(action_tile "readonly" "(setq DwgName (strcat (vla-get-path(vla-get-activedocument(vlax-get-acad-object))) \"/\" (vla-get-name(vla-get-activedocument(vlax-get-acad-object)))))
;;Opens a Read-only copy if the Read-only button is clicked
(done_dialog 1)")
(action_tile "cancel" "(done_dialog)") ;;Closes dialog and dwg if Cancel button from DCL is clicked
(set_tile "mytile" (strcat "YOU JUST OPENED AN " acadv " DWG IN 2007.")) ;;Creates tile to be used on DCL that shows version variable info
(setq ans(start_dialog)) ;;Gets value for ans variable
(unload_dialog dclid)
(if (= ans 1)
(progn ;;This runs a script to close the fully opened original dwg
(setq scrFile (open (strcat (getvar "dwgprefix") "Runme.scr") "w"))
(write-line "(vla-open (vla-get-documents (vlax-get-acad-object))Dwgname :VLAX-TRUE)" scrfile)
(write-line ".close" scrFile)
(write-line "Y" scrFile)
(write-line "(vl-file-delete (strcat (getvar \"dwgprefix\") \"Runme.scr\"))"scrfile)
(close scrFile)
(command ".script" (strcat (getvar "dwgprefix") "Runme.scr")) ;Run the script
) ;;End of progn
(progn
(done_dialog) ;;Finishes dialog box
(command "_.close" "Y") ;;Closes dwg and answers yes to do you really want to close this file question
) ;;End of progn
) ;;End of if
) ;;End of defun drawing_is_read_write
(is_drawing_read_only dwgver)
;;;;
;;;;End of the AutoLISP routine
;;;;
[/code]
DCL Code:
[code]
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// This program is designed to be used with the acaddoc.lsp file.
// They are to be stored locally on the users' machine under the product's support file area.
// I.E.: C:Program Files_Autodesk Building Systems 2007_Support
// This program uses the slide image "WarnImage.sld" that is stored here: F:HBEDT2K7_Setup
// It was created to pop-up a warning when a dwg of a lower version is opened in a 2007 product.
// The user will get a choice to cancel out of the open, or go ahead with the open.
// Currently this pop-up will appear if the file is opened full out or read-only.
// It will not affect any dwgs that are already open in that session of Acad (ADT or ABS).
// Please do not use-alter-modify this file without contacting Abbie Meador first.
// Created by Abbie Meador.
// Special thanks to the AUGI members who helped!
// Last modified on 10-01-08 by Abbie Meador.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////
warnr14 : dialog {label = "WARNING!!! WARNING!!!"; //Controls the text on the pop-up's title
: image { //This creates a stripe or bar of color along the top
key = "im"; //Creating a variable called "im" for this stripe
height = 1.0; //Setting height of stripe to 1
width = 1.0; //Setting width of stripe to 1
color = 1; //Setting color of stripe to 1 = Red
} //Ends stripe "im" creation
:row{ //Creates a row
: image { //Adds in the image from the LSP for the Slide
key = "sld"; //Calls the slide image
height = 0; //Sets the height of the image
width = 15; //Sets the width of the image
color = -15; //Sets the color to the background color -15 = grey
is_enabled = false;
is_tab_stop = false;
} //Ends row for image slide
: paragraph { //Begins a paragraph of text
: text { key = "mytile"; } //Calls the tile created in the LSP to print out in a text line
: text { //If you use text_part { the text lines squish together, this way they have some air b/w them.
label = "Click -Cancel- or -Read-only- to keep from converting your file to an 07 format.";
}
: text {
label = "If you ignore this warning and end up saving this as a 2007 dwg,";
}
: text {
label = "YOU WILL REPAIR THIS FILE ON YOUR OWN TIME!!";
}
} //End paragraph of text
} //End of row
: image { //This creates a stripe or bar of color underneath the paragraph text
key = "im2"; //Creating a variable called "im2" for this stripe
height = 1.0; //Setting height of stripe to 1
width = 1.0; //Setting width of stripe to 1
color = 1; //Setting color of stripe to 1 = Red
} //Ends stripe "im2" creation
: row { //Begins row for buttons
: button { //Begins first button creation
label = "CANCEL"; //Labels first button cancel
key = "cancel"; //Attaches a call of cancel to the button
mnemonic = "C"; //Sets up a keyboard shortcut for the button
alignment = centered; //Alignment of the button
width = 1.0; //Sets width of button
height = 3.0; //Sets height of button
is_default = true; //Sets the default selection to this button...If user hits enter this button will be selected
} //Ends first button
: button { //Begins second button creation
fixed_width = true; //Sets a fixed width of button
fixed_height = true; //Sets a fixed height of button
label = "Read-Only"; //Labels second button open
key = "readonly"; //Attaches a call of readonly to the button
mnemonic = "R"; //Sets up a keyboard shortcut for the button
} //Ends second button
: button { //Begins third button creation
fixed_width = true; //Sets a fixed width of button
fixed_height = true; //Sets a fixed height of button
label = "Open"; //Labels third button open
key = "accept"; //Attaches a call of accept to the button
mnemonic = "O"; //Sets up a keyboard shortcut for the button
} //Ends third button
} //Ends row
} //Ends program
[/code]