Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/17/2020 in all areas

  1. This (sub)function is part of a larger appie I'm currently working on (not sure how I'm gonna name the larger app yet , for now called it RlxBlockSync but also entertaining the idea to call RFD, redefine for dummies ) Anyways, this sub dynamically creates a dialog and takes 'commatized' strings for input. Few years ago I wrote Tokkie, this basically does the same , just a little different and with less code. I was inspired by a similar function master L created and later Grrr made something like that. The reason I use commatized / csv strings is so I can save the output of this function as a string in the registry. Added little test function which generates 3 list boxes but you can have as many LB's as you like, the only limitations are your imagination and the width of your monitor. I hope by analyzing the test function (c:t1) you understand how you can use this function. ; multiple input listbox function : mlist = ( ( description1 (labels1) (defaults1) ) ...) (defun milf ( mlist / get_lb_width commatize de-commatize _ufo toggle fn fp dcl lb-width old-props new-props plist tmp out) ; get max strlen from list arguments for milf (defun get_lb_width (l) (apply 'max (mapcar 'strlen (apply 'append (mapcar 'de-commatize (mapcar 'cadr l)))))) ; (commatize '("a" "b" "c")) -> "a,b,c" (defun commatize (l) (apply 'strcat (cdr (apply 'append (mapcar '(lambda (x) (list "," x)) l))))) ; (de-commatize "a,b,c") -> ("a" "b" "c") (defun de-commatize (s / p)(if (setq p (vl-string-search "," s))(cons (substr s 1 p)(de-commatize (substr s (+ p 2))))(list s))) ; use filter on : (_ufo "*" '("door" "table" "floor")) (_ufo "o" '("door" "table" "floor")) (defun _ufo ( f l ) (if (and (= (type f) 'STR) (/= f "")) (vl-remove-if '(lambda (s)(not (or (eq f "*") (vl-string-search (strcase f)(strcase s))))) l))) ; adds / removes [0] or [X] before each item in listboxes (defun toggle (k v / lst r s) (if (eq (substr (setq r (nth (atoi v) (setq lst (cdr (assoc k plist))))) 2 1) "X") (setq s "[O] ") (setq s "[X] ")) (setq plist (subst (cons k (setq lst (subst (strcat s (substr r 5)) r lst))) (assoc k plist) plist)) (start_list k)(mapcar 'add_list lst)(end_list)(set_tile k v)) ; calculated width of list boxes by finding longest string (setq lb-width (+ (get_lb_width mlist) 5)) (if (not (setq fp (open (setq fn (vl-filename-mktemp ".dcl")) "w"))) (princ "\nUnable to create temporary dcl file") (progn (write-line "milf:dialog {label=\"Multiple Input Listbox Function (RLX 5/'20)\";:row {" fp) (setq lb 0) (foreach item mlist (write-line (strcat ":column {label=\"" (car item) "\";:list_box{height=16;width=" (itoa lb-width) ";key=\"lb" (itoa (setq lb (1+ lb))) "\";}}") fp)) (write-line "}ok_cancel;}" fp)(if fp (progn (close fp)(gc))) (if (not (and (< 0 (setq dcl (load_dialog fn))) (new_dialog "milf" dcl))) (princ "\nUnable to start dialog milf") (progn (setq lb 0) (foreach item mlist (setq old-props (de-commatize (cadr item)) new-props (de-commatize (caddr item))) (setq l (mapcar '(lambda (x)(if (member x new-props)(strcat "[X] " x)(strcat "[O] " x))) old-props)) (setq lb-id (strcat "lb" (itoa (setq lb (1+ lb)))) plist (cons (cons lb-id l) plist)) (start_list lb-id) (mapcar 'add_list l) (end_list) (action_tile (strcat "lb" (itoa lb)) "(toggle $key $value)") ) (action_tile "accept" "(done_dialog 1)") (action_tile "cancel" "(done_dialog 0)") (setq drv (start_dialog)) (unload_dialog dcl)(vl-file-delete fn) ) ) ) ) (if (= drv 1) (mapcar '(lambda (x)(commatize (mapcar '(lambda (y)(substr y 5)) x))) (mapcar '(lambda (x)(_ufo "[X]" x))(mapcar 'cdr (reverse plist)))) nil) ) (defun c:t1 ( / result-list animals breakfast music) (setq animals "Aardvark,Baboon,Camel,Dragons,Easterbunny,Firebird,Godzilla,Hobbit,Idiot,Phoenix") (setq breakfast "Anna Nicole,Beyoncé Knowles,Carmen Electra,Daenerys Targaryen,Ella Enchanted,Gal Gadot,Sophie Turner") (setq music "Andrea Bocelli,Electric Light Orchestra,Earth Wind & Fire,George Michael,Lara Fabian,Queen") (setq result-list (milf (list (list "Animals" animals "Dragons,Phoenix") (list "Breakfast" breakfast "Gal Gadot,Sophie Turner") (list "Music" music "Electric Light Orchestra,Lara Fabian") ;;; add as many list as you want limited only by the size of the screen ) ) ) (princ "\n\nYou made the following selections : ") (mapcar '(lambda (label value) (princ (strcat "\n\n" label "\nvalue : " value))) '("Animals :" "Breakfast :" "Music :" ) result-list) (princ "\n\n") (princ) ) I can show you how other app looks , but that's not finished yet (if ever) so will get back to that later Awell... hope I didn't forget any sub functions that are allways loaded automatically on my own pc (autoload & forget) but if so let me know (wouldn't be the first time I forgot something and probably not the last time) happy coding
    1 point
  2. (setvar 'osnapz 1) ; 2D (setvar 'elevation 100.) ;plan elevation (defun c:test ( / pt1 pt2) (ai_sysvar '(("OSNAPZ" . 1)("ELEVATION" . 100.0 ))) (and (setq pt1 (getpoint "\nPick 1st point for length ")) (setq pt2 (getpoint pt1 "\nPick 2nd point for length ")) (entmakex (vl-list* '(0 . "line") '(8 . "01-identity") (mapcar ''((a b) (cons a (trans b 1 0))) '(10 11) (list pt1 pt2)) ) ) ) (ai_sysvar nil) ; restore sysvar (princ) )
    1 point
  3. So, changing the display order is not possible, however a new major point version of the forum software will shortly be available and this will allow users to state where they are taken when they click a topic title - first, last or last read. See the details here: https://invisioncommunity.com/news/product-updates/45-user-interface-improvements-r1182/
    1 point
  4. More like this one then using a triple lookup. StretchSample(1).dwg
    1 point
  5. One of the tools that we often forget is the Quick Select Tool. We can use Quick Select Tool to select the layers/ blocks that we want to isolate. This is extremely useful for those with specific layers, (Furniture Layer- Interior; Furniture Layer ref- Ceiling) because from there you can influence how the block behaves. An example would be using blocks for different specific sheets (Architectural- walls only, no furniture; Interior- Furniture only no lighting; Lighting Plan, Furniture setting in dotted outline; and so on.) To access this tool, we can right click into the model space and pick it from the drop down list. Pick the one with the lightning and an arrow. Pick the drop-down to select an entire drawing, from the properties you may check the layers you want to change. Cheers, -Chris E., AllAboutcad.com
    1 point
  6. Here's a tip that I think might be of value: For anyone finding themselves with dimensions that have different scales from paper space to model space you may use DIMLFAC. DIMLFAC allows you to dimension in paper space that is associative in scale to the drawing in model space. Just type it in and set the value to 1, to use dimension for both model and paper space Cheers, -Chris E., AllAboutCad.com
    1 point
×
×
  • Create New...