Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/26/2024 in all areas

  1. Thank you for help, but I have no Idea how to use it. I know something about Lisp routines, but not about this kind....I am not expert, just average user. Kind regards
    1 point
  2. Based off your very first post: (defun c:test ( / *error* a dch dcl des e i l layerlist len s t1 t2 t3 t4 t5 t6 t7 t8 wid) ;; |JH| Variables localised ;;;List of layers (setq LayerList '("Layer1" "Layer2")) ; List of layers (prompt "\n Select a close polyline") (setq s ; Selection set of closed polylines on layers (ssget (list (cons 0 "*POLYLINE") ;(cons 8 (LM:lst->str LayerList ",")) ;; |JH| Temporarily disabled layers for testing '(-4 . "<OR") '(70 . 1) '(70 . 129) '(-4 . "OR>") ) ) ; end ssget, list ) ; end setq (if s (progn (defun *error* ( msg ) (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 msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))) (princ (strcat "\nError: " msg)) ) (princ) ) (cond ( (not (setq dcl (vl-filename-mktemp nil nil ".dcl") des (open dcl "w") ) ) (princ "\nUnable to open DCL for writing.") ) ( (progn (foreach str '( "ed : edit_box { alignment = left; width = 20; edit_width = 10; fixed_width = true;}" "" "test : dialog { spacer; key = \"dcl\";" " : boxed_column { label = \"Select the scale\"; height = 1.0;" " : radio_button { height = 1.0; width = 20; is_tab_stop = true;" " key = \"radio_button01\"; label = \"1. 1:1000\";" " }" ; radio_button " : radio_button { height = 1.0; width = 20; is_tab_stop = true;" " key = \"radio_button02\"; label = \"2. 1:5000\";" " }" ; radio_button " }" ;end boxed_column " : boxed_column { label = \"Results\"; height = 1.0;" " : row" " {" " : ed { key = \"a\"; label = \"Polyline Area:\"; is_enabled = false;}" " : ed { key = \"res1\"; label = \"Calculate An:\"; is_enabled = false; }" " }"; end row " : row" " {" " : ed { key = \"res2\"; label = \"Area min:\"; is_enabled = false;}" " : ed { key = \"res3\"; label = \"Area max:\"; is_enabled = false; }" " }"; end row " : row" " {" " : ed { key = \"res4\"; label = \"Comment :\"; is_enabled = false; }" " }"; end row " }" ;end boxed_column " : row" " {" " : column { width = 10;" " }" ; end column " : column { width = 17;" " : button { key = \"cal\"; label = \"Calculations\"; is_default = true;" " is_cancel = false; fixed_width = true; width = 10; }" " }" ; end column " : column { width = 17;" " : button { key = \"OK\"; label = \"OK\"; is_default = true;" " is_cancel = true; fixed_width = true; width = 10; }" " }" ; end column " }" ; end row " }" ; end dialog ) (write-line str des) ) (setq des (close des) dch (load_dialog dcl) ) (<= dch 0) ) (princ "\nUnable to load DCL file.") ) ( (not (new_dialog "test" dch)) (princ "\nUnable to display 'test' dialog.") ) (t (set_tile "dcl" "Calculate An") (action_tile "a" "(setq a $value)") (action_tile "cal" (vl-prin1-to-string (quote ;; |JH| Changed to quote (Not really necessary, but just to have it look neater?) (progn ;; |JH| Changed to progn so that the QUOTE function will not run with any errors. (set_tile "res1" "") (set_tile "res2" "") (set_tile "res3" "") (set_tile "res4" "") (setq l 0.0 a 0.0 i 0 ) (while (< i (sslength s)) (progn (setq e (ssname s i) l (+ l (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) ) a (+ a (vlax-curve-getarea e)) i (1+ i) ;; |JH| Line added so as to not get stuck in the while loop. ) ) (setq t3 (* a 0.07)) (setq t4 (* a 0.10)) (cond ((= (get_tile "radio_button01") "1") ; Option 1 scale 1:1000 |JH| - get_tile returns a string, so the "1" needs to be enclosed in a string. (setq t1 (/ (* (- (expt (+ (sqrt a) 1) 2) a) l 0.25) (sqrt a)) t5 (- t1 a) t6 (- t3 a) t7 (- t1 a) t8 (- t3 a) ) (mode_tile "a" 2) (set_tile "res1" (rtos (if (> t1 t3) t3 t1) 2 2)) (set_tile "res2" (rtos (if (> t1 t3) t6 t5) 2 2)) (set_tile "res3" (rtos (if (> t1 t3) t8 t7) 2 2)) (set_tile "res4" "comment") ) ((= (get_tile "radio_button02") "1") ; Option 2 scale 1:5000 |JH| - get_tile returns a string, so the "1" needs to be enclosed in a string. (setq t2 (/ (* (- (expt (+ (sqrt a) 5) 2) a) l 0.25) (sqrt a)) t5 (- t2 a) t6 (- t4 a) t7 (- t2 a) t8 (- t4 a) ) (mode_tile "a" 2) (set_tile "res1" (rtos (if (> t2 t4) t4 t2) 2 2)) (set_tile "res2" (rtos (if (> t2 t4) t6 t5) 2 2)) (set_tile "res3" (rtos (if (> t2 t4) t8 t7) 2 2)) (set_tile "res4" "comment") ) ) ; end cond ) ) ) ) ) (start_dialog) ;; |JH| Moved line to outside the action_tile function. ) ) (*error* nil) (princ) ) ) ) Fyi, this will only get the calculations to show in the dialog box. Whether the calculations themselves are correct or not is to be determined by you. That said, if you're still stuck, don't hesitate to ask again.
    1 point
  3. And it states one argument, variant (array of doubles). Double is a number. Coordinates are defined by a number. So you have to "use" coordinates. From my understanding, and I'm not an expert I have only recently started digging deeper into Active X stuff, your st-point and en-point are variants right. So "vlax-make-safearray vlax-vbDouble st-point en-point" doesn't work, can't work. And afaik you can't make a variant (array of doubles) with variants st-point and en-point without getting their coordinates (that are - double), what you are here for some reason trying to avoid. To give a comparison with AutoLISP, its like wanting to create a line by only selecting two points with (car (entsel)). You get entity of each point, but you have to extract its coordinates to eventually create a line. If I'm wrong someone correct me of course.
    1 point
×
×
  • Create New...