Hello bloggers!
With the help of some knowledgeable people on AUGI.com (thank you Lions60 & rkmcswain!!) I believe I have a solid working version of this pop-up that we've been needing.
Here's what it does: When opening a dwg (be it read-only or a full on open) this pop-up will appear if the dwg is any version below 2007). The pop-up will state what version the dwg is and ask if you really want to open. If you press cancel it closes that dwg out, but all other dwgs that you have open in that session are unaffected. If you press open, it will go ahead and let you open the dwg as you had chosen (either full on or read-only depending upon what you picked in the beginning). If you try to click on the "x" button to close out of the dialog box it will not work. The user is forced to either choose cancel or open. The cancel button is set as the default choice, so if the user just hits the enter key it will be selecting cancel and close the dwg out.
I have also have it showing an image on the dialog box (just for fun). That's a whole different post on how to do that....I had never made a slide before so that was a learning experience all on its own.
If you decide for some reason that you would like to use this code (LSP and/or DCL), or any portion of it please make sure you credit me for it.
Thank you!
Here is the DCL File:
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
//
// 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.
// Last modified on 09-26-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_part {
label = "Verify this file is Read-only before clicking 'Open' (Check the header).";
}
: text_part {
label = "If you ignore this warning and end up saving this as a 2007 dwg,";
}
: text_part {
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 = 0.5; //Sets width of button
height = 3; //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 = "Open"; //Labels second button open
key = "accept"; //Attaches a call of accept to the button
mnemonic = "O"; //Sets up a keyboard shortcut for the button
} //Ends second button
} //Ends row
} //Ends program
Here is the LSP File:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; 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.
;; Last modified on 09-26-08 by Abbie Meador.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq mykey "sld") ;;Naming the slide image
(setq myslidename "F:\\HBEDT2K7\\Setup\\WarnImage.sld") ;;Locating the slide file
(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
(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 "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
(start_dialog) ;;Starts dialog box
(done_dialog) ;;Finishes dialog box
(command "_.close") ;;Closes dwg
(command "y") ;;Answers yes to do you really want to close this file question
(unload_dialog dclid) ;;Unloads dialog box
;;;;
;;;;End of the AutoLISP routine
;;;;
This blog is to share information I have gathered while transitioning from R14 to ABS 2007 to R-MEP 2012 and any other noteworthy nerd type information.
Friday, September 26, 2008
Wednesday, September 24, 2008
LSP and DCL
Good morning Bloggers!
I have taken on a task that is challenging to me. I have never created LSP or DCL codes before.
We have a huge need to create a pop-up dialog box that warns people that they are opening an R14 dwg inside of the 07 product. We have had too many projects get overwritten into 07 and the saving down/exporting/converting...you name it, there is no sufficient fix. We want them to stop doing it altogether.
If any of you can comment/contact me if you have suggestions and/or answers to my questions this would just rock!
My questions are this:
1. How do I add a .bmp image (that is stored on a network drive) to show up in the dialog box? (It is stored here: F:\HBEDT2K7\Setup\WarnImage.bmp)
2. How do I change the font of the text that appears in the dialog box? I would like to make the font larger, bolder, and perhaps a different font style altogether.
3. How do I change the color of the font? How do I change the color of the "buttons"? How do I change the color of the background of the dialog box? Basically what are all the ways to manipulate colors in the dialog box.
4. How do I get my dialog box to print out the "acadv" variable? I want it to state something along the lines of: Warning you have just opened a "acadv" dwg.... Is this possible?
Here is my current LSP file
;;;;
;;;;Beginning of the AutoLISP routine
;;;
(setq dwgfile (strcat (getvar "dwgprefix")(getvar "dwgname")))
(setq rfile (open dwgfile "r"))
(setq dwgver (substr (read-line rfile) 1 6))
(close rfile)
(cond
((= dwgver "AC1021")
(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")
;;;; (setq acadv "AutoCAD 2008")
;;;; )
;;;; ((= dwgver "AC1023")
;;;; (setq acadv "AutoCAD 2009")
;;;; )
)
(setq dclid (load_dialog "warnr14.dcl"))
(new_dialog "warnr14" dclid)
(defun edit_action1 (val)
(setq NT val)
)
(action_tile "accept" "(unload_dialog)")
(action_tile "cancel" "(done_dialog)")
(start_dialog)
(done_dialog)
(command "_.close")
(command "y")
(unload_dialog dclid)
)
;;;;
;;;;End of the AutoLISP routine
Here is my DCL code:
warnr14 : dialog {
label = "WARNING!!! WARNING!!!";
: image {
key = "im";
height = 1.0;
width = 1.0;
}
: paragraph {
: text_part {
label = "YOU JUST OPENED AN R14 DWG IN 2007.";
}
: text_part {
label = "Verify this file is Read-only before clicking 'Open' (Check the header).";
}
: text_part {
label = "If you ignore this warning and end up saving this as a 2007 dwg, YOU WILL REPAIR THIS FILE ON YOUR OWN TIME!!";
}
}
: image {
key = "im2";
height = 1.0;
width = 1.0;
}
: row {
: button {
label = "CANCEL";
key = "cancel";
mnemonic = "C";
alignment = centered;
width = 0.5;
height = 3;
is_default = true;
}
: button {
fixed_width = true;
fixed_height = true;
label = "Open";
key = "accept";
mnemonic = "O";
}
}
}
I have taken on a task that is challenging to me. I have never created LSP or DCL codes before.
We have a huge need to create a pop-up dialog box that warns people that they are opening an R14 dwg inside of the 07 product. We have had too many projects get overwritten into 07 and the saving down/exporting/converting...you name it, there is no sufficient fix. We want them to stop doing it altogether.
If any of you can comment/contact me if you have suggestions and/or answers to my questions this would just rock!
My questions are this:
1. How do I add a .bmp image (that is stored on a network drive) to show up in the dialog box? (It is stored here: F:\HBEDT2K7\Setup\WarnImage.bmp)
2. How do I change the font of the text that appears in the dialog box? I would like to make the font larger, bolder, and perhaps a different font style altogether.
3. How do I change the color of the font? How do I change the color of the "buttons"? How do I change the color of the background of the dialog box? Basically what are all the ways to manipulate colors in the dialog box.
4. How do I get my dialog box to print out the "acadv" variable? I want it to state something along the lines of: Warning you have just opened a "acadv" dwg.... Is this possible?
Here is my current LSP file
;;;;
;;;;Beginning of the AutoLISP routine
;;;
(setq dwgfile (strcat (getvar "dwgprefix")(getvar "dwgname")))
(setq rfile (open dwgfile "r"))
(setq dwgver (substr (read-line rfile) 1 6))
(close rfile)
(cond
((= dwgver "AC1021")
(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")
;;;; (setq acadv "AutoCAD 2008")
;;;; )
;;;; ((= dwgver "AC1023")
;;;; (setq acadv "AutoCAD 2009")
;;;; )
)
(setq dclid (load_dialog "warnr14.dcl"))
(new_dialog "warnr14" dclid)
(defun edit_action1 (val)
(setq NT val)
)
(action_tile "accept" "(unload_dialog)")
(action_tile "cancel" "(done_dialog)")
(start_dialog)
(done_dialog)
(command "_.close")
(command "y")
(unload_dialog dclid)
)
;;;;
;;;;End of the AutoLISP routine
Here is my DCL code:
warnr14 : dialog {
label = "WARNING!!! WARNING!!!";
: image {
key = "im";
height = 1.0;
width = 1.0;
}
: paragraph {
: text_part {
label = "YOU JUST OPENED AN R14 DWG IN 2007.";
}
: text_part {
label = "Verify this file is Read-only before clicking 'Open' (Check the header).";
}
: text_part {
label = "If you ignore this warning and end up saving this as a 2007 dwg, YOU WILL REPAIR THIS FILE ON YOUR OWN TIME!!";
}
}
: image {
key = "im2";
height = 1.0;
width = 1.0;
}
: row {
: button {
label = "CANCEL";
key = "cancel";
mnemonic = "C";
alignment = centered;
width = 0.5;
height = 3;
is_default = true;
}
: button {
fixed_width = true;
fixed_height = true;
label = "Open";
key = "accept";
mnemonic = "O";
}
}
}
Wednesday, September 17, 2008
Water
It has been awhile since I have posted.
We've gotten our fair share of "fall-out" from the leftovers of Ike (nothing like those hit in TX though). Flash flood really does mean Flash flood!
I am working on a way to get a warning box to pop-up when our users try to open a dwg that is a different version than 07 (aka trying to ward off those people opening R14 dwgs in 07).
I've been busy attempting to piece together .lsp's and .dcl's to get this to work. I've even had someone mention to me to use a .scr file to obtain the results I am looking for.
I'll keep you all posted on what happens. It would be a cool tool if I can get it to do everything that I want it to do. I'd like it to state what version the dwg is that they are trying to open and have a button to cancel, ok, and read-only (which would convert it from the regular open to a read-only open)--tricky, eh? I also want it to know whether or not they tried opening it as read only.
If anyone out there knows of how to accomplish this successfully or is interested in helping or learning please post a comment and I'll be sure to contact you.
Thanks!
We've gotten our fair share of "fall-out" from the leftovers of Ike (nothing like those hit in TX though). Flash flood really does mean Flash flood!
I am working on a way to get a warning box to pop-up when our users try to open a dwg that is a different version than 07 (aka trying to ward off those people opening R14 dwgs in 07).
I've been busy attempting to piece together .lsp's and .dcl's to get this to work. I've even had someone mention to me to use a .scr file to obtain the results I am looking for.
I'll keep you all posted on what happens. It would be a cool tool if I can get it to do everything that I want it to do. I'd like it to state what version the dwg is that they are trying to open and have a button to cancel, ok, and read-only (which would convert it from the regular open to a read-only open)--tricky, eh? I also want it to know whether or not they tried opening it as read only.
If anyone out there knows of how to accomplish this successfully or is interested in helping or learning please post a comment and I'll be sure to contact you.
Thanks!
Subscribe to:
Posts (Atom)