Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/10/2024 in all areas

  1. You say before: I have specified the code for this task. But you can add for exemple at line 5: ((lambda ( / e_sel e pt_sel) (princ "\nSelect an object.") (cond ((setq e_sel (entsel)) (setq e (car e_sel) pt_sel (osnap (cadr e_sel) "_near,_ins,_nod")) (command "_.dview" e "" "_points" "_none" (list (car pt_sel) (cadr pt_sel) 0.0) "_none" (list (car pt_sel) (cadr pt_sel) 1.0) "" ) (sssetfirst nil (ssadd (car e_sel))) ) (T (princ "\nNothing selected.")) ) (prin1) )) For pnod I can't incorporate this, but without control of the return of "pnod" you can try this ((lambda ( / pt_sel) (command "_.ID" "_pnod" pause) (setq pt_sel (getvar "LASTPOINT")) (command "_.dview" "" "_points" "_none" (list (car pt_sel) (cadr pt_sel) 0.0) "_none" (list (car pt_sel) (cadr pt_sel) 1.0) "" ) (prin1) ))
    1 point
  2. I think Steven and Bigal have given some excellent and learnfull advise so far , but , your code is like getting too near to a black hole and is getting spaghettified. And believe me , I'm an expert on black holes , just ask my wife ... Anyways , maybe just taking count calcula out of the vl-princ-to-string environment could make it a bit more readable? I'm not sure if I do the math correct because I see no real difference between the handling of (<= e 250) , (and (> e 250) (<= e 1000)) & (and (> e 250) (<= e 1000)) But I'll leave that up to you code below is just meant as advise to supplement the ones posted before , not to compete. And believe me , you don't want to compete with me because if I end up in a life threatening situation , I always carry a picture of my mother-in-law in my wallet! Yeah I know , that's cruel , even by my standards , but as a last resort.... and trust me , once seen , it cannot be unseen. (defun c:test (/ *error* dch dcl des area e my-pop-list pop-index) (defun *error* (m) (if (and (= 'int (type dch)) (< 0 dch)) (unload_dialog dch)) (if (= 'file (type des))(close des))(if (and (= 'str (type dcl))(findfile dcl))(vl-file-delete dcl)) (if (and m (not (wcmatch (strcase m t) "*break,*cancel*,*exit*")))(princ (strcat "\nError: " m)))(princ)) ;;; action popup_list returns index number as a string so use (nth (atoi pop-index) my-pop ;;; also no harm in using 'area' in both lisp & dcl instead of just a , just a better read , that's all (setq pop-index "0" my-pop-list '("Option 1" "Option 2" "Option 3" "Option 4")) (cond ((not (setq dcl (vl-filename-mktemp nil nil ".dcl") des (open dcl "w"))) (princ "\nUnable to open DCL for writing.")) ((progn (foreach str '("eb_10 :edit_box {edit_width=10;}" "bt_10 :button {fixed_width=true;width=10;}" "peacost :dialog {label=\"Mhy3sx Nov'24\"; spacer;" " :row {:eb_10 {key=\"eb_area\";label=\"Area\";}:eb_10 {key=\"res1\";label=\"Calc:\";}}" " :eb_10 {key=\"res2\";label=\"Text\";}spacer;:popup_list {key=\"pop_1\";value=\"0\";}" " spacer; :concatenation {alignment=centered;"":bt_10 {key=\"cal\";label=\"Calc\";}ok_only;}}") (write-line str des) ) (setq des (close des) dch (load_dialog dcl))(<= dch 0) ) (princ "\nUnable to load DCL file.") ) ((not (new_dialog "peacost" dch)) (princ "\nUnable to display 'peacost' dialog.")) (t ;;; lock & load the dialog (set_tile "dcl" "Any name") ;;; no harm using area instead of a (action_tile "eb_area" "(setq area $value)") (start_list "pop_1")(mapcar 'add_list my-pop-list)(end_list) (action_tile "pop_1" "(setq pop-index $value)") (action_tile "cal" "(Do_The_Calculation)") (start_dialog) ) ) (*error* nil) (princ) ) (defun Do_The_Calculation ( / calc) ;;; use (calc '(2.50 75)) (defun calc (x) (/ (+ (* (car x) (cadr x)) 1.24))) (set_tile "res1" "") (set_tile "res2" "") ;;; do the t1 math (if (or (not area) (= "" area) (not (setq e (distof area)))) (progn (alert "Please first enter correct value for area")(mode_tile "eb_area" 2)) (setq t1 (calc (nth (atoi pop-index) (list '(2.50 75) '(2.75 85) '(285 95) '(2.45 75)))))) ;;; do the t2 math (setq t2 (nth (atoi pop-index) (list 322.58 354.84 384 400))) ;;; looking at code formulas for all value's for e are handled the same? (mode_tile "eb_area" 2)(set_tile "res1" (rtos (if (> t1 t2) t2 t1) 2 2))(set_tile "res2" "text text text") )
    1 point
×
×
  • Create New...