wimal Posted February 22, 2013 Posted February 22, 2013 (setq scale (getint " Enter the scale:")) How can I feed a default scale. And after feeding a new value can I auto load it next time Quote
MSasu Posted February 22, 2013 Posted February 22, 2013 This subject was discussed few times before, please check those: http://www.cadtutor.net/forum/showthread.php?54797 http://www.cadtutor.net/forum/showthread.php?64520 http://www.cadtutor.net/forum/showthread.php?55644 Quote
togores Posted February 22, 2013 Posted February 22, 2013 And after feeding a new value can I auto load it next time Do you mean that you require that the value you entered will be remembered the next time you open the drawing? In this case you have different options: Using the USER variables: USERI1 to USERI5 for Integer values, USERR1 to USERR5 for real numbers, USERS1 to USERS5 for text strings. Other alternative would be to use a custom dictionary to store these variables. This would be safer for an application that would be distributed to different users. It can be a regular XRECORD DICTIONARY or an LDATA dictionary. If this scale value could be linked to some drawing object, for example a title block, you could try XDATA or even a block attribute. Quote
dbroada Posted February 22, 2013 Posted February 22, 2013 Using the USER variables: USERI1 to USERI5 for Integer values, USERR1 to USERR5 for real numbers, USERS1 to USERS5 for text strings. although the USERS* will not be recalled. They are not saved on exiting the drawing. Quote
togores Posted February 22, 2013 Posted February 22, 2013 although the USERS* will not be recalled. They are not saved on exiting the drawing. Sorry, you're right, if strings we would have to use the other alternatives. LDATA are very easy to use. Quote
Bill Tillman Posted February 22, 2013 Posted February 22, 2013 At the risk of sounding like an idiot because I didn't read all the links in MSasu's reply...text files are always a favorite method of mine for storing information which may be needed later. The LISP file can read in as much or as little data as you need. Quote
MSasu Posted February 22, 2013 Posted February 22, 2013 It will be interesting to get clarification from OP what he/she understood by "auto load it next time". Is about the next call of the routine in current drawing or in another one? Quote
BIGAL Posted February 22, 2013 Posted February 22, 2013 Using a xdata dictionary is pretty easy but it saves in the dwg you can also save to the local pc in a registry value and retrieve it. If its got to be sharable by multiple users then a txt file is probably the way to go save dwg name + value, a simple defun reads through the lines saved and retrieves the value. (if (= vert nil) (progn (setq vert 50) (prompt "\nEnter Vertical scale:<") (prin1 vert) (prompt ">:") (setq newvert (getint)) (if (= newvert nil) (setq vert vert) (setq vert newvert) ) ) ) (defun get-or-create-Dict (/ adict) ;;test if "BIG-ALS" is already present in the main dictionary (if (not (setq adict (dictsearch (namedobjdict) "BIG-ALS"))) ;;if not present then create a new one and set the main ;; dictionary as owner (progn (setq adict (entmakex '((0 . "DICTIONARY")(100 . "AcDbDictionary")))) ;;if succesfully created, add it to the main dictionary (if adict (setq adict (dictadd (namedobjdict) "BIG-ALS" adict))) ) ;;if present then just return its entity name (setq adict (cdr (assoc -1 adict))) ) ) (defun get-or-make-Xrecord (/ adict anXrec) ; change to allow w1 etc and thickness (cond ;;first get our dictionary. Notice that "BIG-ALS" will be ;;created here in case it doesn't exist ((setq adict (get-or-create-Dict)) (cond ;;if "BIG-ALS" is now valid then look for "BIG-ALSVARS" Xrecord ((not (setq anXrec (dictsearch adict wallvar))) ;the variable BIG-ALSvars is name of xrecord so need to be a variable to add lots ;;if "BIG-ALSVARS" was not found then create it ;(setq anXrec (entmakex '((0 . "XRECORD") (setq anXrec (entmakex (list (cons 0 "XRECORD") (cons 100 "AcDbXrecord") ;(1 . wallvar) (cons 1 wallvar) (cons 40 wallsize) ;(40 . wallsize) ) ) ) ;;if creation succeeded then add it to our dictionary (if anXrec (setq anXrec (dictadd adict wallvar anXrec))) ) ;;if it's already present then just return its entity name (setq anXrec (cdr (assoc -1 (dictsearch adict wallvar))) ) ) ) ) ) (defun getBIG-ALSvars (/ vars varlist) ;;retrieve XRecord "wallvar" from dictionary "BIG-ALS" ;;which in turn calls both functions above (setq vars (get-or-make-Xrecord)) ;;if our Xrecord is found, then get values in group code (cond (vars (setq varlist (entget vars)) (setq WALLname (cdr (assoc 1 varlist))) (setq WALLTHICK (cdr (assoc 40 varlist))) ) ;;otherwise return nil (T nil) ) ) 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.