;*******************************ATGL.LSP****************************************
; Written By : Peter Jamtgaard offerd for public use NO WARRANTY
; Purpose : Attribute Global Change for Value, Height, Angle, Style,
; : Layer, Color, Width, or (Increment or Multiply Numeric values)
; Instructions: Enter Block Name, Value, and Tag Specifications.
; : Then Select BLOCKS (Note: NOT Attributes) then select
; : the Characteristic you wish to change.
;*******************************************************************************
(defun C:AGC ()
(setq Y 0 B 0 C 0 KIND 0)
(setq CMDDIA (getvar "CMDDIA"))
(if (= CMDDIA 0)
(progn
(princ "\nDialog Box Disabled by CMDDIA. ")
(princ "\nBlock Name Specification? : ")
(setq BNS (strcase (getstring)))
(if (= BNS "")(setq BNS "*"))
(princ "Attribute Value Specification? : ")
(setq AVS (strcase (getstring)))
(if (= AVS "")(setq AVS "*"))
(princ "Attribute Tag Specification? : ")
(setq ATS (strcase (getstring)))
(if (= ATS "")(setq ATS "*"))
(atgl2)
)
(progn
(setq BNS "*" AVS "*" ATS "*")
(setq id (load_dialog "atgl.dcl"))
(new_dialog "atgl" id)
(set_tile "string1" "")
(set_tile "string2" "")
(set_tile "title" "Block Name Specification? ")
(set_tile "string" BNS)
(action_tile "string" "(setq BNS (strcase (get_tile \"string\")))")
(if (= 1 (start_dialog))
(progn
(done_dialog)
(new_dialog "atgl" id)
(set_tile "string1" "")
(set_tile "string2" (strcat "Block Name Specification? " BNS))
(set_tile "title" "Attribute Value Specification? ")
(set_tile "string" AVS)
(action_tile "string" "(setq AVS (strcase (get_tile \"string\")))")
(if (= 1 (start_dialog))
(progn
(done_dialog)
(new_dialog "atgl" id)
(set_tile "string1" "")
(set_tile "string1" (strcat "Block Name Specification? " BNS))
(set_tile "string2" (strcat "Attribute Value Specification? " AVS))
(set_tile "title" "Attribute Tag Specification ? ")
(set_tile "string" ATS)
(action_tile "string" "(setq ATS (strcase (get_tile \"string\")))")
(if (= 1 (start_dialog))
(progn
(done_dialog)
(atgl2)
)
(done_dialog)
)
)
(done_dialog)
)
)
(done_dialog)
)
)
)
(prin1)
)
(defun ATGL2 ()
(princ "Select Blocks with Attributes: ")
(SELSET)
(if (= CMDDIA 0)
(progn
(princ "Angle/Color/Height/Increment/Layer/Multiply/Rotate/Style/Value/Width/chT: ")
(setq SD 1)
(setq TRAIT1 (strcase (getstring)) KIND 0)
(setq TRAIT1 (substr TRAIT1 1 1))
(if (= TRAIT1 "V")
(setq STRING3 (getstring T "\nNew Value: ") ASO 1 KIND 0)
(if (= TRAIT1 "T")
(progn
(setq OS (getstring T "\nOld String: ") ASO 1 KIND 0 SD 1
NS (getstring T "\nNew String: "))
)
(if (= TRAIT1 "H")
(setq NUMBER1 (getreal "\nNew Height: ") ASO 40 KIND 1)
(if (= TRAIT1 "A")
(setq NUMBER1 (/ (* (getreal "\nNew Angle: ") PI) 180) ASO 50 KIND 1)
(if (= TRAIT1 "S")
(setq STRING3 (getstring "\nNew Style: ") ASO 7)
(if (= TRAIT1 "L")
(setq STRING3 (getstring T "\nNew Layer: ") ASO 8)
(if (= TRAIT1 "C")
(setq NUMBER1 (getint "\nNew Color: ") KIND 1 ASO 62)
(if (= TRAIT1 "W")
(setq NUMBER1 (getreal "\nNew Width: ") KIND 1 ASO 41)
(if (= TRAIT1 "I")
(progn
(setq INCR (getreal "\nIncrement: "))
(setq DEC (getint "\nDecimal Point Number [0]: ") KIND 0 ASO 1)
(if (= DEC nil)(setq DEC 0))
)
(if ( = TRAIT1 "M")
(progn
(setq MULTP (getreal "\nMultiplier: "))
(setq DEC (getint "\nDecimal Point Number [0]: ") KIND 0 ASO 1)
(if (= DEC nil)(setq DEC 0))
)
(if (= TRAIT1 "R")
(setq NUMBER1 (/ (* (getreal "\nNew Angle: ") PI) 180) ASO 50 KIND 1)
(setq B 1)
)
)
)
)
)
)
)
)
)
)
)
(PRINC "*")
(atgl3)
)
(ddatgl2)
)
)
(defun ATGL3 ()
(setq B 0 C 0 X 0)
(while (= B 0)
(setq ENT (ssname SSET C))
(if (= ENT nil)(setq B 1)
(progn
(setq ED (entget ENT))
(setq TYPE1 (cdr (assoc 0 ED)))
(if (= TYPE1 "INSERT")
(progn
(setq BLOCK (cdr (assoc 2 ED)))
(if (wcmatch BLOCK BNS)
(progn
(setq X 0)
(setq NENT (entnext ENT))
(setq NED (entget NENT))
(setq NTYPE (cdr (assoc 0 NED)))
(if (= NTYPE "ATTRIB")
(progn
(setq flag 0)
(while (= X 0)
(if (= NENT nil)(setq X 1)
(progn
(setq FLAG1 0)
(setq FLAG2 0)
(setq NAM (cdr (assoc 1 NED)))
(if (= TRAIT1 "I")(setq STRING3 (rtos (+ INCR (atof NAM)) 2 DEC)))
(if (= TRAIT1 "M")(setq STRING3 (rtos (* MULTP (atof NAM)) 2 DEC)))
(SETQ TAG (cdr (assoc 2 NED)))
(if (= ATS "*")(setq FLAG1 1))
(if (WCMATCH TAG ATS)(setq FLAG1 1))
(if (= TAG ATS)(setq FLAG1 1))
(if (= AVS "*")(setq FLAG2 1))
(if (WCMATCH NAM AVS)(setq FLAG2 1))
(if (= NAM AVS)(setq FLAG2 1))
(if (= FLAG2 1)
(if (= FLAG1 1)
(if (= KIND 0)
(if (/= TRAIT1 "T")
(setq NED (subst (cons ASO STRING3)(assoc ASO NED) NED))
(atglswap OS NS)
)
(progn
(if (= ASO 62)
(progn
(if (or (> NUMBER1 256)( DEC 8)(setq DEC 8))
(if ( DEC 8)(setq DEC 8))
(if (< DEC 0)(setq DEC 0))
(atgl3)
)
(defun ATGLVALUE ()
(setq STRING3 "")
(new_dialog "atglvalue" id)
(set_tile "V" STRING3)
(action_tile "V" "(setq STRING3 (get_tile \"V\"))")
(start_dialog)
(atgl3)
)
(defun ATGLWIDTH ()
(setq NUMBER1 1.0)
(new_dialog "atglwidth" id)
(set_tile "W" "1.0")
(action_tile "W" "(setq NUMBER1 (atof $value))")
(start_dialog)
(done_dialog)
(atgl3)
)
(defun ATGLSTYLE ()
(atglstyle2)
(setq STYLIST (SORTLIST STYLIST))
(ddatgls)
(atglstyle3)
(setq STRING3 STYLE)
(atgl3)
)
(defun SELSET ()
(setq SSET nil)
(while (= SSET nil)
(setq SSET (ssget))
(if (= SSET nil)
(princ "\nNull selection set please try again:")
)
)
)
(defun ATGLSTYLE2 ()
(setq B 0 C 0)
(while (= B 0)
(if (= C 0)
(progn
(setq STYLEL (tblnext "style" 1))
(setq STYLIST (list (cdr (assoc 2 STYLEL))))
(setq C 1)
)
(progn
(setq STYLEL (tblnext "style"))
(if (= STYLEL nil)(setq B 1)
(progn
(setq STYLIST (append STYLIST (list (cdr (assoc 2 STYLEL)))))
)
)
)
)
)
)
(defun ATGLCHT ()
(setq CMDDIA (getvar "CMDDIA"))
(if (= CMDDIA 0)
(progn
(princ "\nDialog Box Disabled by CMDDIA. ")
(setq OS (getstring T "\nEnter Old String: "))
(setq NS (getstring T "\nEnter New String: "))
(swapstring)
)
(progn
(setq OS "" NS "")
(new_dialog "atglcht" id)
(set_tile "oldstring" "")
(set_tile "title" "Old String: ")
(set_tile "string" "")
(action_tile "string" "(setq OS (get_tile \"string\"))")
(if (= 1 (start_dialog))
(progn
(done_dialog)
(new_dialog "atglcht" id)
(set_tile "oldstring" (strcat "Old String: " OS))
(set_tile "title" "New String: ")
(set_tile "string" "")
(action_tile "string" "(setq NS (get_tile \"string\"))")
(if (= 1 (start_dialog))
(progn
(done_dialog)
(atgl3)
)
(done_dialog)
)
)
(done_dialog)
)
)
)
(prin1)
)

(defun DDATGLS ()
(setq STYLENUM 0)
(setq id (load_dialog "atgl.dcl"))
(new_dialog "atglstyle" id)
(start_list "styles")
(mapcar 'add_list stylist)
(end_list)
(set_tile "styles" "0")
(action_tile "styles" "(setq STYLENUM (atoi $value))")
(start_dialog)
(done_dialog)
(setq STYLE (nth STYLENUM STYLIST))
)
(defun SORTLIST (LIST1)
(setq B 0)
(while (= B 0)
(setq C 1 D 0 E 0)
(setq PART1 (nth 0 LIST1))
(repeat (- (length LIST1) 1)
(setq PART2 (nth C LIST1))
(if ( C2 LNL)(setq B2 1))
)
(setq NED (subst (cons 1 NLN)(assoc 1 NED) NED))
(entmod NED)
(entmod ED)
)
)
)

;******************************************************************************
(defun SELSET ()
(setq SSET nil)
(while (= SSET nil)
(setq SSET (ssget))
(if (= SSET nil)
(princ "\nNull selection set please try again:")
)
)
(princ)
)
(prin1)
(c:agc)

****************************************** ATGL.DCL ****************************

atgl : dialog {
label="Enter Attribute Filters";
initial_focus = string;
: text_part {
key = "string1";
width = 30;
}
: spacer {
}
: text_part {
key = "string2";
width = 30;
}
: row {
: text_part {
key = "title";
width = 30;
}
: edit_box {
allow_accept = true;
key = "string";
width = 15;
}
}
ok_cancel;
}
atgl2 : dialog {
label="Select Characteristic";
initial_focus = string;
: boxed_row {
: column {
: button {
allow_accept = true;
key = "A";
label = "&Angle ";
mnemonic = "A";
width = 10;
}
: button {
allow_accept = true;
key = "C";
label = "&Color ";
mnemonic = "C";
width = 10;
}
}
: column {
: button {
allow_accept = true;
key = "H";
label = "&Height ";
mnemonic = "H";
width = 10;
}
: button {
allow_accept = true;
key = "I";
label = "&Increment";
mnemonic = "I";
width = 10;
}
}
: column {
: button {
allow_accept = true;
key = "L";
label = "&Layer ";
mnemonic = "L";
width = 10;
}
: button {
allow_accept = true;
key = "M";
label = "&Multiply ";
mnemonic = "M";
width = 10;
}
}
: column {
: button {
allow_accept = true;
key = "S";
label = "&Style ";
mnemonic = "S";
width = 10;
}
: button {
allow_accept = true;
key = "V";
label = "&Value ";
mnemonic = "V";
width = 10;
}
}
: column {
: button {
allow_accept = true;
key = "W";
label = "&Width ";
mnemonic = "W";
width = 10;
}
: button {
allow_accept = true;
key = "T";
label = "ch&T ";
mnemonic = "T";
width = 10;
}
}
}
ok_cancel;
}
atglangle : dialog {
label = "Enter New Attribute Angle";
initial_focus = "A";
: edit_box {
allow_accept = true;
key = "A";
label = "Angle";
width = 12;
}
ok_cancel;
}
atglcolor : dialog {
label = "Enter New Attribute Color";
initial_focus = "C";
: edit_box {
allow_accept = true;
key = "C";
label = "Color";
width = 12;
}
ok_only;
}
atglheight : dialog {
label = "Enter New Attribute Height";
initial_focus = "H";
: edit_box {
allow_accept = true;
key = "H";
label = "Height";
width = 12;
}
ok_only;
}
atglinc : dialog {
label = "Enter New Numeric Increment";
initial_focus = "string2";
: row {
: text_part {
key = "title1";
width = 15;
}
: text_part {
key = "string1";
width = 12;
}
}
: row {
: text_part {
key = "title2";
width = 15;
}
: edit_box {
allow_accept = true;
key = "string2";
width = 12;
}
}
ok_cancel;
}
atgllayer : dialog {
label="Set Attribute Layer";
: list_box {
key = "layers";
height = 5;
width = 40;
allow_accept = true;
}
ok_only;
}
atglmult : dialog {
label = "Enter New Numeric Increment";
initial_focus = "string2";
: row {
: text_part {
key = "title1";
width = 15;
}
: text_part {
key = "string1";
width = 12;
}
}
: row {
: text_part {
key = "title2";
width = 15;
}
: edit_box {
allow_accept = true;
key = "string2";
width = 12;
}
}
ok_cancel;
}
atglstyle : dialog {
label="Set Attribute Style";
: list_box {
key = "styles";
height = 5;
width = 38;
allow_accept = true;
}
ok_only;
}
atglcht : dialog {
label="Replace Text Strings";
initial_focus = string;
: text_part {
key = "oldstring";
width = 11;
}
: row {
: text_part {
key = "title";
width = 11;
}
: edit_box {
key = "string";
width = 15;
allow_accept = true;
}
}
ok_cancel;
}
atglvalue : dialog {
label = "Enter New Attribute Value";
initial_focus = "V";
: edit_box {
is_tab_stop = true;
allow_accept = true;
key = "V";
label = "Value";
width = 30;
}
ok_only;
}
atglwidth : dialog {
label = "Enter New Attribute Width";
initial_focus = "W";
: edit_box {
allow_accept = true;
key = "W";
label = "Width";
width = 30;
}
ok_only;
}