Sambuddy Posted December 19, 2019 Posted December 19, 2019 I am trying to accomplish this lisp with no knowledge of DCL since I can check and uncheck options when I want. (Typ.) (Type) (TYP.) (TYPE) ± c/c ;option1; ± ;Dimension; c/c or C/C ;option2; ± ;Dimension; c/c or C/C then underneath the dim line to be: all four options of (Typ.)(Type)(TYP.)(TYPE) previously I had made a few lisps to do the task but it seems a DCL would be the way to go: ; Adding (Type) to the dimension line with Arial text (defun c:2 (/ Rtrn txt ss in vl) (progn (princ "\nSelect Dimension to modify: ") (setq ss (ssget "_:L" '((0 . "DIMENSION")))) ) ;end of 1st. progn (progn (setq Txt (strcat "<> " "{\\fArial|b0|i0|c0|p34;(Type)}")) (repeat (setq in (sslength ss)) (setq vl (vlax-ename->vla-object (ssname ss (setq in (1- in))))) (vl-catch-all-apply 'vla-put-TextOverride (list vl txt)) ) ) ;end 2nd. progn ; ) ; end if (princ) ) ;End Defun ; Adding ± to the dimension line keeping dim style (defun c:4 (/ Rtrn txt ss in vl) (progn (princ "\nSelect Dimension to modify: ") (setq ss (ssget "_:L" '((0 . "DIMENSION")))) ) ;end of 1st. progn (progn (setq Txt (strcat "%%P<>")) (repeat (setq in (sslength ss)) (setq vl (vlax-ename->vla-object (ssname ss (setq in (1- in))))) (vl-catch-all-apply 'vla-put-TextOverride (list vl txt)) ) ) ;end 2nd. progn ; ) ; end if (princ) ) ;End Defun for now I have them each under a command but it would be nice to have them using DCL. You see some pre/suffixes are all capital and some regular. also some are taking the dimension style formatting and some are Arial. Any help please? thank you! Quote
Lee Mac Posted December 19, 2019 Posted December 19, 2019 I would suggest starting with these excellent tutorials at AfraLISP. Quote
Sambuddy Posted December 19, 2019 Author Posted December 19, 2019 To me there are two types of people: (TYPE1) ones with brain bigger than head or (TYPE2) ones with skulls bigger than their brain. unfortunately I am Type 2. Thanks for the suggestion. I will see what I can do with the link you sent. Quote
BIGAL Posted December 20, 2019 Posted December 20, 2019 (edited) Not sure but look at my multi radio buttons returns item ticked. Then use a cond to run correct defun. Multi radio buttons.lsp eg (cond ((= ans2 "±")(c:0)) ((= ans2 "Dimension")(c:1)) ((= ans2 "c/c")(c:2)) ((= ans2 "C/C")(c:3)) ) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (= but nil)(setq but 1)) (setq ans2 (ah:butts 1 "v" (list "Please choose" "±" "Dimension" "c/c" "C/C"))) Edited December 20, 2019 by BIGAL Quote
Sambuddy Posted December 20, 2019 Author Posted December 20, 2019 9 hours ago, BIGAL said: Not sure but look at my multi radio buttons returns item ticked. Then use a cond to run correct defun. As always BIGAL: you the man - My sincere thanks for sharing your work. I did similar conditions as I was overwhelmed with DCL tutorials. For some reason though I never thought about (c:1), (c:2) as answer but instead I changed my codes to fit what I intended (resulting in a 400 line code). I can clearly follow your logic of keeping my c:0 as is and then just reference it if the condition statement is true. da! You are a blessing on this platform! Thank you very much! Quote
Sambuddy Posted December 20, 2019 Author Posted December 20, 2019 (edited) Hey BIGAL, I also just downloaded your Multiple Toggle Lisp. Could you please let me know how to deal with combination selection? (0 0 0 0 1 0 0 0 1 0 1) If I have lisp as you indicated on your last post c:1 11 hours ago, BIGAL said: (cond ((= ans2 "±")(c:0)) Can I still use condition with multiple selection? Would you help me please? say for example (Typ.) + c/c is selected - I do have the lisp to deal with it but I do not know how to make it know the combination. Do I use "nth"? Edited December 20, 2019 by Sambuddy Quote
BIGAL Posted December 21, 2019 Posted December 21, 2019 (edited) The toggle button returns 1 or 0 like a yes no. You can then look at using (nth x ans) so for you (nth 0 ans ) = (typ.) and will be a 1 or 0. Note nth starts at 0. (1 0 1 0 0 0 0 0 0 0 0) You can still use cond but to check for 1 or more you need and. (cond ((= (nth 0 ans) 1)(do-1)) ((= (nth 1 ans) 1 (do-2)) so repeat for single pick combo pick ((and (= (nth 0 ans) 1)(= (nth 5 ans) 1)(do-7)) ((and (= (nth 3 ans) 1)(= (nth 4 ans) 1)((do-12)(do-17))) ; run two defuns ) (and (= (nth 0 ans) 1)(= (nth 2 ans ) 1)(= (nth 3 ans ) 1)(= (nth 4 ans ) 1)(= (nth 5 ans ) 1)) worked Edited December 21, 2019 by BIGAL Quote
Sambuddy Posted December 23, 2019 Author Posted December 23, 2019 @BIGAL Could you please let me know how I should be dealing with Combo Picks. it seems to be always returning my first pick and not the combination I selected. Is it because of wrong Paran placements or would there be some other problems? The reason I have my answer of nth selection in " " is because I kept receiving nil as an answer. (= (nth 0 ans1) "1") Could you also let me know why I have this on my Visual Lisp Console instead of simply the name of the command which I usually have? ; 4 forms loaded from #<editor The first part of the LISP is of course your Pick box lisp (VERY NICE!). (defun mkv_lst ( / ) (setq v_lst '()) (setq x 1) (repeat (- (length ahbutlst) 1) (setq val (strcat "Tb" (rtos x 2 0))) (setq v_lst (cons (get_tile val) v_lst)) (setq x (+ x 1)) ) ) (vl-load-com) (defun AH:Toggs (ahbutlst / fo fname x y keylst keynum v_lst) (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w")) (write-line "AHtoggles : dialog {" fo) (write-line (strcat " label =" (chr 34) (nth 0 ahbutlst) (chr 34) " ;" )fo) (write-line " : column {" fo) (setq x 1) (repeat (- (length ahbutlst) 1) (write-line " : toggle {" fo) (write-line "alignment = left ;" fo) (write-line (strcat "key = " (chr 34) "Tb" (rtos x 2 0) (chr 34) ";") fo) (write-line (strcat "label = " (chr 34) (nth x ahbutlst) (chr 34) ";") fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (setq x (+ x 1)) ) (write-line "spacer_1 ;" fo) (write-line " ok_cancel;" fo) (write-line " }" fo) (write-line " }" fo) (close fo) (setq dcl_id (load_dialog fname)) (if (not (new_dialog "AHtoggles" dcl_id) ) (exit) ) (setq y 0) (repeat (- (length ahbutlst) 1) (setq keynum (strcat "Tb" (rtos (setq y (+ Y 1)) 2 0))) (set_tile keynum "0") (mode_tile keynum 3) ) (action_tile "accept" "(mkv_lst)(done_dialog)") (action_tile "cancel" "(done_dialog)") (start_dialog) (unload_dialog dcl_id) (vl-file-delete fname) (princ v_lst) ) ;=========================================================================================================================================; (defun c:test1 (/ ans1) (if (not AH:Toggs)(load "Multiple toggles.lsp")) (setq ans1 (AH:toggs (list "ROOFTOP" "(Typ.)" "(Type)" "c/c" "±"))) ;end setq list ; /////////////// SINGLE PICKS ///////////////////; (cond ((= (nth 0 ans1) "1")(command "circle" "\\" 100)) ; "±" ((= (nth 1 ans1) "1")(command "circle" "\\" 200)) ; "c/c" ((= (nth 2 ans1) "1")(command "circle" "\\" 300)) ; "(Type)" ((= (nth 3 ans1) "1")(command "circle" "\\" 400)) ; "(Typ.)" ; /////////////// COMBO PICKS ///////////////////; ((and (= (nth 0 ans1) "1")(= (nth 1 ans1) "1")(command "circle" "\\" 10))) ; "±" & "c/c" ((and (= (nth 1 ans1) "1")(= (nth 2 ans1) "1")(command "circle" "\\" 20))) ; "c/c" & "(Type)" ((and (= (nth 1 ans1) "1")(= (nth 3 ans1) "1")(command "circle" "\\" 30))) ; "c/c" & "(Typ.)" ((and (= (nth 0 ans1) "1")(= (nth 1 ans1) "1")(= (nth 2 ans1) "1")(command "circle" "\\" 40))) ; "±" & "c/c" & "(Type)" ((and (= (nth 0 ans1) "1")(= (nth 1 ans1) "1")(= (nth 3 ans1) "1")(command "circle" "\\" 50))) ; "±" & "c/c" & "(Typ.)" ) ;end condition ) ;end defun ;=========================================================================================================================================; Quote
BIGAL Posted December 24, 2019 Posted December 24, 2019 (edited) Ok a couple of changes (setq ans1 (reverse (AH:toggs (list "ROOFTOP" "(Typ.)" "(Type)" "c/c" "±")))) need to reverse list I thought it was in the multi toggle code is now. ((and (= (nth 0 ans1) "1")(= (nth 1 ans1) "1")(command "circle" "\\" 10))) ; "±" & "c/c" ((and (= (nth 0 ans1) "1")(= (nth 1 ans1) "1")) (command "circle" "\\" 10)) ; "±" & "c/c" The "and" must be enclosed look at brackets Edited December 25, 2019 by BIGAL Quote
Sambuddy Posted December 24, 2019 Author Posted December 24, 2019 @BIGAL sorry did not work, still takes the first true statement in the list to execute! 11 hours ago, BIGAL said: ((and (= (nth 0 ans1) "1")(= (nth 1 ans1) "1")) (command "circle" "\\" 10)) ; "±" & "c/c" in this case, if nth 0 was 100 circle (on single picks) it takes that and not the combination. I tried to use IF statements on top of condition and I get some random good results - not consistent! I know it is Christmas Eve - but when you have some time, could you please let me know where I am going wrong? Thanks, Quote
Sambuddy Posted December 24, 2019 Author Posted December 24, 2019 my bad! I did not know that condition evaluates the first true statement - so I inserted my multiple condition statements before single picks and it works! now I have a different problem: This one works ( (and (= (nth 1 ans1) "1") (= (nth 2 ans1) "1") ) (command "circle" "\\" 20) ) this one does not work ( (and (= (nth 1 ans1) "1") (= (nth 2 ans1) "1") (= (nth 3 ans1) "1") ) (command "circle" "\\" 70) ) evaluating with three conditions gives me the result of the first two: example: if nth 1 and nth 2 were to give me "blah", evaluating this argument with three conditions give me the same "blah". Do I have to make another condition for the third one? Quote
BIGAL Posted December 25, 2019 Posted December 25, 2019 I think its in your ans1 using above you need to reverse list then the "and" should work. Its slightly different between cond and if (if (and (= (nth 1 ans1) "1") (= (nth 2 ans1) "1") (= (nth 3 ans1) "1") ) (alert "true") ) cond ((and (= (nth 1 ans1) "1") (= (nth 2 ans1) "1") (= (nth 3 ans1) "1") ) (alert "true") ) Quote
Sambuddy Posted December 26, 2019 Author Posted December 26, 2019 (edited) @BIGAL Your help is greatly appreciated! Wish you Happy Holidays and a 2020 Vision! hah! I founf out - the hard way - that there is a priority on selection when conditions are extended so I just shoved my 4 statements on top followed by 3 and 2 conditions and it works perfectly. Thank you again for your help in solving yet another problem BIGAL! When you have sometime, could you please explain the reason why I am getting: 12 forms loaded from #<editor "D:/..." instead of only 1 for me? is it because I have many defuns? and also what does this mean? the forward slash in a paran by itself! is there a way to include all variables without writing them one by one as local variables? (defun c:test ( / ) Can i also ask you one more thing: I am writing a lisp where I am inserting blocks but because I do not want the cad file to be loaded at once, I chose to select only a number of blocks with a specific command <BLAH> How can I check at the beginning of my new lisp (to insert blocks) to check if <BLAH> is been executed since my blocks are only inserted if <BLAH> is executed. A simple loading does not work: (if (not c:BLAH)(load "BLAH")) Edited December 26, 2019 by Sambuddy Quote
BIGAL Posted December 27, 2019 Posted December 27, 2019 (edited) Like the "multi lisps" I do not have them in any of my code but rather check to see If I have loaded it already. So looking at Multi toggles it has the defun AH:toggs so check for its existence, (if (not AH:toggs)(load "Multiple toggles")) I have all my lisps in a directory that has been added to my search path, Config, Files. This means I do not need to have a path in my load command. (if (not AH:getvalsm)(load "Multi Getvals.lsp")), so the (blkins lisp would have the (if (not, in it. Re setting local variables lee-mac has a tutorial on using vlide it will check for your variable names, you can then copy and paste them very easy into the ( / ? ? ? ) Edited December 27, 2019 by BIGAL Quote
Sambuddy Posted January 2, 2020 Author Posted January 2, 2020 @BIGAL Thank you BIGAL for you help and guidance! I have now created a fancy DCL with your two multi and single selection DCL. It was a GREAT help. Please see attached picture - I am not sure a better way to create a spacer between my groupings. Do you think there is a way I can create a title or spacer? Again - I am amazed of what I was able to create with your help! Regarding the earlier question of loading LISP - it happens many times thatI bring the office laptop home and have to hard code the loading portion as I am not the one in charge office CAD related issues. Would there be a way to hard code two directories - none of which on the trusted search path? a) check path1 and/or B) check path2 and if not loaded, load Blah.lisp Thanks Quote
BIGAL Posted January 3, 2020 Posted January 3, 2020 (edited) You have answered your own question re spacers look up the dcl help for spacer you would just add to code, in multi radio buttons I did add a auto space see below you just need to make the list before doing the (setq ans part you then get the length of this list (length lst) and do say if less than 8 add spacer, remember its actually 6 as ver/hor & label are part of the list. I may not have posted that version. It was based around a user request. (write-line "spacer_1 ;" fo) (if (< numch 8) (write-line "spacer_1 ;" fo) ) (setq x (+ x 1)) ; look for this in multi radio buttons ) (setq lst '("Yes or No" "Yes" "No")) (setq numch (length lst)) (setq ans (ah:butts but "V" lst )) Thinking a bit more maybe add a padding to the text description say 2 spaces then remove when retrieving. You can also get which line was picked in radio buttons, so your cond etc would be more like was it 0 1 2 3 ? So the description is not used as the Text string to be checked. (nth but butlst) remove and (princ but) Lastly there is "text" in dcl I have not used it but you could add extra labels. Send a email to info@alanh.com.au may be easier than clogging up Cadtutor. Edited January 3, 2020 by BIGAL Quote
BIGAL Posted January 3, 2020 Posted January 3, 2020 (edited) Using the support paths is the easiest way and it does not matter if at work or at home if they don't exist Autocad will skip, Ok a simple way around maybe creating a trusted path is to map a drive but it can also be a directory so you could have a trusted path like L:\ for lisps on home computer. Thinking a bit more it could be the name of you network drive. Map a drive can be done at CMD (DOS) level so you could just do when you take it home to look on say a USB. Once turned pff its gone. The other way is you can add trusted paths via lisp, whilst you have trusted paths its so easy to get around it almost why do it. I guess also can remove. May be better here to use setenv and getenv if you close Autocad can get old back. I would setenv once only running the couple of lines of code, don't do each time then no chance of having wrong paths. (setq oldtrust (getvar 'trustedpaths)) (setq newtrust (strcat oldtrust ";" "L:\\Autodesk...")) (setvar 'trustedpaths newtrust) ; back to old (setvar 'trustedpaths oldtrust) (setvar 'trustedpaths (getenv "Trustedpaths")) Edited January 3, 2020 by BIGAL 1 Quote
Sambuddy Posted January 3, 2020 Author Posted January 3, 2020 @BIGAL Thanks again. I did succeed by looking up some DCL tutorials by AFRA I believe. Your help is very extensive and for that I appreciate all your inputs! 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.