rcb007 Posted November 11, 2022 Posted November 11, 2022 (edited) I am curious on how I can modify the code; where the user could enter the value in an Edit MText Box rather than on the command line. (initget 6) ;;(setq n (getint "\nHow many more needed: ") ;;<<<<-------- Is it possible to use this (lisped (getvar 'ctab)) for a user to enter a value? (setq n (lisped (getint "")) ;;(lisped (getvar 'ctab)) ;;<<------- Example Edit MText Dialog Box i (+ 1 namei n)) Thanks for any help on this! Edited November 11, 2022 by rcb007 Quote
mhupp Posted November 11, 2022 Posted November 11, 2022 Use a dcl https://autolisp-exchange.com/Tutorials/MyDialogs.htm#MyEditText 1 Quote
Steven P Posted November 12, 2022 Posted November 12, 2022 22 hours ago, mhupp said: Use a dcl https://autolisp-exchange.com/Tutorials/MyDialogs.htm#MyEditText Sort of beaten to it, http://www.lee-mac.com/editbox.html, but doesn't have the 'Full editor' option. For the OP, this pop up box approach I think loses the ability to type multiple lines of text won't it? Can't put a new line character in the text box? Quote
BIGAL Posted November 13, 2022 Posted November 13, 2022 Like others can pop a single dcl use Multi getvals.lsp look here in downlaods. Quote
rcb007 Posted November 14, 2022 Author Posted November 14, 2022 Thanks for the pointer. I have the following full code, but I keep getting an error when running it. ; error: bad argument type: fixnump: nil Not quite sure where the error could be within the dialog. It works with the (getint). (initget 6) -------------------------------------------------- ;;(setq n (getint "\nHow many more needed: ") ;;currently works within command line<<<<-------- Is it possible to use this in dialog box? ------------------------------------------------- (if (not AH:getvalsm)(load "Multi Getvals.lsp")) ;;BigAl's Dialog Box ;(setq n (AH:getvalsm (list "Enter" "How Many More? " 5 4 "100"))) ;(setq n (atof (nth 0 (AH:getvalsm (list "Enter" "How Many More?" 10 8 (rtos n 2 3 )))))) ---------------------------------------------------- (defun c:DeleteAllButCurrentTab nil (vl-load-com) (vlax-for l (vla-get-Layouts (vla-get-ActiveDocument (vlax-get-acad-object) )) (if (not (vl-position (strcase (vla-get-name l)) (cons (strcase (getvar 'CTAB)) '("MODEL") ) ) ) (vla-delete l) )) (princ)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun c:CopyLayouts ( / *error* oCMDECHO ctab name namer namei nname n i x ans n) (defun *error* (errmsg) (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end")) (princ (strcat "\nError: " errmsg))) (setvar 'CMDECHO oCMDECHO) (princ)) (setq oCMDECHO (getvar 'CMDECHO)) (setvar 'CMDECHO 0) (setq cur (getvar 'CTAB)) (c:DeleteAllButCurrentTab) (setq ctab (getvar "ctab")) (setq name (getvar "ctab")) (if (= name "") (setq name ctab)) (setq n (1+ (strlen name)) namei "") (while (and (> n 1) (wcmatch (setq x (substr name (setq n (1- n)) 1)) "#")) (setq namei (strcat x namei))) (setq namer (substr name 1 (- (strlen name) (strlen namei))) namei (atoi namei)) (initget 6) -------------------------------------------------- ;;(setq n (getint "\nHow many more needed: ") ;;currently works within command line<<<<-------- Is it possible to use this in dialog box? ------------------------------------------------- (if (not AH:getvalsm)(load "Multi Getvals.lsp")) ;;BigAl's Dialog Box ;(setq n (AH:getvalsm (list "Enter" "How Many More? " 5 4 "100"))) ;(setq n (atof (nth 0 (AH:getvalsm (list "Enter" "How Many More?" 10 8 (rtos n 2 3 )))))) ---------------------------------------------------- i (+ 1 namei n)) (repeat n (setq nname (strcat namer (itoa (setq i (1- i))))) (if (member nname (layoutlist)) (princ (strcat "\nLayout '" nname " ' already exists.")) (command "_.LAYOUT" "_Copy" name (strcat namer "a") "_.LAYOUT" "_Rename" (strcat namer "a") nname))) (foreach name (layoutlist) (setvar 'ctab name) (setq n (cdr (assoc -1 (dictsearch (namedobjdict) "acad_layout")))) (command "-layer" "Freeze" "*" "Thaw" (strcat "*Area" (itoa (cdr (assoc 71 (dictsearch n name))))) "" ) (command "_mspace") (command "zoom" "extents") (command "ZOOM" "Scale" "1/100xp") (command "_pspace") ) (setvar 'CMDECHO oCMDECHO) (setvar 'CTAB cur) (princ)) Quote
Steven P Posted November 14, 2022 Posted November 14, 2022 fixnump suggests that something in the code is expecting a number but is getting given something else, a string, list or something. BigAl will correct me shortly I am sure, but I think the output from his getvalsm routine is a list and each variable in the list is a string. In this case it is a list of length 1. Putting this after you call his routine: (setq n (atoi (car n))) should make n into a single number and able to be used from then on Quote
BIGAL Posted November 15, 2022 Posted November 15, 2022 (edited) When you use a dcl edit box it only accepts or out puts a string even though you will seem to put in a number like 123 the dcl returns "123" as a string , so Steven P is correct need to convert to a number atof for real or atoi for integer. In the multi getvals you can save a variable say num = 123, then in the multi call just convert it to a string and it will be displayed. Please note that the Multi getvals returns a list of the values, so as you only have one then use the (car to get the 1st value in the list. (if (not AH:getvalsm)(load "Multi Getvals.lsp")) ;;BigAl's Dialog Box (if (= n nil)(setq n 100)) (setq n (atof (car (AH:getvalsm (list "Enter" "How Many More? " 5 4 (rtos n 2 0)))))) Edited November 15, 2022 by BIGAL 1 Quote
rcb007 Posted November 15, 2022 Author Posted November 15, 2022 What is posted does make sense. However, when I place the updated code, it still seems to be getting that error. The error happens immediately once I load the routine. Layouts.lsp") ; error: bad argument type: fixnump: nil I have flipped the atof to the atoi to force the string to become an integer number, but still errors. (setq namer (substr name 1 (- (strlen name) (strlen namei))) namei (atoi namei)) (initget 6) -------------------------------------------------- ;(setq n (getint "\nHow many more needed: ") ;;currently works within command line<<<<-------- Is it possible to use this in dialog box? ------------------------------------------------- (if (not AH:getvalsm)(load "Multi Getvals.lsp")) ;;BigAl's Dialog Box (if (= n nil)(setq n 100)) (setq n (atof (car (AH:getvalsm (list "Enter" "How Many More? " 5 4 (rtos n 2 0)))))) ---------------------------------------------------- i (+ 1 namei n)) (repeat n (setq nname (strcat namer (itoa (setq i (1- i))))) Its weird, the (setq n (getint), is used, and the dialog is commented out, it seems to run from the get go. Quote
Steven P Posted November 15, 2022 Posted November 15, 2022 So something runs when it is loaded.... suggests that there is a bracket in the wrong place somewhere endling the LISP early? Quote
BIGAL Posted November 15, 2022 Posted November 15, 2022 The value n is being returned correct, as mentioned earlier use atoi if want an integer, also change 5 4 to bigger numbers if need to enter a large number like 100000.123 use 12 11. If using getvals remove (initget 6) maybe that is the problem. Quote
Recommended Posts
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.