j_spawn_h 发表于 2022-7-6 07:57:10

Help Please - with creating ef

I got this to work but before i go any farther is there a better or shorter way to reach the same result? I am using 2012 and these have been modified from some codes I have gotten here.
 

(defun C:bd() ;list your key here, it is not necessary but it will useful with a huge list of key, or you can do a function lisp to write your dcl(setq   lstWidth '( "3.5" "5.25" "7" "1 ply" "2 ply" "3 ply")       lstDepth '("7.25" "9.25" "11.25" "11.875" "14" "16" "18")         lstmembr '("Flush Beam" "Header/Drop Beam"))      (or membr (setq membr (car lstmembr)))(or width (setq width (car lstWidth)))(or depth (setq depth (car lstDepth)))                              (setq dcl_id (load_dialog "beam.dcl"))                      (if (not (new_dialog "beam" dcl_id)) (exit)                           (progn            (set_tile membr "1")       (set_tile width "1")       (set_tile depth "1")                  (action_tile "kmembr" "(setq membr $value)")   (action_tile "kWidth" "(setq width $value)")       (action_tile "kDepth" "(setq depth $value)")       (start_dialog)       (unload_dialog dcl_id)   ))(if (= membr "Flush Beam") (setq tp 2))(if (= membr "Header/Drop Beam") (setq tp 3))(if (= width "3.5") (setq wd 5))(if (= width "5.25") (setq wd 7))(if (= width "7") (setq wd 11))(if (= width "1 ply") (setq wd 13))(if (= depth "7.25") (setq dp 23))(if (= depth "9.25") (setq dp 29))(if (= depth "11.25") (setq dp 31))(setq bt (+ (+ wd dp) tp))(command "filedia" "0") (if (= bt 30)   (command "_.layer" "M" "S-FRM-BEAM" "C" "12" "S-FRM-BEAM" "s" "S-FRM-BEAM" "" "-linetype" "c" "3.5x7.25 PSL" "" "Y" "3.5x7.25 PSL" "0.25,-0.125" "S" "3.5x7.25 PSL" ""    )      ) (if (= bt 39)   (command "_.layer" "M" "S-FRM-HEADER" "C" "1" "S-FRM-HEADER" "s" "S-FRM-HEADER" "" "-linetype" "c" "5.25x9.25 PSL" "" "Y" "5.25x9.25 PSL" "0.25,-0.125" "S" "5.25x9.25 PSL" ""    )      ) (command "filedia" "1") (princ))
 

beam : dialog {label = "Pick a Member";   : row {       : boxed_radio_row {key = "kmembr";         label = "Member";         : radio_button {         label = "Flush Beam";         key = "Flush Beam";         }         : radio_button {         label = "Header/Drop Beam";         key = "Header/Drop Beam";         }}}   : row {       : boxed_radio_row {key = "kWidth";         label = "Width";         : radio_button {         label = "3.5";         key = "3.5";         }         : radio_button {         label = "5.25";         key = "5.25";         }         : radio_button {         label = "7";         key = "7";         }         : radio_button {         label = "1 Ply";         key = "1 Ply";         }                  : radio_button {         label = "2 Ply";         key = "2 Ply";         }                  : radio_button {         label = "3 Ply";         key = "3 Ply";         }}}         : row {       : boxed_radio_row {key = "kDepth";         label = "Depth";          : radio_button {         label = "7.25";         key = "7.25";                  }         : radio_button {         label = "9.25";         key = "9.25";         }         : radio_button {         label = "11.25";         key = "11.25";         }                  : radio_button {         label = "11.875";         key = "11.875";         }                  : radio_button {         label = "14";         key = "14";         }                  : radio_button {         label = "16";         key = "16";         }                  : radio_button {         label = "18";         key = "18";         }}}                : row {       : button {         label = "&OK";         key = "accept";         fixed_width = true;         is_default = true;         alignment = centered;       }         : button {         label = "&Cancel";         key = "cancel";         fixed_width = true;         is_cancel = true;         alignment = centered;       }   }}

Tharwat 发表于 2022-7-6 08:23:12

Is the final result of the routine would be to create specific layers names with some kind of different properties ?
If yes , list the name of your layers to have then in pop_up list instead of all these long lines of codes .

j_spawn_h 发表于 2022-7-6 08:46:09

Sorry what it does is it creats a layer with a linetype then I will make it draw lines where ever I need them, then another routine I have will label all those lines by their linetypes. If that makes since? I just didn't want to keep writing alot of code knowing there has to be shorter way to write it. I trying to learn has i go.

David Bethel 发表于 2022-7-6 09:01:15

While I don't quite understand your entire process,
 
 
You may want to look into (cond) statements:
 

(if (= depth "7.25") (setq dp 23))(if (= depth "9.25") (setq dp 29))(if (= depth "11.25") (setq dp 31))
 

(setq dp(cond ((= depth"7.25") 23)       ((= depth"9.25") 29)       ((= depth "11.25") 31))       (T (alert "Cannot find a Depth - Aborting")          (exit)))
 
But you would need a robust error trap in order to use (exit) safely -David
 
Or you code force a manual input

(setq dp(cond ((= depth"7.25") 23)       ((= depth"9.25") 29)       ((= depth "11.25") 31))       (T (initget 7)          (setq depth "\n Depth Not Found - Enter a Depth Value:   ")))
页: [1]
查看完整版本: Help Please - with creating ef