Message 1 of 16
Attribute value from text .dat
Not applicable
05-04-2016
09:50 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm a novice on lisp and especially DCL.
Please help me out in this lisp with DCL to insert an attribute block in my dialog where I can select the Brand & Code values from the drop down popup-list. This is to enhance my attribute entry to every insertion of this block. There are about 150 values for both Brand and Code that I need on every drawing. Attached are the DCL, Lisp, block and the .DAT. I hope the values can be taken from the .DAT.
I had posted this at CADTutor.net but did not get much response. Thanks for the guy help anyway.
What I hope to acheive:
- insert block with my dcl that I can select the Brand & Code.
- values for Code and Brand are from .dat.
- if possible, if I select a code, it automatically filled brand base on the .dat and vice versa. I hope I not asking too much here.
Thanks..
DCL:
br : dialog { label = "Enhanced Attribute Input"; width = 42;
: popup_list { label = "Code "; key = "sel-code"; value = 3; allow_accept = true; }
: popup_list { label = "Brand"; key = "sel-brand"; value = 3; allow_accept = true; }
: spacer { width = 1; }
ok_cancel;
}Lisp:
(defun C:BRAND (/ names dcl_id lst cd br it bk pt)
(setq names '("1000 - COUNTRY ROAD WOMENS" "1011 - SPORTCRAFT"
"1022 - DAVID LAWRENCE" "2100 - FRAGRANCE TRI"
"2117 - FRAGRANCE L'OR" "2133 - BURBERRY BEAUTY"
)
)
(if (and (< 0 (setq dcl_id (load_dialog "brand.dcl")))
(new_dialog "br" dcl_id)
)
(progn
(setq lst (mapcar '(lambda (x) (cons (substr x 1 4) (substr x 8)))
names
)
cd (mapcar 'car lst)
br (mapcar 'cdr lst)
)
(mapcar '(lambda (k v)
(start_list k)
(mapcar 'add_list v)
(end_list)
)
'("sel-code" "sel-brand")
(list cd br)
)
(action_tile "cancel" "(done_dialog)")
(action_tile
"accept"
"(setq it (mapcar 'atoi (list (get_tile \"sel-code\") (get_tile \"sel-brand\")))) (done_dialog)"
)
(start_dialog)
(unload_dialog dcl_id)
(if
(and
(apply 'and it)
(setq pt (getpoint "\nPick Attribute insertion point: "))
(if (not (or (tblsearch "BLOCK" (setq bk "AREA_ATTRIB_M"))
(setq bk (findfile "H:/AREA_ATTRIB_M.dwg"))
)
)
(progn
(princ
"\nBlock not found drawing and either in H:DCL Test folder !"
)
nil
)
t
)
)
(command "_.-insert"
bk
"_non"
pt
"1"
"1"
"0."
(nth (car it) cd)
(nth (cadr it) br)
""
""
)
)
)
)
(princ)
)Data:
**CODE & BRANDS **CODE, BRANDS **---------------- *1006-COUNTRY ROAD WOMENS 1006,COUNTRY ROAD WOMENS *1014-SPORTCRAFT 1014,SPORTCRAFT *1022-DAVID LAWRENCE 1022,DAVID LAWRENCE *2379-OPI 2379,OPI *2565-MAC 2565,MAC *3498-BLAZER 3498,BLAZER *4753-QUICKSILVER 4753,QUICKSILVER