woodman78 Posted July 30, 2009 Author Posted July 30, 2009 Thanks Lee Mac, The mode_tile did the job. Quote
The Buzzard Posted July 30, 2009 Posted July 30, 2009 Buzzard,I made the follwoing changes to the output section of the code and it works a dream. Only one thing is whether it is possible to make the type be greyed out if no type is to be selected. Apart from that it is excellent. Thanks ;////////////////////////////////////////////////////////////////////////// ; ; Output Function ; (defun BLINS_OF () (setq outp (strcat DPIP " " STYP)) (command "_-insert" outp pause "1" "1" "0") (princ) ) ; ;////////////////////////////////////////////////////////////////////////// woodman78, Sorry to get back to you so late, Im just tired. Glad to see you are getting it together yourself. And thanks Lee for looking out. Quote
woodman78 Posted July 30, 2009 Author Posted July 30, 2009 Just on that, I have setup a getvar for layer and color to set them to the layer for the block and back to the original setting afterwards. It sets it to the new one but not back when finished. Is it to do with the position of it in the code. See red below. Thanks. ;////////////////////////////////////////////////////////////////////////// ; ; Start-Up Function ; (defun C:BLINS () (BLINS_MF) (princ) ) (princ "\nBLINS.lsp Loaded....") (princ "\nType BLINS to start program.") ; ;////////////////////////////////////////////////////////////////////////// ; ; Choose List Items Function ; (defun BLINS_CLI (lst items) (mapcar '(lambda (i) (nth i lst)) items) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Update Type List Function ; (defun BLINS_UTL (D:PIP) (setq ST_list '("Type A" "Type B" "Type C" "Type D" "Type 1" "Type 2" "Type 3" "Type 4" "No selection")) (cond ((= D:PIP "DP01")(mode_tile "ST" 1)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP02")(mode_tile "ST" 1)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP03")(mode_tile "ST" 1)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP04")(mode_tile "ST" 1)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP05")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP06")(mode_tile "ST" 1)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP07")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP08")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP09")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP10")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(0 1 2 3))))(end_list)) ((= D:PIP "DP11")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Main Function ; (defun BLINS_MF (/ DPIP$ DPIP STYP$ STYP [color=red]SUCL SUCR[/color]) (setq dcl_id (load_dialog "BLINS.dcl")) (if (not (new_dialog "BLINS" dcl_id)) (progn (ALERT "Can not find your dcl file")(exit))) (or D:PIP (setq D:PIP "DP01")) (set_tile D:PIP "1") [color=red] (setq SUCL (getvar "clayer")) (setq SUCR (getvar "cecolor")) [/color] (BLINS_UTL D:PIP) (action_tile "DP01" "(BLINS_UTL (setq D:PIP \"DP01\"))") (action_tile "DP02" "(BLINS_UTL (setq D:PIP \"DP02\"))") (action_tile "DP03" "(BLINS_UTL (setq D:PIP \"DP03\"))") (action_tile "DP04" "(BLINS_UTL (setq D:PIP \"DP04\"))") (action_tile "DP05" "(BLINS_UTL (setq D:PIP \"DP05\"))") (action_tile "DP06" "(BLINS_UTL (setq D:PIP \"DP06\"))") (action_tile "DP07" "(BLINS_UTL (setq D:PIP \"DP07\"))") (action_tile "DP08" "(BLINS_UTL (setq D:PIP \"DP08\"))") (action_tile "DP09" "(BLINS_UTL (setq D:PIP \"DP09\"))") (action_tile "DP10" "(BLINS_UTL (setq D:PIP \"DP10\"))") (action_tile "DP11" "(BLINS_UTL (setq D:PIP \"DP11\"))") (if STYP:DEF (set_tile "ST" (itoa STYP:DEF))) (action_tile "accept" (strcat "(progn (setq S:TYP (atoi (get_tile \"ST\")) STYP:DEF S:TYP)" "(done_dialog)(setq userclick T))")) (action_tile "cancel" "(done_dialog)(setq userclick nil)") (start_dialog)(unload_dialog dcl_id) (if userclick (BLINS_VF)) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Variable Function ; (defun BLINS_VF () (setq DPIP$ D:PIP) (cond ((= DPIP$ "DP01")(setq DPIP "Existing Filter Drains")) ((= DPIP$ "DP02")(setq DPIP "Existing Filter Drains to be Removed")) ((= DPIP$ "DP03")(setq DPIP "Existing Foul Sewer")) ((= DPIP$ "DP04")(setq DPIP "Existing Foul Sewer to be Removed")) ((= DPIP$ "DP05")(setq DPIP "Existing PVC Storm Sewer to be Replaced with Concrete")) ((= DPIP$ "DP06")(setq DPIP "Existing Storm Sewer")) ((= DPIP$ "DP07")(setq DPIP "Existing Storm Sewer to be Relaid")) ((= DPIP$ "DP08")(setq DPIP "Proposed Concrete Class H Piped Culvert")) ((= DPIP$ "DP09")(setq DPIP "Proposed Ductile Iron Storm Sewer")) ((= DPIP$ "DP10")(setq DPIP "Proposed Filter Drain as per RCD-500-1 with Geotextile to top face only")) ((= DPIP$ "DP11")(setq DPIP "Proposed Thermoplastic Integrally Socketed Carrier Drain")) ) (progn (setq S:TYP (fix S:TYP)) (setq S:TYP (nth S:TYP ST_list)) (setq STYP$ S:TYP) (cond ((= STYP$ "Type A") (setq STYP "Type A")) ((= STYP$ "Type B") (setq STYP "Type B")) ((= STYP$ "Type C") (setq STYP "Type C")) ((= STYP$ "Type D") (setq STYP "Type D")) ((= STYP$ "Type 1") (setq STYP "Type 1")) ((= STYP$ "Type 2") (setq STYP "Type 2")) ((= STYP$ "Type 3") (setq STYP "Type 3")) ((= STYP$ "Type 4") (setq STYP "Type 4")) ((= STYP$ "No selection")(setq STYP "")) ) ) (BLINS_OF) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Output Function ; (defun BLINS_OF () (setq outp (strcat DPIP " " STYP)) (command "_.-layer" "_N" "CCC_TITLE_Legend" "_M" "CCC_TITLE_Legend" "_C" "7" "CCC_TITLE_Legend" "" ) (command "_-color" "bylayer") (command "_-insert" outp pause "1" "1" "0") [color=red] (setvar "clayer" SUCL) (setvar "cecolor" SUCR)[/color] (princ) ) ; ;////////////////////////////////////////////////////////////////////////// Quote
Lee Mac Posted July 30, 2009 Posted July 30, 2009 Its because you have localised the variables in the sub-function of the program, hence, after that sub-function has executed, these variables are set to nil. You could localise them in the main-function of the routine and all should be well. Quote
The Buzzard Posted July 30, 2009 Posted July 30, 2009 Just on that, I have setup a getvar for layer and color to set them to the layer for the block and back to the original setting afterwards. It sets it to the new one but not back when finished. Is it to do with the position of it in the code. See red below. Thanks. ;////////////////////////////////////////////////////////////////////////// ; ; Start-Up Function ; (defun C:BLINS () (BLINS_MF) (princ) ) (princ "\nBLINS.lsp Loaded....") (princ "\nType BLINS to start program.") ; ;////////////////////////////////////////////////////////////////////////// ; ; Choose List Items Function ; (defun BLINS_CLI (lst items) (mapcar '(lambda (i) (nth i lst)) items) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Update Type List Function ; (defun BLINS_UTL (D:PIP) (setq ST_list '("Type A" "Type B" "Type C" "Type D" "Type 1" "Type 2" "Type 3" "Type 4" "No selection")) (cond ((= D:PIP "DP01")(mode_tile "ST" 1)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP02")(mode_tile "ST" 1)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP03")(mode_tile "ST" 1)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP04")(mode_tile "ST" 1)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP05")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP06")(mode_tile "ST" 1)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP07")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP08")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP09")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP10")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(0 1 2 3))))(end_list)) ((= D:PIP "DP11")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Main Function ; (defun BLINS_MF (/ DPIP$ DPIP STYP$ STYP [color=red]SUCL SUCR[/color]) (setq dcl_id (load_dialog "BLINS.dcl")) (if (not (new_dialog "BLINS" dcl_id)) (progn (ALERT "Can not find your dcl file")(exit))) (or D:PIP (setq D:PIP "DP01")) (set_tile D:PIP "1") [color=red] (setq SUCL (getvar "clayer"))[/color] [color=red] (setq SUCR (getvar "cecolor"))[/color] (BLINS_UTL D:PIP) (action_tile "DP01" "(BLINS_UTL (setq D:PIP \"DP01\"))") (action_tile "DP02" "(BLINS_UTL (setq D:PIP \"DP02\"))") (action_tile "DP03" "(BLINS_UTL (setq D:PIP \"DP03\"))") (action_tile "DP04" "(BLINS_UTL (setq D:PIP \"DP04\"))") (action_tile "DP05" "(BLINS_UTL (setq D:PIP \"DP05\"))") (action_tile "DP06" "(BLINS_UTL (setq D:PIP \"DP06\"))") (action_tile "DP07" "(BLINS_UTL (setq D:PIP \"DP07\"))") (action_tile "DP08" "(BLINS_UTL (setq D:PIP \"DP08\"))") (action_tile "DP09" "(BLINS_UTL (setq D:PIP \"DP09\"))") (action_tile "DP10" "(BLINS_UTL (setq D:PIP \"DP10\"))") (action_tile "DP11" "(BLINS_UTL (setq D:PIP \"DP11\"))") (if STYP:DEF (set_tile "ST" (itoa STYP:DEF))) (action_tile "accept" (strcat "(progn (setq S:TYP (atoi (get_tile \"ST\")) STYP:DEF S:TYP)" "(done_dialog)(setq userclick T))")) (action_tile "cancel" "(done_dialog)(setq userclick nil)") (start_dialog)(unload_dialog dcl_id) (if userclick (BLINS_VF)) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Variable Function ; (defun BLINS_VF () (setq DPIP$ D:PIP) (cond ((= DPIP$ "DP01")(setq DPIP "Existing Filter Drains")) ((= DPIP$ "DP02")(setq DPIP "Existing Filter Drains to be Removed")) ((= DPIP$ "DP03")(setq DPIP "Existing Foul Sewer")) ((= DPIP$ "DP04")(setq DPIP "Existing Foul Sewer to be Removed")) ((= DPIP$ "DP05")(setq DPIP "Existing PVC Storm Sewer to be Replaced with Concrete")) ((= DPIP$ "DP06")(setq DPIP "Existing Storm Sewer")) ((= DPIP$ "DP07")(setq DPIP "Existing Storm Sewer to be Relaid")) ((= DPIP$ "DP08")(setq DPIP "Proposed Concrete Class H Piped Culvert")) ((= DPIP$ "DP09")(setq DPIP "Proposed Ductile Iron Storm Sewer")) ((= DPIP$ "DP10")(setq DPIP "Proposed Filter Drain as per RCD-500-1 with Geotextile to top face only")) ((= DPIP$ "DP11")(setq DPIP "Proposed Thermoplastic Integrally Socketed Carrier Drain")) ) (progn (setq S:TYP (fix S:TYP)) (setq S:TYP (nth S:TYP ST_list)) (setq STYP$ S:TYP) (cond ((= STYP$ "Type A") (setq STYP "Type A")) ((= STYP$ "Type B") (setq STYP "Type B")) ((= STYP$ "Type C") (setq STYP "Type C")) ((= STYP$ "Type D") (setq STYP "Type D")) ((= STYP$ "Type 1") (setq STYP "Type 1")) ((= STYP$ "Type 2") (setq STYP "Type 2")) ((= STYP$ "Type 3") (setq STYP "Type 3")) ((= STYP$ "Type 4") (setq STYP "Type 4")) ((= STYP$ "No selection")(setq STYP "")) ) ) (BLINS_OF) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Output Function ; (defun BLINS_OF () (setq outp (strcat DPIP " " STYP)) (command "_.-layer" "_N" "CCC_TITLE_Legend" "_M" "CCC_TITLE_Legend" "_C" "7" "CCC_TITLE_Legend" "" ) (command "_-color" "bylayer") (command "_-insert" outp pause "1" "1" "0") [color=red] (setvar "clayer" SUCL)[/color] [color=red] (setvar "cecolor" SUCR)[/color] (princ) ) ; ;////////////////////////////////////////////////////////////////////////// Not sure, because I cannot test. I do not have your blocks. But try this ;////////////////////////////////////////////////////////////////////////// ; ; Start-Up Function ; (defun C:BLINS () (BLINS_MF) (princ) ) (princ "\nBLINS.lsp Loaded....") (princ "\nType BLINS to start program.") ; ;////////////////////////////////////////////////////////////////////////// ; ; Choose List Items Function ; (defun BLINS_CLI (lst items) (mapcar '(lambda (i) (nth i lst)) items) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Update Type List Function ; (defun BLINS_UTL (D:PIP) (setq ST_list '("Type A" "Type B" "Type C" "Type D" "Type 1" "Type 2" "Type 3" "Type 4" "No selection")) (cond ((= D:PIP "DP01")(mode_tile "ST" 1)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP02")(mode_tile "ST" 1)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP03")(mode_tile "ST" 1)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP04")(mode_tile "ST" 1)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP05")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP06")(mode_tile "ST" 1)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP07")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP08")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP09")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP10")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(0 1 2 3))))(end_list)) ((= D:PIP "DP11")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Main Function ; (defun BLINS_MF (/ DPIP$ DPIP STYP$ STYP SUCL SUCR) (setq dcl_id (load_dialog "BLINS.dcl")) (if (not (new_dialog "BLINS" dcl_id)) (progn (ALERT "Can not find your dcl file")(exit))) (or D:PIP (setq D:PIP "DP01")) (set_tile D:PIP "1") (setq SUCL (getvar "clayer")) (setq SUCR (getvar "cecolor")) (BLINS_UTL D:PIP) (action_tile "DP01" "(BLINS_UTL (setq D:PIP \"DP01\"))") (action_tile "DP02" "(BLINS_UTL (setq D:PIP \"DP02\"))") (action_tile "DP03" "(BLINS_UTL (setq D:PIP \"DP03\"))") (action_tile "DP04" "(BLINS_UTL (setq D:PIP \"DP04\"))") (action_tile "DP05" "(BLINS_UTL (setq D:PIP \"DP05\"))") (action_tile "DP06" "(BLINS_UTL (setq D:PIP \"DP06\"))") (action_tile "DP07" "(BLINS_UTL (setq D:PIP \"DP07\"))") (action_tile "DP08" "(BLINS_UTL (setq D:PIP \"DP08\"))") (action_tile "DP09" "(BLINS_UTL (setq D:PIP \"DP09\"))") (action_tile "DP10" "(BLINS_UTL (setq D:PIP \"DP10\"))") (action_tile "DP11" "(BLINS_UTL (setq D:PIP \"DP11\"))") (if STYP:DEF (set_tile "ST" (itoa STYP:DEF))) (action_tile "accept" (strcat "(progn (setq S:TYP (atoi (get_tile \"ST\")) STYP:DEF S:TYP)" "(done_dialog)(setq userclick T))")) (action_tile "cancel" "(done_dialog)(setq userclick nil)") (start_dialog)(unload_dialog dcl_id) (if userclick (BLINS_VF)) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Variable Function ; (defun BLINS_VF () (setq DPIP$ D:PIP) (cond ((= DPIP$ "DP01")(setq DPIP "Existing Filter Drains")) ((= DPIP$ "DP02")(setq DPIP "Existing Filter Drains to be Removed")) ((= DPIP$ "DP03")(setq DPIP "Existing Foul Sewer")) ((= DPIP$ "DP04")(setq DPIP "Existing Foul Sewer to be Removed")) ((= DPIP$ "DP05")(setq DPIP "Existing PVC Storm Sewer to be Replaced with Concrete")) ((= DPIP$ "DP06")(setq DPIP "Existing Storm Sewer")) ((= DPIP$ "DP07")(setq DPIP "Existing Storm Sewer to be Relaid")) ((= DPIP$ "DP08")(setq DPIP "Proposed Concrete Class H Piped Culvert")) ((= DPIP$ "DP09")(setq DPIP "Proposed Ductile Iron Storm Sewer")) ((= DPIP$ "DP10")(setq DPIP "Proposed Filter Drain as per RCD-500-1 with Geotextile to top face only")) ((= DPIP$ "DP11")(setq DPIP "Proposed Thermoplastic Integrally Socketed Carrier Drain")) ) (progn (setq S:TYP (fix S:TYP)) (setq S:TYP (nth S:TYP ST_list)) (setq STYP$ S:TYP) (cond ((= STYP$ "Type A") (setq STYP "Type A")) ((= STYP$ "Type B") (setq STYP "Type B")) ((= STYP$ "Type C") (setq STYP "Type C")) ((= STYP$ "Type D") (setq STYP "Type D")) ((= STYP$ "Type 1") (setq STYP "Type 1")) ((= STYP$ "Type 2") (setq STYP "Type 2")) ((= STYP$ "Type 3") (setq STYP "Type 3")) ((= STYP$ "Type 4") (setq STYP "Type 4")) ((= STYP$ "No selection")(setq STYP "")) ) ) (BLINS_OF) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Output Function ; (defun BLINS_OF () (progn (setq outp (strcat DPIP " " STYP)) (if (null (tblsearch "block" outp) ) (command "_.-layer" "_N" "CCC_TITLE_Legend" "_M" "CCC_TITLE_Legend" "_C" "7" "CCC_TITLE_Legend" "" ) (command "_-color" "bylayer") (command "_-insert" outp pause "1" "1" "0") ) ) (setvar "clayer" SUCL) (setvar "cecolor" SUCR) (princ) ) ; ;////////////////////////////////////////////////////////////////////////// Quote
The Buzzard Posted July 30, 2009 Posted July 30, 2009 woodman78, You made some changes to the Update List Function that look strange. The lists are not reading correctly now. Quote
The Buzzard Posted July 30, 2009 Posted July 30, 2009 I am still uncertain about this because I do not have the block names. Try this one anyway, Adjust as needed: ;////////////////////////////////////////////////////////////////////////// ; ; Start-Up Function ; (defun C:BLINS () (BLINS_MF) (princ) ) (princ "\nBLINS.lsp Loaded....") (princ "\nType BLINS to start program.") ; ;////////////////////////////////////////////////////////////////////////// ; ; Choose List Items Function ; (defun BLINS_CLI (lst items) (mapcar '(lambda (i) (nth i lst)) items) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Update Type List Function ; (defun BLINS_UTL (D:PIP) (setq ST_list '("Type A" "Type B" "Type C" "Type D" "Type 1" "Type 2" "Type 3" "Type 4" "")) (cond ((= D:PIP "DP01")(mode_tile "ST" 1)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP02")(mode_tile "ST" 1)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP03")(mode_tile "ST" 1)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP04")(mode_tile "ST" 1)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP05")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP06")(mode_tile "ST" 1)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP07")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP08")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP09")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP10")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(0 1 2 3))))(end_list)) ((= D:PIP "DP11")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Main Function ; (defun BLINS_MF (/ DPIP$ DPIP STYP$ STYP) (setq SUCL (getvar "clayer")) (setq SUCR (getvar "cecolor")) (setq dcl_id (load_dialog "BLINS.dcl")) (if (not (new_dialog "BLINS" dcl_id)) (progn (ALERT "Can not find your dcl file")(exit))) (or D:PIP (setq D:PIP "DP01")) (set_tile D:PIP "1") (BLINS_UTL D:PIP) (action_tile "DP01" "(BLINS_UTL (setq D:PIP \"DP01\"))") (action_tile "DP02" "(BLINS_UTL (setq D:PIP \"DP02\"))") (action_tile "DP03" "(BLINS_UTL (setq D:PIP \"DP03\"))") (action_tile "DP04" "(BLINS_UTL (setq D:PIP \"DP04\"))") (action_tile "DP05" "(BLINS_UTL (setq D:PIP \"DP05\"))") (action_tile "DP06" "(BLINS_UTL (setq D:PIP \"DP06\"))") (action_tile "DP07" "(BLINS_UTL (setq D:PIP \"DP07\"))") (action_tile "DP08" "(BLINS_UTL (setq D:PIP \"DP08\"))") (action_tile "DP09" "(BLINS_UTL (setq D:PIP \"DP09\"))") (action_tile "DP10" "(BLINS_UTL (setq D:PIP \"DP10\"))") (action_tile "DP11" "(BLINS_UTL (setq D:PIP \"DP11\"))") (if STYP:DEF (set_tile "ST" (itoa STYP:DEF))) (action_tile "accept" (strcat "(progn (setq S:TYP (atoi (get_tile \"ST\")) STYP:DEF S:TYP)" "(done_dialog)(setq userclick T))")) (action_tile "cancel" "(done_dialog)(setq userclick nil)") (start_dialog)(unload_dialog dcl_id) (if userclick (BLINS_VF)) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Variable Function ; (defun BLINS_VF () (setq DPIP$ D:PIP) (cond ((= DPIP$ "DP01")(setq DPIP "Existing Filter Drains")) ((= DPIP$ "DP02")(setq DPIP "Existing Filter Drains to be Removed")) ((= DPIP$ "DP03")(setq DPIP "Existing Foul Sewer")) ((= DPIP$ "DP04")(setq DPIP "Existing Foul Sewer to be Removed")) ((= DPIP$ "DP05")(setq DPIP "Existing PVC to be Replaced with Concrete")) ((= DPIP$ "DP06")(setq DPIP "Existing Storm Sewer")) ((= DPIP$ "DP07")(setq DPIP "Existing Storm Sewer to be Relaid")) ((= DPIP$ "DP08")(setq DPIP "Proposed Concrete Class H Piped Culvert")) ((= DPIP$ "DP09")(setq DPIP "Proposed Ductile Iron Storm Sewer")) ((= DPIP$ "DP10")(setq DPIP "Proposed Filter Drain RCD 500 1 Geotextile")) ((= DPIP$ "DP11")(setq DPIP "Proposed Thermoplastic Integrally Socketed Carrier Drain")) ) (progn (setq S:TYP (fix S:TYP)) (setq S:TYP (nth S:TYP ST_list)) (setq STYP$ S:TYP) (cond ((= STYP$ "Type A")(setq STYP "Type A")) ((= STYP$ "Type B")(setq STYP "Type B")) ((= STYP$ "Type C")(setq STYP "Type C")) ((= STYP$ "Type D")(setq STYP "Type D")) ((= STYP$ "Type 1")(setq STYP "Type 1")) ((= STYP$ "Type 2")(setq STYP "Type 2")) ((= STYP$ "Type 3")(setq STYP "Type 3")) ((= STYP$ "Type 4")(setq STYP "Type 4")) ((= STYP$ "") (setq STYP "")) ) ) (BLINS_OF) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Output Function ; (defun BLINS_OF () (BLINS_ML "CCC_TITLE_Legend" "7" "") (setq outp (strcat DPIP " " STYP)) (if (null (tblsearch "block" outp) ) (setq INPT (getpoint "\Get insertion point:")) (command "_.insert" outp INPT "1" "1" "0") ) (setvar "clayer" SUCL) (setvar "cecolor" SUCR) (princ) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Make Layer Function ; (defun BLINS_ML (NLAY CLR LT / LAY FRZ) (setq LAY (tblsearch "layer" NLAY)) (if (not LAY) (command "_.layer" "m" NLAY "c" CLR "" "lt" LT "" "") (progn (setq FRZ (cdr (assoc 70 LAY))) (if (= FRZ 65) (progn (command "_.layer" "t" NLAY "") (command "_.layer" "s" NLAY "")) (command "_.layer" "s" NLAY "")))) ) ; ;////////////////////////////////////////////////////////////////////////// Quote
The Buzzard Posted July 30, 2009 Posted July 30, 2009 woodman78, If you are still having problems with the code, Than it could be here: (setq outp (strcat DPIP " " STYP)) I am not sure because the names assembled in this code may not match if they are written differently. You need to make sure to include any spacing or underscores as well or the block will not be found. If you cannot send copies of your blocks at least supply me with the block names as they are exactly named in your blocks. This will save alot of headaches. If all is well at this point than please inform me. There may also be a possibility that the names in the Variable Function may also be incorrect. This is why it is important to supply information so we do not keep going back and forth. The names I supplied in that section were only for the demonstration as I set the code originally. Thanks, The Buzzard Quote
The Buzzard Posted July 30, 2009 Posted July 30, 2009 I made a fictitious block and removed the tblsearch and the program functions fine. It inserted the block using the names that were assembled in the program. Also the user variables were restored as well. This copy should do it. BLINS.dcl BLINS : dialog { label = "Drainage Legend"; : row { : boxed_radio_column { label = "Select a Drainage Pipe:"; : radio_button { label = "Existing Filter Drains"; key = "DP01"; } : radio_button { label = "Existing Filter Drains to be Removed"; key = "DP02"; } : radio_button { label = "Existing Foul Sewer"; key = "DP03"; } : radio_button { label = "Existing Foul Sewer to be Removed"; key = "DP04"; } : radio_button { label = "Existing PVC to be Replaced with Concrete"; key = "DP05"; } : radio_button { label = "Existing Storm Sewer"; key = "DP06"; } : radio_button { label = "Existing Storm Sewer to be Relaid"; key = "DP07"; } : radio_button { label = "Proposed Concrete Class H Piped Culvert"; key = "DP08"; } : radio_button { label = "Proposed Ductile Iron Storm Sewer"; key = "DP09"; } : radio_button { label = "Proposed Filter Drain RCD 500 1 Geotextile"; key = "DP10"; } : radio_button { label = "Proposed Thermoplastic Integrally Socketed Carrier Drain"; key = "DP11"; } } } : row { : boxed_column { label = "Select a Surround Type:"; : popup_list { key = "ST"; label = "Surround Type:"; edit_width = 12; alignment = right; } : spacer { height = 0; } } } : row { : column { ok_cancel; : paragraph { : text_part { label = "Designed by Brian Deasy"; } : text_part { label = "for CCC NNRDO"; } } } } } BLINS.lsp ;////////////////////////////////////////////////////////////////////////// ; ; Start-Up Function ; (defun C:BLINS () (BLINS_MF) (princ) ) (princ "\nBLINS.lsp Loaded....") (princ "\nType BLINS to start program.") ; ;////////////////////////////////////////////////////////////////////////// ; ; Choose List Items Function ; (defun BLINS_CLI (lst items) (mapcar '(lambda (i) (nth i lst)) items) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Update Type List Function ; (defun BLINS_UTL (D:PIP) (setq ST_list '("Type A" "Type B" "Type C" "Type D" "Type 1" "Type 2" "Type 3" "Type 4" "")) (cond ((= D:PIP "DP01")(mode_tile "ST" 1)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP02")(mode_tile "ST" 1)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP03")(mode_tile "ST" 1)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP04")(mode_tile "ST" 1)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP05")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP06")(mode_tile "ST" 1)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '())) (end_list)) ((= D:PIP "DP07")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP08")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP09")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ((= D:PIP "DP10")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(0 1 2 3))))(end_list)) ((= D:PIP "DP11")(mode_tile "ST" 0)(start_list "ST" 3)(mapcar 'add_list (setq ST_list (BLINS_CLI ST_list '(4 5 6 7))))(end_list)) ) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Main Function ; (defun BLINS_MF (/ DPIP$ DPIP STYP$ STYP SUCL SUCR outp INTP) (setq SUCL (getvar "clayer")) (setq SUCR (getvar "cecolor")) (setq dcl_id (load_dialog "BLINS.dcl")) (if (not (new_dialog "BLINS" dcl_id)) (progn (ALERT "Can not find your dcl file")(exit))) (or D:PIP (setq D:PIP "DP01")) (set_tile D:PIP "1") (BLINS_UTL D:PIP) (action_tile "DP01" "(BLINS_UTL (setq D:PIP \"DP01\"))") (action_tile "DP02" "(BLINS_UTL (setq D:PIP \"DP02\"))") (action_tile "DP03" "(BLINS_UTL (setq D:PIP \"DP03\"))") (action_tile "DP04" "(BLINS_UTL (setq D:PIP \"DP04\"))") (action_tile "DP05" "(BLINS_UTL (setq D:PIP \"DP05\"))") (action_tile "DP06" "(BLINS_UTL (setq D:PIP \"DP06\"))") (action_tile "DP07" "(BLINS_UTL (setq D:PIP \"DP07\"))") (action_tile "DP08" "(BLINS_UTL (setq D:PIP \"DP08\"))") (action_tile "DP09" "(BLINS_UTL (setq D:PIP \"DP09\"))") (action_tile "DP10" "(BLINS_UTL (setq D:PIP \"DP10\"))") (action_tile "DP11" "(BLINS_UTL (setq D:PIP \"DP11\"))") (if STYP:DEF (set_tile "ST" (itoa STYP:DEF))) (action_tile "accept" (strcat "(progn (setq S:TYP (atoi (get_tile \"ST\")) STYP:DEF S:TYP)" "(done_dialog)(setq userclick T))")) (action_tile "cancel" "(done_dialog)(setq userclick nil)") (start_dialog)(unload_dialog dcl_id) (if userclick (BLINS_VF)) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Variable Function ; (defun BLINS_VF () (setq DPIP$ D:PIP) (cond ((= DPIP$ "DP01")(setq DPIP "Existing Filter Drains")) ((= DPIP$ "DP02")(setq DPIP "Existing Filter Drains to be Removed")) ((= DPIP$ "DP03")(setq DPIP "Existing Foul Sewer")) ((= DPIP$ "DP04")(setq DPIP "Existing Foul Sewer to be Removed")) ((= DPIP$ "DP05")(setq DPIP "Existing PVC to be Replaced with Concrete")) ((= DPIP$ "DP06")(setq DPIP "Existing Storm Sewer")) ((= DPIP$ "DP07")(setq DPIP "Existing Storm Sewer to be Relaid")) ((= DPIP$ "DP08")(setq DPIP "Proposed Concrete Class H Piped Culvert")) ((= DPIP$ "DP09")(setq DPIP "Proposed Ductile Iron Storm Sewer")) ((= DPIP$ "DP10")(setq DPIP "Proposed Filter Drain RCD 500 1 Geotextile")) ((= DPIP$ "DP11")(setq DPIP "Proposed Thermoplastic Integrally Socketed Carrier Drain")) ) (progn (setq S:TYP (fix S:TYP)) (setq S:TYP (nth S:TYP ST_list)) (setq STYP$ S:TYP) (cond ((= STYP$ "Type A")(setq STYP "Type A")) ((= STYP$ "Type B")(setq STYP "Type B")) ((= STYP$ "Type C")(setq STYP "Type C")) ((= STYP$ "Type D")(setq STYP "Type D")) ((= STYP$ "Type 1")(setq STYP "Type 1")) ((= STYP$ "Type 2")(setq STYP "Type 2")) ((= STYP$ "Type 3")(setq STYP "Type 3")) ((= STYP$ "Type 4")(setq STYP "Type 4")) ((= STYP$ "") (setq STYP "")) ) ) (BLINS_OF) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Output Function ; (defun BLINS_OF () (BLINS_ML "CCC_TITLE_Legend" "7" "") (setq outp (strcat DPIP " " STYP)) (setq INPT (getpoint "\Get insertion point:")) (command "_.insert" outp INPT "1" "1" "0") (setvar "clayer" SUCL) (setvar "cecolor" SUCR) (princ) ) ; ;////////////////////////////////////////////////////////////////////////// ; ; Make Layer Function ; (defun BLINS_ML (NLAY CLR LT / LAY FRZ) (setq LAY (tblsearch "layer" NLAY)) (if (not LAY) (command "_.layer" "m" NLAY "c" CLR "" "lt" LT "" "") (progn (setq FRZ (cdr (assoc 70 LAY))) (if (= FRZ 65) (progn (command "_.layer" "t" NLAY "") (command "_.layer" "s" NLAY "")) (command "_.layer" "s" NLAY "")))) ) ; ;////////////////////////////////////////////////////////////////////////// Quote
woodman78 Posted July 30, 2009 Author Posted July 30, 2009 Thanks Buzzard, I'll check it out in the morning. What was the problem with the changes i made? just wondering so i can do better the next time. Quote
The Buzzard Posted July 30, 2009 Posted July 30, 2009 The reason your user settings were not resetting was do to the fact that they never got to that point. There were different problems within the code. As I had mentioned you had a problem where you added mode tile to the Update Type List Function, Then there were some problem with the layer command. I gave you a function for this in your last code. There is better error trapping with it. You also were using pause within the insert command where it was not needed. I replaced it with getpoint. Just compare your old code to the last one posted. I also ask you make sure that your block names are the same as what the code is assembling. Because I did not have your block names for comparision, I made a random block and gave it a name and the code would create and it inserted with no problem. I made a mistake using the tblesearch function since I make codes with the block definitions built in. Just a force of habit I guess. Your were kind going in the right direction, But taking some shortcuts. Try to use some of the functions I gave you in the last code. It will save alot of headaches that are not forseen. If there are still any problems and I would think at this point they would be most likely block naming which we can sort this out easy. Just supply me with the block names so it can be tested completely. See you in the am. The Buzzard Quote
woodman78 Posted July 31, 2009 Author Posted July 31, 2009 Thanks for that Buzzard. Another part of the new cad routines locked down. Only a few more to go I hope. I am slowly starting to get into this a bit. Problem is getting the time to throw at it...... Quote
The Buzzard Posted July 31, 2009 Posted July 31, 2009 Thanks for that Buzzard. Another part of the new cad routines locked down. Only a few more to go I hope. I am slowly starting to get into this a bit. Problem is getting the time to throw at it...... I would assume the program is working OK? The part I was not sure about was, I put the names you are using for the blocks in the program without knowing what they are. I guess you must have changed all that. As I said before, Those name were placed in there as part of the demo so you could see the program work. Anyway I hope all is everything is OK. 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.