Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/04/2021 in all areas

  1. If you are reading it from a CDV file, it should be just a text string? So Help: vl-string-trim (AutoLISP) (autodesk.com) should do the trick.
    1 point
  2. ENAMES are not constant over different acad sessions, so even restoring them from text (which is impossible) would be useless. Instead, you should save the handle of the entity as text and restore it with (handent <handle>). _$ e <Entity name: 21f6b3c3a00> _$ (setq h (cdr (assoc 5 (entget e)))) "180408" _$ (handent h) <Entity name: 21f6b3c3a00>
    1 point
  3. Here is a more than you asked for but shows the properties of a viewport you could pick north point and get angle, you may need to set angdir 1st else will possibly get wrong angle. You should be able to put twistangle not tested. (command "._PSPACE") (setq sss (ssget "_+.:E:S" (list (cons 0 "Viewport")))) (setq cspace (cdr (assoc 69 (entget (ssname sss 0))))) (setq obj (vlax-ename->vla-object (ssname sss 0))) (if (= (vla-get-objectname obj) "AcDbViewport") (progn (setq cen (vlax-get obj 'Center )) (setq ht (vlax-get obj 'Height)) (setq wid (vlax-get obj 'Width)) (setq sc (vlax-get obj 'customscale )) (setq ang (vlax-get obj 'TwistAngle)) )) I have the other rotate block to match a viewpoint angle.
    1 point
  4. maybe like this : (defun c:pref (/ as ct ln list1 name op prefi sufi text1 dialog) (setvar "cmdecho" 0) (vl-cmdf "_.undo" "_begin") ;(oldvars) ;(newvars) (setvar "osmode" 0) (princ "\nSelect the texts to be modified.") (setq list1 (ssget (list (cons 0 "TEXT,MTEXT")))) (if list1 (progn (if (and (< 0 (setq dialog (load_dialog "pref.dcl"))) (new_dialog "pref" dialog) ) (progn (action_tile "rb1" "(setq op \"Prefix\") (mode_tile \"eb1\" 0) (mode_tile \"eb2\" 1) (mode_tile \"eb1\" 2)" ) (action_tile "rb2" "(setq op \"Suffix\") (mode_tile \"eb2\" 0) (mode_tile \"eb1\" 1) (mode_tile \"eb2\" 2)" ) (action_tile "rb3" "(setq op \"Both\") (mode_tile \"eb1\" 0) (mode_tile \"eb2\" 0) (mode_tile \"eb1\" 2)" ) (mode_tile "eb1" 2) ;;; Focus on eb1 (action_tile "cancel" "(done_dialog) (setq op nil)" ) ;;; (action_tile "accept" "(setq prefi (get_tile \"eb1\"))(setq sufi (get_tile \"eb2\"))(valid)(done_dialog)") (action_tile "accept" "(setq prefi (get_tile \"eb1\"))(setq sufi (get_tile \"eb2\"))(validate)") ) ;;; End progn ) ;;; End if (start_dialog) (unload_dialog dialog) (setq ct 0 ln (sslength list1) ) ;;; End setq (while (< ct ln) (setq name (entget (ssname list1 ct)) text1 (cdr (setq as (assoc 1 name)))) (cond ((= op "Prefix") (setq text1 (strcat prefi text1))) ((= op "Suffix") (setq text1 (strcat text1 sufi))) ((= op "Both") (setq text1 (strcat prefi text1 sufi))) ((= op nil) ) ) (setq name (subst (cons 1 text1) as name)) (entmod name) (setq ct (1+ ct)) ) ;;; End while ) ;;; End progn (princ "\nThere are no selected texts") ) ;;; End if ;(reset) (vl-cmdf "_.undo" "_end") (princ "\n") (princ) ) (defun validate () (cond ;;; prefix only ((and (vl-every '(lambda (but val)(= (get_tile but) val)) '("rb1" "rb2" "rb3") '("1" "0" "0")) (not (void (get_tile "eb1")))) (done_dialog)) ;;; suffix only ((and (vl-every '(lambda (but val)(= (get_tile but) val)) '("rb1" "rb2" "rb3") '("0" "1" "0")) (not (void (get_tile "eb2")))) (done_dialog)) ;;; both prefix & suffix ((and (vl-every '(lambda (but val)(= (get_tile but) val)) '("rb1" "rb2" "rb3") '("0" "0" "1")) (not (void (get_tile "eb1")))(not (void (get_tile "eb2")))) (done_dialog)) ;;; not some of the radio buts was selected ((not (vl-some '(lambda (x)(eq "1" (get_tile x))) '("rb1" "rb2" "rb3"))) (alert "Invalid radio button selection")) ;;; prefix rb was selected but not a value in edit box ((and (= "1" (get_tile "rb1")) (= "0" (get_tile "rb2"))(void (get_tile "eb1"))) (alert "Prefix is empty")) ;;; prefix rb was selected but not a value in edit box ((and (= "0" (get_tile "rb1")) (= "1" (get_tile "rb2")) (void (get_tile "eb2"))) (alert "Suffix is empty")) ;;; whatever (t (alert "Data not complete")) ) ) ; checks if variable is bound and if it is a string it's not empty (defun void (x)(or (null x)(and (eq 'LIST (type x))(not (vl-consp x)))(and (eq 'STR (type x))(eq "" (vl-string-trim " \t\r\n" x)))))
    1 point
  5. Re add dcl to lisp you can simply write-line every line of the dcl to a file, make sure you allow for \" in the write line. Where quotes are required. This uses a slide for a image display but also shows how to write the dcl in a file note the (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w")) this writes a temporary file and when done dialog deletes it. ; Getvals multi allows multiple line inputs with an image must be a slide image ; By Alan H Oct 2019 ; code examples ; (if (not AH:getvalsimg)(load "Multi Getvals img.lsp")) ; (setq ans (AH:getvalsimg "D:\\Acadtemp\\furntable" 40 (list "Enter table size" "Enter length" 5 4 "1200" "Enter width" 5 4 "900" "Table thickness" 5 4 "30" "Enter height" 5 4 "900" "Enter Leg size" 5 4 "100"))) (defun AH:getvalsimg (img_name siz dcllst / x y num fo fname keynum key_lst v_lst) (setq num (/ (- (length dcllst) 1) 4)) (setq x 0) (setq y 0) (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w")) ;(setq fo (open (setq fname "d:\\acadtemp\\alantest.dcl") "w")) (write-line "getvalsimg : dialog {" fo) (write-line (strcat "label = " (chr 34) (nth 0 dcllst) (chr 34) " ; ") fo) (write-line " : row {" fo) (write-line "spacer ;" fo) (write-line " : column {" fo) (write-line "spacer ;" fo) (write-line " : icon_image { " fo) (write-line (strcat " width =" (rtos siz 2 0) " ;") fo) (write-line " aspect_ratio = 1.0 ;" fo) (write-line (strcat "key = " (chr 34) "Ah_img" (chr 34) " ;") fo) (write-line " }" fo) (write-line " }" fo) (write-line " : boxed_column {" fo) (write-line " width = 22 ;" fo) (write-line "spacer_1 ;" fo) (repeat num (write-line ": edit_box {" fo) (setq keynum (strcat "key" (rtos (setq y (+ Y 1)) 2 0))) (write-line (strcat " key = " (chr 34) keynum (chr 34) ";") fo) (write-line (strcat " label = " (chr 34) (nth (+ x 1) dcllst) (chr 34) ";") fo) (write-line (strcat " edit_width = " (rtos (nth (+ x 2) dcllst) 2 0) ";") fo) (write-line (strcat " edit_limit = " (rtos (nth (+ x 3) dcllst) 2 0) ";") fo) (write-line " is_enabled = true ;" fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (setq x (+ x 4)) ) (write-line " }" fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (write-line "ok_only;}" fo) (close fo) (setq dcl_id (load_dialog fname)) (if (not (new_dialog "getvalsimg" dcl_id)) (exit) ) (setq x 0) (setq y 0) (setq v_lst '()) (repeat num (setq keynum (strcat "key" (rtos (setq y (+ Y 1)) 2 0))) (setq key_lst (cons keynum key_lst)) (set_tile keynum (nth (setq x (+ x 4)) dcllst)) (mode_tile keynum 3) ) (start_image "Ah_img") (slide_image 0 0 (- (dimx_tile "Ah_img") 1) (- (dimy_tile "Ah_img") 1) img_name) (end_image) (action_tile "accept" "(mapcar '(lambda (x) (setq v_lst (cons (get_tile x) v_lst))) key_lst)(done_dialog)") (start_dialog) (unload_dialog dcl_id) (vl-file-delete fname) (princ v_lst) ) I have not looked properly at your dcl and code, so no comment at this stage. Maybe later if no one else answers.
    1 point
×
×
  • Create New...