dimka Posted February 15, 2021 Share Posted February 15, 2021 I have multiple objects that are closed polylines and need to enter the extrude value through the DCL interface. Some of the input boxes are left empty/blank, meaning some of object I don’t want to extrude. When I want to extrude, the script will stop when it encounters a blank or 0 value. How can I write a script to skip the blank input box? Due to limited skill, I am very basic lisp experience and DCL to complete this lisp. I hope everyone can help, thank you this is the lisp (defun c:3dext1 () (setq AR "arlayer") ;AR (setq CO "colayer") ;CO (setq FR "frlayer") ;FR (dcl_3dextr) (princ) ) (defun dcl_3dextr ( ) (setq dcl_id_PARA (load_dialog "3Dextr.dcl")) (if (not (new_dialog "dextr" dcl_id_PARA)) (exit) ) (set_tile "arval" "") (set_tile "coval" "") (set_tile "frval" "") (action_tile "accept-ht" "(get_1ht) (done_dialog 1)") (action_tile "cancel" "(done_dialog)") (setq dd (start_dialog)) (cond ((= dd 1) (main-extru)) ) (unload_dialog dcl_id_PARA) ) (defun get_1ht () (setq arh (atof (get_tile "arval"))) (setq coh (atof (get_tile "coval"))) (setq frh (atof (get_tile "frval"))) ) (defun main-extru (/) (command "_.view" "_swiso" ) (command "_.zoom" "_extents") (command "_.LAYER" "_T" AR "_S" AR "_F" "*" "") (command "_.extrude" "all" "" arh ) (command "_.LAYER" "_T" CO "_S" CO "_F" "*" "") (command "_.extrude" "all" "" coh ) (command "_.LAYER" "_T" FR "_S" FR "_F" "*" "") (command "_.extrude" "all" "" frh ) (princ) ) ;_ defun DCL here dextr : dialog { label = "extrude by val" ; :row { : edit_box {key = "arval"; label = "a"; edit_width = 3; value = "000";} : edit_box {key = "coval"; label = "c"; edit_width = 3; value = "000";} : edit_box {key = "frval"; label = "f"; edit_width = 3; value = "000";} : button { label = "OK"; key = "accept-ht"; width = 12; fixed_width = true; mnemonic = "O"; } : button { label = "Cancel"; key = "cancel"; width = 12; fixed_width = true; mnemonic = "C"; is_cancel = true; } } } Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 16, 2021 Share Posted February 16, 2021 (edited) You'll need to use a conditional statement, such as an if or cond statement to test whether the supplied extrusion height is present and numerical prior to performing the extrude operation. I would suggest using the distof function in place of atof to perform the conversion from a string to a float, as this function will return nil if the supplied string is not numerical. You can then implement a test such as the following: (if arh (progn (command "_.-layer" ...) (command "_.extrude" ...) ... ) ) (if coh (progn (command "_.-layer" ...) (command "_.extrude" ...) ... ) ) ... Edited February 16, 2021 by Lee Mac Quote Link to comment Share on other sites More sharing options...
dimka Posted February 17, 2021 Author Share Posted February 17, 2021 Ok, i will give those a try. thank you very much! Quote Link to comment Share on other sites More sharing options...
dimka Posted April 7, 2021 Author Share Posted April 7, 2021 On 2/17/2021 at 12:20 AM, Lee Mac said: (if arh (progn (command "_.-layer" ...) (command "_.extrude" ...) ... ) ) (cond ((< arh "0") nil ) ((> arh "0") (command "_.extrude" "all" "" arh )) ) ... .. Thank you for your advice. Finally, I used cond to avoid this problem. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 7, 2021 Share Posted April 7, 2021 (edited) 13 hours ago, dimka said: (cond ((< arh "0") nil ) ((> arh "0") (command "_.extrude" "all" "" arh )) ) ... .. Thank you for your advice. Finally, I used cond to avoid this problem. You're welcome! Since you're only taking action if 'arh' is greater than zero in string format*, the above could be written as: (if (< "0" arh) (command "_.extrude" "_all" "" arh)) *Consider either converting the value to an integer or using the not equal operator '/=' since, whilst it is possible to compare strings in this manner, the strings will be compared on a character-by-character basis comparing the ASCII code for each character, which may not yield an expected result - e.g. (< "10" "2") would return True. Edited April 7, 2021 by Lee Mac 1 Quote Link to comment Share on other sites More sharing options...
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.