Jump to content

Help with loop and action in edit_box


Anushka

Recommended Posts

Hello guys, help me find a solution and thank you very much in advance.

What is the smartest way to handle situations?
My goal is to create a .dcl with popup_list and options "12F" "24F" "36F" "48F" "96F" "144F" and an edit box to enter a prefix that will be just ONE LETTER.
if I choose the option * 12F * and the prefix * A *
The following layers will be created (all in color 7 and last color 1):

 

"Test AA01"
"Test AA02"
"Test AA03"
"Test AA04"
"Test AA05"
"Test AA06"
"Test AA07"
"Test AA08"
"Test AA09"
"Test AA10"
"Test AA11"
"Test AA12"
"Teste AA No"

 

if I choose the option * 24F * and prefix * B *

 

"Test BA01"
"Test BA02"
"Test BA03"
"Test BA04"
"Test BA05"
"Test BA06"
"Test BA07"
"Test BA08"
"Test BA09"
"Test BA10"
"Test BA11"
"Test BA12"
"Test BA No" 
"Test BB01"
"Test BB02"
"Test BB03"
"Test BB04"
"Test BB05"
"Test BB06"
"Test BB07"
"Test BB08"
"Test BB09"
"Test BB10"
"Test BB11"
"Test BB12"
"Test BB No"  

 

[...] And so on.

Any help will be most welcome.
Once again, thank you for any help !!

;;  _makelayer Lee-Mac - Link:
;;  https://www.cadtutor.net/forum/topic/32900-create-layer-in-autolisp-and-not-set-it-current/

(defun _makelayer ( name color ltype lnwt )
   (
       (lambda ( _function )
           (_function
               (list
                   (cons 0 "LAYER")
                   (cons 100 "AcDbSymbolTableRecord")
                   (cons 100 "AcDbLayerTableRecord")
                   (cons 2 name)
                   (cons 70 0)
                   (cons 62 color)
                   (cons 6 ltype)
                   (cons 370 lnwt)
               )
           )
       )
       (if (tblsearch "LAYER" name)
           (lambda ( data ) (entmod (cons (cons -1 (tblobjname "LAYER" name)) data)))
           entmakex
       )
   )
)

(defun c:Test ()
  ;;  *error* Lee-Mac;;  
  (defun *error* ( msg )
    (if (< 0 dch) (unload_dialog dch))
    (if (= 'file (type des)) (close des))
    (if (and (= 'str (type dcl)) (setq dcl (findfile dcl))) (vl-file-delete dcl))
    (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")))
      (princ (strcat "\nError: " msg))
      )
    (princ)
  )
  (if
    (and
      (setq dcl (vl-filename-mktemp nil nil ".dcl"))
      (setq des (open dcl "w"))
      (foreach str
	       '(
		 ""
		 "dcllayer : dialog"
		 "{"
		 "label = \"Layer\";"
		 "key = \"Title\";"
		 "initial_focus = \"Edit\";"
		 "spacer;"
		 ": row"
		 "   {"
		 "   : column"
		 "     {"
		 "      alignment = centered;"
		 "      fixed_width = true;"
		 "     }"
		 "   : popup_list"
		 "     {"
		 "      key = \"plist\";"
		 "      label = \"Amount \";"
		 "      allow_accept = true;"
		 "      edit_width = 10;"
		 "     }"
		 "   : edit_box"
		 "     {"
		 "      key = \"Edit01\";"
		 "      label = \"Prefix \";"
		 "      allow_accept = true;"
		 "      edit_width = 30;"
		 "      fixed_width = true;"
		 "     }"
		 "   }"
		 "spacer;"
		 "   : row"
		 "   {"
		 "     fixed_width = true;"
		 "     lignment = centered;"
		 "    : ok_button"
		 "    {"
		 "     width = 15;"
		 "    }"
		 "    : cancel_button"
		 "    {"
		 "    width = 15;"
		 "    }"
		 "  }"
		 "} "
		 )
	(write-line str des)
      )
      (not (setq des (close des)))
      (< 0 (setq dch (load_dialog dcl)))
      (new_dialog "test" dch)
     )
    )
)

 

Link to comment
Share on other sites

99% of my code I 'steal' (wink wink) one way or the other from somebody else 😁. I will never be as good as someone like master Lee just to name a random person and in the end even he only uses the commands provided to us by probably some even more clever guys from Autodesk. Just steal , oh I mean learn by example. If I can lisp, so can you. Just take your time and if a task is to difficult , do more research , ask help or lay it to rest for a while until one day you think , oh , I think I can solve it now. The more you try to do yourself , the better you learn.

  • Like 1
Link to comment
Share on other sites

Posted this and 403 error occurred 

 

I have a radio button library routine just run  it twice. It is in the Download area here. The following code will run it. This is only the input part not the make layer. Need to have a think about that part. Can you explain a bit more about the layering what does 36F & B look like will it be BA 1-12 BB 1-12 BC 1-12  and so on ?

 


(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (= but nil)(setq but 1))
(setq ans (ah:butts but "v"  '("Please choose" "12F" "24F" "36F" "48F" "96F" "144F")))
(setq ans2 (ah:butts 1 "v"  '("Choose prefix" "A" "B" "C" "D" "E" "F")))

 

Rlx like the make_letters idea  (setq lst (make_letters "Choose prefix" 65 10 ) ) = A - J  97 5 = a - e   49 5 = 1 - 5

(setq ans2 (ah:butts 1 "v"  lst))

(setq ans2 (ah:butts 1 "v"  (make_letters "Please choose" 97 8)))

 

Maybe should do a double radio dcl library so can pick two buttons.

 

; a=97 A=65 1=49
(defun make_letters (heading  asc num  / lstchar) 
(if (/= heading nil)(setq lstchar (list heading))(setq lstchar '()))
(repeat num 
(setq lstchar (cons (chr asc) lstchar))
(setq asc (+ asc 1))
)
(setq lstchar (reverse lstchar))
(princ lstchar)
)

Edited by BIGAL
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...