pBe Posted May 8, 2012 Posted May 8, 2012 Hi pBe, I got it sorted. It was a problem with my block. I must have had an old version of it. The lisp works great. Thank you very much for your help. It is a fantastic piece of work. I appreciate all the work you did on it. You're welcome woodman78 Glad you had it sorted, I know you had it in you. Cheers Quote
woodman78 Posted May 9, 2012 Author Posted May 9, 2012 pBe, I got a bit brave and had a go at another similar type lisp but for other elements of the title block. I went back to the previous code I had from afralisp after I tried to dicipher your code but didn't have much luck. I had it working updating on the current tab and I tried to incorporate your code from post #15 (http://www.cadtutor.net/forum/showthread.php?68847-Lisp-for-Revision-Box-Need-help&p=471304&viewfull=1#post471304). I am now getting an error ; error: too many arguments Would you be able to have a look? I can't seem to spot the error. ;CODING STARTS HERE (defun c:title_details-01 (/) (setq ss1 (ssget "X" (list '(0 . "INSERT")'(66 . 1)'(2 . "Title_Details")))) (if ss1 (progn (setq count 0 emax (sslength ss1) ) (while (< count emax) (setq en (ssname ss1 count) ed (entget en) blkn (dxf 2 ed) ) (if (= "Title_Details" blkn) (setq count emax found T ) (setq count (1+ count)) );if );while (if found (ddisplay) ;cannot find our block (alert "\nDrawing Sheet has No Attributes \n Use Manual Edit" ) );if );progn (alert "\nIncorrect Drawing Sheet \n Use Manual Edit" ) );if (princ) );defun ;;;********************************************************** (defun ddisplay (/) (setq dcl_id (load_dialog "title_details_01.dcl")) (if (not (new_dialog "title_details_01" dcl_id)) (exit) );if (action_tile "rbt1" "(setq en (_sel "REV-BOX" T nil))) (action_tile "rbt2" "(setq en (_sel "REV-BOX" nil nil))) (setq edata (entget en)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq edata (entget (entnext (dxf -1 edata)))) (setq REVISION (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq DWGNO (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq STATUS (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq DESIGNED (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq DRAWN (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq CHECKED (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq APPROVED (dxf 1 edata)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (set_tile "REVISION" REVISION) (set_tile "DWGNO" DWGNO) (set_tile "STATUS" STATUS) (set_tile "DESIGNED" DESIGNED) (set_tile "DRAWN" DRAWN) (set_tile "CHECKED" CHECKED) (set_tile "APPROVED" APPROVED) (mode_tile "REVISION" 2) (action_tile "cancel" "(done_dialog) (setq userclick nil)" ) ;if OK selected, retrieve the tile values (action_tile "accept" (strcat "(progn (setq REVISIONa (get_tile \"REVISION\"))" "(setq DWGNOa (get_tile \"DWGNO\"))" "(setq STATUSa (get_tile \"STATUS\"))" "(setq DESIGNEDa (get_tile \"DESIGNED\"))" "(setq DRAWNa (get_tile \"DRAWN\"))" "(setq CHECKEDa (get_tile \"CHECKED\"))" "(setq APPROVEDa (get_tile \"APPROVED\"))" " (done_dialog)(setq userclick T))" ) ) (start_dialog) (unload_dialog dcl_id) (if userclick (progn (setq edata (entget en)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 REVISIONa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 DWGNOa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 STATUSa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 DESIGNEDa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 DRAWNa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 CHECKEDa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 APPROVEDa) (assoc 1 edata) edata)) (entmod el) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;regen the drawing (command "REGEN") );progn );if (princ) );defun ;;;*********************************************************** (defun dxf (code elist) (cdr (assoc code elist)) );defun ;;;********************************************************** ;load clean (princ) ;;;********************************************************** ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun _sel (bn flg att ) (setq lst (list '(0 . "insert") (cons 2 (strcat bn "title_details")) (cons 410 (if flg (getvar 'Ctab) "*")))) (ssget "x" (if att (append lst '((66 . 1))) lst)) ) ;CODING ENDS HERE td1 : edit_box { edit_limit = 2; edit_width = 2;} td2 : edit_box { edit_limit = 2; edit_width = 2;} td3 : edit_box { edit_limit = 15; edit_width = 15;} td4 : edit_box { edit_limit = 7; edit_width = 8;} td5 : edit_box { edit_limit = 7; edit_width = 8;} td6 : edit_box { edit_limit = 7; edit_width = 8;} td7 : edit_box { edit_limit = 7; edit_width = 8;} title_details_01 : dialog { label = "Drawing Title Block"; : boxed_radio_column { label = "Application" ; //give it a label : row { : radio_button { //define radion button key = "rbt1" ; //give it a name label = "Apply to Current Layout ONLY" ; //give it a label value = "1" ; //switch it on } : radio_button { //define radion button key = "rbt2" ; //give it a name label = "Apply to All Layouts" ; //give it a label } } } : boxed_column { label = "Information" ; //give it a label : row { : text {label = "Revision"; alignment = centered;} : td1 { key = "REVISION"; } : text {label = "Dwg No."; alignment = centered;} : td2 { key = "DWGNO"; } : text {label = "Status"; alignment = centered;} : td3 { key = "STATUS"; } } : row { : column { : text {label = "Designed"; alignment = centered;} : td4 { key = "DESIGNED"; } } : column { : text {label = "Drawn"; alignment = centered;} : td5 { key = "DRAWN" ; } } : column { : text {label = "Checked"; alignment = centered;} : td6 { key = "CHECKED" ; } } : column { : text {label = "Approved"; alignment = centered;} : td7 { key = "APPROVED" ; } } } spacer ; } : row { ok_cancel ; //predifined OK/Cancel } } Title_Details.dwg Quote
pBe Posted May 9, 2012 Posted May 9, 2012 (edited) Learn how to "trace" the error: Linky ---> Debugging Code with the Visual LISP IDE Oh.. I see thats not the only problem.. I'll have a second look woodman78. EDIT: First use the original _sel subrouitne i posted (defun c:title_details-01 (/) [color=blue][b](setq ss1 (_sel "Title_Details" T T))[/b][/color] (if ss1 [color=blue][color=black] (ddisplay[/color][b] (ssname ss1 0)[/b][color=black])[/color] [/color] (alert "\nDrawing Sheet has No Attributes \n Use Manual Edit" ) );if (princ) ) From (defun ddisplay (/) (defun ddisplay ( [b][color=blue]en[/color][/b] /) Take out this lines ;;(action_tile "rbt1" "(setq en (_sel "REV-BOX" T nil))) ;;(action_tile "rbt2" "(setq en (_sel "REV-BOX" nil nil))) ...... (action_tile "accept" (strcat "(progn (setq REVISIONa (get_tile \"REVISION\"))" "(setq DWGNOa (get_tile \"DWGNO\"))" "(setq STATUSa (get_tile \"STATUS\"))" "(setq DESIGNEDa (get_tile \"DESIGNED\"))" "(setq DRAWNa (get_tile \"DRAWN\"))" "(setq CHECKEDa (get_tile \"CHECKED\"))" "(setq APPROVEDa (get_tile \"APPROVED\"))" [b][color=blue]"(setq en (get_tile \"rbt1\"))" [/color][/b] " (done_dialog)(setq userclick T))" ) ) (if userclick (progn [color=blue][b] (setq ssb (if (eq en "1") (_sel "Title_Details" T T) (_sel "Title_Details" nil T))) [/b][/color] [color=blue][b](repeat (sslength ssb) (setq edata (entget (ssname ssb 0))) [/b][/color] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 REVISIONa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 DWGNOa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 STATUSa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 DESIGNEDa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 DRAWNa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 CHECKEDa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 APPROVEDa) (assoc 1 edata) edata)) (entmod el) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;regen the drawing (command "REGEN") [b][color=blue](ssdel (ssname ssb 0) ssb)) [/color][/b] );progn ) Hope you can put it together. Holler if you need help Edited May 9, 2012 by pBe Quote
woodman78 Posted May 9, 2012 Author Posted May 9, 2012 pBe, I had trouble getting it to recognise the block and I made a change to include the wildcard. Now the dialog loads but I get this error on clicking ok. ;CODING STARTS HERE (defun c:Title_Details-01 (/) (setq ss1 (_sel "Title_Details[color="red"],`*U*[/color]" T T)) (if ss1 (ddisplay (ssname ss1 0)) (alert "\nDrawing Sheet has No Attributes \n Use Manual Edit" ) );if (princ) ) ;;;********************************************************** (defun ddisplay ( en /) (setq dcl_id (load_dialog "title_details_01.dcl")) (if (not (new_dialog "title_details_01" dcl_id)) (exit) );if (setq edata (entget en)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq edata (entget (entnext (dxf -1 edata)))) (setq REVISION (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq DWGNO (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq STATUS (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq DESIGNED (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq DRAWN (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq CHECKED (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq APPROVED (dxf 1 edata)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (set_tile "REVISION" REVISION) (set_tile "DWGNO" DWGNO) (set_tile "STATUS" STATUS) (set_tile "DESIGNED" DESIGNED) (set_tile "DRAWN" DRAWN) (set_tile "CHECKED" CHECKED) (set_tile "APPROVED" APPROVED) (mode_tile "REVISION" 2) (action_tile "cancel" "(done_dialog) (setq userclick nil)" ) ;if OK selected, retrieve the tile values (action_tile "accept" (strcat "(progn (setq REVISIONa (get_tile \"REVISION\"))" "(setq DWGNOa (get_tile \"DWGNO\"))" "(setq STATUSa (get_tile \"STATUS\"))" "(setq DESIGNEDa (get_tile \"DESIGNED\"))" "(setq DRAWNa (get_tile \"DRAWN\"))" "(setq CHECKEDa (get_tile \"CHECKED\"))" "(setq APPROVEDa (get_tile \"APPROVED\"))" "(setq en (get_tile \"rbt1\"))" " (done_dialog)(setq userclick T))" ) ) (start_dialog) (unload_dialog dcl_id) (if userclick (progn (setq ssb (if (eq en "1") (_sel "Title_Details" T T) (_sel "Title_Details" nil T))) (repeat (sslength ssb) (setq edata (entget (ssname ssb 0))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 REVISIONa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 DWGNOa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 STATUSa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 DESIGNEDa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 DRAWNa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 CHECKEDa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 APPROVEDa) (assoc 1 edata) edata)) (entmod el) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;regen the drawing (command "REGEN") (ssdel (ssname ssb 0) ssb)) );progn );if (princ) );defun ;;;*********************************************************** (defun dxf (code elist) (cdr (assoc code elist)) );defun ;;;********************************************************** ;load clean (princ) ;;;********************************************************** ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun _sel (bn flg att ) (setq lst (list '(0 . "insert") (cons 2 (strcat bn "Title_Details")) (cons 410 (if flg (getvar 'Ctab) "*")))) (ssget "x" (if att (append lst '((66 . 1))) lst)) ) ;CODING ENDS HERE ; error: bad argument type: lselsetp nil Quote
woodman78 Posted May 9, 2012 Author Posted May 9, 2012 I got it. Just had to add that lower down as well. (if userclick (progn (setq ssb (if (eq en "1") (_sel "Title_Details,`*U*" T T) (_sel "Title_Details,`*U*" nil T))) (repeat (sslength ssb) (setq edata (entget (ssname ssb 0))) Quote
pBe Posted May 9, 2012 Posted May 9, 2012 You dont need to do that... (list '(0 . "insert") (cons 2 (strcat bn ",[b][color=blue]`*U*"[/color][/b])) (cons 410 (if flg (getvar 'Ctab) "*"))) As it is already included on _sel function Quote
woodman78 Posted May 9, 2012 Author Posted May 9, 2012 Thanks for your help pBe. As we would say here "you're a dinger!!!!" Quote
woodman78 Posted May 9, 2012 Author Posted May 9, 2012 But it works now.....Ah, I had this: (defun _sel (bn flg att ) (setq lst (list '(0 . "insert") (cons 2 (strcat bn "[color="red"]Title_Details[/color]")) (cons 410 (if flg (getvar 'Ctab) "*")))) (ssget "x" (if att (append lst '((66 . 1))) lst)) ) Quote
pBe Posted May 9, 2012 Posted May 9, 2012 Thanks for your help pBe. As we would say here "you're a dinger!!!!" You are welcome Woodman78, (hope it means well) But it works now.....Ah, I had this: Thats right... Hence First use the original _sel subrouitne i posted Reminder: If you are going to use or convert the block to DB. we may need to add a line for checking the EFFECTIVENAME. Quote
asos2000 Posted May 9, 2012 Posted May 9, 2012 Is this mean the final code in reply no 64 with the small modification in reply no 68 ? and final DCL in reply no 43 ? pBe, let me tell you that, What a great man you are. Quote
pBe Posted May 9, 2012 Posted May 9, 2012 pBe, let me tell you that, What a great man you are. Thank you for the kind words asos200 As for what is the latest and the greatest, i suggest you hook up with Woodman78 as i'm as confuse as you are. Keep in mind that there are two routines now. Cheers Quote
asos2000 Posted May 9, 2012 Posted May 9, 2012 ... i suggest you hook up with Woodman78 ... OK Lets ask Woodman78 Could you please paste the final 2 routines and whats the deference between? Thanks Quote
woodman78 Posted May 9, 2012 Author Posted May 9, 2012 (edited) ok, here we go. Hang in there now it gets a bit messy!! The first routine was for updating a rev box with the option of selecting one or all layouts. This is all pBe's work apart from LeeMac subroutines. (defun c:rev_box ( / bn Adoc Layt BlkColl RevList) (setq bn "rev-box" Visname "Visibility1") (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object)) Layt (vla-get-layouts aDoc)) (setq BlkColl nil lytn (vla-get-name (vla-get-ActiveLayout aDoc))) (if (foreach layoutname (layoutlist) (vlax-for itm (vlax-get (vla-item Layt layoutname) 'Block) (if (and (eq (vla-get-ObjectName itm) "AcDbBlockReference") (vlax-property-available-p itm 'effectivename) (eq (vla-get-EffectiveName itm) bn) (eq (LM:GetVisibilityParameterName itm) Visname) ) (setq BlkColl (cons (list layoutname (LM:GetVisibilityState itm) itm) BlkColl))))) (ddisplay lytn BlkColl) ) ) (defun ddisplay (clay lst / dcl_id RevList ByList DateList DescList DescList RButtons ATTData NewVal VisState RunHere) (setq RevList '("L1-REV" "L2-REV" "L3-REV" "L4-REV" "L5-REV" "L6-REV" "L7-REV" "L8-REV" "L9-REV") ByList '("L1-BY" "L2-BY" "L3-BY" "L4-BY" "L5-BY" "L6-BY" "L7-BY" "L8-BY" "L9-BY") DateList '("L1-DATE" "L2-DATE" "L3-DATE" "L4-DATE" "L5-DATE" "L6-DATE" "L7-DATE" "L8-DATE" "L9-DATE") DescList '("L1-DESCRIPTION" "L2-DESCRIPTION" "L3-DESCRIPTION" "L4-DESCRIPTION" "L5-DESCRIPTION" "L6-DESCRIPTION" "L7-DESCRIPTION" "L8-DESCRIPTION" "L9-DESCRIPTION") RButtons '("rbl1" "rbl2" "rbl3" "rbl4" "rbl5" "rbl6" "rbl7" "rbl8" "rbl9")) (setq ATTData (_AttFunc (last (setq CRevB (assoc clay lst))) nil)) (setq dcl_id (load_dialog "rev_box.dcl")) (if (not (new_dialog "rev_box" dcl_id)) (exit)) (set_tile (if (null rbd) "rbl1" (strcat "rbl" rbd)) "1") (_AssignVal RevList (_ReduceList "REV" ATTData)) (_AssignVal ByList (_REDUCELIST "BY" ATTData)) (_AssignVal DateList (_REDUCELIST "DATE" ATTData)) (_AssignVal DescList (_REDUCELIST "DESCRIPTION" ATTData)) (action_tile "accept" "(setq NewVal (_PutValtoVar (mapcar 'car ATTData))) (setq VisState (_PutValtoVar RButtons)) (setq RunHere (get_tile \"rb1\")) (done_dialog 1)") (action_tile "cancel" "(done_dialog 0)") (start_dialog) (unload_dialog dcl_id) (if (and NewVal VisState) (progn (foreach Blk (if (eq RunHere "1") (list CRevB) lst) ( _AttFunc (last Blk) NewVal) (LM:SetVisibilityState (last Blk) (strcat "Line" (setq rbd (itoa (1+ (vl-position "1" (mapcar 'cadr VisState)))))) ))) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun _ReduceList (str lst) (vl-remove-if-not '(lambda (ly)(wcmatch (car ly) (strcat "*" str)) ) lst)) (defun _AssignVal (lst1 lst2) (mapcar '(lambda (d1 d2) (set_tile d1 (cadr d2))) lst1 lst2)) (defun _PutValtoVar (lst_) (mapcar '(lambda (vr) (list vr (set (read vr) (get_tile vr)))) lst_) ) (defun _AttFunc (en lst / vals v) (mapcar (function (lambda (at) (setq vals (list (vla-get-tagstring at)(vla-get-textstring at))) (if (and lst (setq v (assoc (car vals) lst))) (vla-put-textstring at (cadr v))) vals)) (vlax-invoke (if (eq (type en) 'VLA-OBJECT) en (vlax-ename->vla-object en)) 'Getattributes) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;----------------=={ Get Visibility State }==----------------;; ;; ;; ;; Returns the value of the Visibility Parameter of a ;; ;; Dynamic Block (if present) ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; block - VLA (Dynamic) Block Reference Object ;; ;;------------------------------------------------------------;; ;; Returns: Value of Visibility Parameter, else nil ;; ;;------------------------------------------------------------;; (defun LM:GetVisibilityState ( block ) ( (lambda ( name ) (vl-some (function (lambda ( prop ) (if (eq name (vla-get-propertyname prop)) (vlax-get prop 'value) ) ) ) (vlax-invoke block 'getdynamicblockproperties) ) ) (LM:GetVisibilityParameterName block) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;----------------=={ Set Visibility State }==----------------;; ;; ;; ;; Sets the Visibility Parameter of a Dynamic Block ;; ;; (if present) to a specific value (if allowed). ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; block - VLA (Dynamic) Block Reference Object ;; ;; value - Visibility Parameter value ;; ;;------------------------------------------------------------;; ;; Returns: Value of Visibility Parameter, else nil ;; ;;------------------------------------------------------------;; (defun LM:SetVisibilityState ( block value ) ( (lambda ( name value ) (vl-some (function (lambda ( prop ) (if (and (eq name (vla-get-propertyname prop)) (member value (mapcar 'strcase (vlax-get prop 'allowedvalues))) ) (progn (vla-put-value prop (vlax-make-variant value (vlax-variant-type (vla-get-value prop))) ) value ) ) ) ) (vlax-invoke block 'getdynamicblockproperties) ) ) (LM:GetVisibilityParameterName block) (strcase value) ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;-----------=={ Get Visibility Parameter Name }==------------;; ;; ;; ;; Returns the name of the Visibility Parameter of a ;; ;; Dynamic Block (if present). ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; block - VLA (Dynamic) Block Reference Object ;; ;;------------------------------------------------------------;; ;; Returns: Name of Visibility Parameter, else nil ;; ;;------------------------------------------------------------;; (defun LM:GetVisibilityParameterName ( block / visib ) (if (and (vlax-property-available-p block 'effectivename) (setq block (vla-item (vla-get-blocks (vla-get-document block)) (vla-get-effectivename block) ) ) (eq :vlax-true (vla-get-isdynamicblock block)) (eq :vlax-true (vla-get-hasextensiondictionary block)) (setq visib (vl-some (function (lambda ( pair ) (if (and (= 360 (car pair)) (eq "BLOCKVISIBILITYPARAMETER" (cdr (assoc 0 (entget (cdr pair))))) ) (cdr pair) ) ) ) (dictsearch (vlax-vla-object->ename (vla-getextensiondictionary block)) "ACAD_ENHANCEDBLOCK" ) ) ) ) (cdr (assoc 301 (entget visib))) ) ) ed1 : edit_box { edit_limit = 2; edit_width = 2;} ed2 : edit_box { edit_limit = 3; edit_width = 3;} ed3 : edit_box { edit_limit = 10; edit_width = 9;} ed4 : edit_box { edit_limit = 58; edit_width = 58;} rev_box : dialog { label = "Drawing Title Block"; : boxed_radio_column { label = "Application" ; //give it a label : row { : radio_button { //define radion button key = "rb1" ; //give it a name label = "Apply to Current Layout ONLY" ; //give it a label value = "1" ; //switch it on } : radio_button { //define radion button key = "rb2" ; //give it a name label = "Apply to All Layouts" ; //give it a label } } } : boxed_column { label = "REVision Data" ; //give it a label : row { : column { : text {label = "Lines"; } : radio_button { key = "rbl9" ;label = "Line 9" ; } : radio_button { key = "rbl8" ;label = "Line 8" ; } : radio_button { key = "rbl7" ;label = "Line 7" ; } : radio_button { key = "rbl6" ;label = "Line 6" ; } : radio_button { key = "rbl5" ;label = "Line 5" ; } : radio_button { key = "rbl4" ;label = "Line 4" ; } : radio_button { key = "rbl3" ;label = "Line 3" ; } : radio_button { key = "rbl2" ;label = "Line 2" ; } : radio_button { key = "rbl1" ;label = "Line 1" ;value = "1" ; } } : column { : text {label = "REV"; alignment = centered;} : ed1 { key = "L9-REV"; } : ed1 { key = "L8-REV"; } : ed1 { key = "L7-REV"; } : ed1 { key = "L6-REV"; } : ed1 { key = "L5-REV"; } : ed1 { key = "L4-REV"; } : ed1 { key = "L3-REV"; } : ed1 { key = "L2-REV"; } : ed1 { key = "L1-REV"; } } : column { : text {label = "By"; alignment = centered;} : ed2 { key = "L9-BY" ; } : ed2 { key = "L8-BY" ; } : ed2 { key = "L7-BY" ; } : ed2 { key = "L6-BY" ; } : ed2 { key = "L5-BY" ; } : ed2 { key = "L4-BY" ; } : ed2 { key = "L3-BY" ; } : ed2 { key = "L2-BY" ; } : ed2 { key = "L1-BY" ; } } : column { : text {label = "Date"; alignment = centered;} : ed3 { key = "L9-DATE"; } : ed3 { key = "L8-DATE"; } : ed3 { key = "L7-DATE"; } : ed3 { key = "L6-DATE"; } : ed3 { key = "L5-DATE"; } : ed3 { key = "L4-DATE"; } : ed3 { key = "L3-DATE"; } : ed3 { key = "L2-DATE"; } : ed3 { key = "L1-DATE"; } } : column { : text {label = "Description"; } : ed4 { key = "L9-DESCRIPTION"; } : ed4 { key = "L8-DESCRIPTION"; } : ed4 { key = "L7-DESCRIPTION"; } : ed4 { key = "L6-DESCRIPTION"; } : ed4 { key = "L5-DESCRIPTION"; } : ed4 { key = "L4-DESCRIPTION"; } : ed4 { key = "L3-DESCRIPTION"; } : ed4 { key = "L2-DESCRIPTION"; } : ed4 { key = "L1-DESCRIPTION"; } } } spacer ; } : row { ok_cancel ; //predifined OK/Cancel } } And the block.rev-box.dwg Edited May 9, 2012 by woodman78 Quote
woodman78 Posted May 9, 2012 Author Posted May 9, 2012 This is for updating the other parts of the title block info but isn't based on a dynamic block. The basis for this code is a routine used as an example on the afralisp site. ;CODING STARTS HERE (defun c:Title_Details-01 (/) (setq ss1 (_sel "Title_Details,`*U*" T T)) (if ss1 (ddisplay (ssname ss1 0)) (alert "\nDrawing Sheet has No Attributes \n Use Manual Edit" ) );if (princ) ) ;;;********************************************************** (defun ddisplay ( en /) (setq dcl_id (load_dialog "title_details_01.dcl")) (if (not (new_dialog "title_details_01" dcl_id)) (exit) );if (setq edata (entget en)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq edata (entget (entnext (dxf -1 edata)))) (setq REVISION (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq DWGNO (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq STATUS (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq DESIGNED (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq DRAWN (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq CHECKED (dxf 1 edata)) (setq edata (entget (entnext (dxf -1 edata)))) (setq APPROVED (dxf 1 edata)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (set_tile "REVISION" REVISION) (set_tile "DWGNO" DWGNO) (set_tile "STATUS" STATUS) (set_tile "DESIGNED" DESIGNED) (set_tile "DRAWN" DRAWN) (set_tile "CHECKED" CHECKED) (set_tile "APPROVED" APPROVED) (mode_tile "REVISION" 2) (action_tile "cancel" "(done_dialog) (setq userclick nil)" ) ;if OK selected, retrieve the tile values (action_tile "accept" (strcat "(progn (setq REVISIONa (get_tile \"REVISION\"))" "(setq DWGNOa (get_tile \"DWGNO\"))" "(setq STATUSa (get_tile \"STATUS\"))" "(setq DESIGNEDa (get_tile \"DESIGNED\"))" "(setq DRAWNa (get_tile \"DRAWN\"))" "(setq CHECKEDa (get_tile \"CHECKED\"))" "(setq APPROVEDa (get_tile \"APPROVED\"))" "(setq en (get_tile \"rbt1\"))" " (done_dialog)(setq userclick T))" ) ) (start_dialog) (unload_dialog dcl_id) (if userclick (progn (setq ssb (if (eq en "1") (_sel "Title_Details,`*U*" T T) (_sel "Title_Details,`*U*" nil T))) (repeat (sslength ssb) (setq edata (entget (ssname ssb 0))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 REVISIONa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 DWGNOa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 STATUSa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 DESIGNEDa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 DRAWNa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 CHECKEDa) (assoc 1 edata) edata)) (entmod el) (setq edata (entget (entnext (dxf -1 edata)))) (setq el (subst (cons 1 APPROVEDa) (assoc 1 edata) edata)) (entmod el) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;regen the drawing (command "REGEN") (ssdel (ssname ssb 0) ssb)) );progn );if (princ) );defun ;;;*********************************************************** (defun dxf (code elist) (cdr (assoc code elist)) );defun ;;;********************************************************** ;load clean (princ) ;;;********************************************************** ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun _sel (bn flg att ) (setq lst (list '(0 . "insert") (cons 2 (strcat bn "Title_Details")) (cons 410 (if flg (getvar 'Ctab) "*")))) (ssget "x" (if att (append lst '((66 . 1))) lst)) ) ;CODING ENDS HERE td1 : edit_box { edit_limit = 2; edit_width = 2;} td2 : edit_box { edit_limit = 2; edit_width = 2;} td3 : edit_box { edit_limit = 15; edit_width = 15;} td4 : edit_box { edit_limit = 7; edit_width = 8;} td5 : edit_box { edit_limit = 7; edit_width = 8;} td6 : edit_box { edit_limit = 7; edit_width = 8;} td7 : edit_box { edit_limit = 7; edit_width = 8;} title_details_01 : dialog { label = "Drawing Title Block"; : boxed_radio_column { label = "Application" ; //give it a label : row { : radio_button { //define radion button key = "rbt1" ; //give it a name label = "Apply to Current Layout ONLY" ; //give it a label value = "1" ; //switch it on } : radio_button { //define radion button key = "rbt2" ; //give it a name label = "Apply to All Layouts" ; //give it a label } } } : boxed_column { label = "Information" ; //give it a label : row { : text {label = "Revision"; alignment = centered;} : td1 { key = "REVISION"; } : text {label = "Dwg No."; alignment = centered;} : td2 { key = "DWGNO"; } : text {label = "Status"; alignment = centered;} : td3 { key = "STATUS"; } } : row { : column { : text {label = "Designed"; alignment = centered;} : td4 { key = "DESIGNED"; } } : column { : text {label = "Drawn"; alignment = centered;} : td5 { key = "DRAWN" ; } } : column { : text {label = "Checked"; alignment = centered;} : td6 { key = "CHECKED" ; } } : column { : text {label = "Approved"; alignment = centered;} : td7 { key = "APPROVED" ; } } } spacer ; } : row { ok_cancel ; //predifined OK/Cancel } } Title_Details.dwg Quote
woodman78 Posted May 9, 2012 Author Posted May 9, 2012 (edited) I have created columns for the dialog info but why doesn't the Revision line up with the box under it? Updated DCL: td1 : edit_box { edit_limit = 2; edit_width = 2;} td2 : edit_box { edit_limit = 2; edit_width = 2;} td3 : edit_box { edit_limit = 15; edit_width = 15;} td4 : edit_box { edit_limit = 7; edit_width = 8;} td5 : edit_box { edit_limit = 7; edit_width = 8;} td6 : edit_box { edit_limit = 7; edit_width = 8;} td7 : edit_box { edit_limit = 7; edit_width = 8;} title_details_01 : dialog { label = "Drawing Title Block"; : boxed_radio_column { label = "Application" ; //give it a label : row { : radio_button { //define radion button key = "rbt1" ; //give it a name label = "Apply to Current Layout ONLY" ; //give it a label value = "1" ; //switch it on } : radio_button { //define radion button key = "rbt2" ; //give it a name label = "Apply to All Layouts" ; //give it a label } } } : boxed_column { label = "Information" ; //give it a label : row { : column { : text {label = "Revision"; alignment = centered;} : td1 { key = "REVISION"; } } : column { : text {label = "Dwg No."; alignment = centered;} : td2 { key = "DWGNO"; } } : column { : text {label = "Status"; alignment = centered;} : td3 { key = "STATUS"; } } } : row { : column { : text {label = "Designed"; alignment = centered;} : td4 { key = "DESIGNED"; } } : column { : text {label = "Drawn"; alignment = centered;} : td5 { key = "DRAWN" ; } } : column { : text {label = "Checked"; alignment = centered;} : td6 { key = "CHECKED" ; } } : column { : text {label = "Approved"; alignment = centered;} : td7 { key = "APPROVED" ; } } } spacer ; } : row { ok_cancel ; //predifined OK/Cancel } } Edited May 9, 2012 by woodman78 Quote
woodman78 Posted May 10, 2012 Author Posted May 10, 2012 pBe, I am having trouble with the Rev-Box routine in that when I run it it works fine. But then if I close the drawings and reopen it I get nil when I run the command. Is there a way to incorporate the wildcard selection for the block and would it help? Thanks. Quote
pBe Posted May 10, 2012 Posted May 10, 2012 pBe, I am having trouble with the Rev-Box routine in that when I run it it works fine. But then if I close the drawings and reopen it I get nil when I run the command. Is there a way to incorporate the wildcard selection for the block and would it help? Thanks. We dont need to apply wildcard matching on this routine woodman78, as the code does not "select" the blocks but instaed it "reads" every block. My guess is the block names are diffrent (setq bn "rev-box" Visname "Visibility1") . if its "Rev-box" then i would suggest we change the line to (setq bn "REV-BOX" Visname "Visibility1") and (eq (vla-get-EffectiveName itm) bn) to (eq [b][color=blue](strcase[/color][/b] (vla-get-EffectiveName itm)[b])[/b] bn) or if you're not sure which block you are using on a drawing like "REV-BOX" or "REV_BOX" . Then its this way (setq bn "[b][color=blue]REV*[/color][/b]" Visname "Visibility1") and ([b][color=blue]wcmatch [/color][/b](strcase (vla-get-EffectiveName itm)) bn) Quote
woodman78 Posted May 10, 2012 Author Posted May 10, 2012 I have added the block to our template file (dwt) and when I import the layout and run the command I get "nil". The block name in the drawing is "rev-box" and it is exactly the same in the code "rev-box". Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.