Costinbos77 Posted November 8, 2012 Posted November 8, 2012 Hello! How to store variables values in dwg, for use in other work sessions? You can store lists? Of course without using setq, userr, users or writing the registry. Costin Quote
Tharwat Posted November 8, 2012 Posted November 8, 2012 Read about these functions . vl-propagate vl-bb-ref vl-bb-[i]set[/i] Quote
Costinbos77 Posted November 8, 2012 Author Posted November 8, 2012 I do not want to transfer variables from one drawing to another, but at the same drawing from one day to another. I read somewhere that if you can store data in structure table of drawing. Costin Quote
Tharwat Posted November 8, 2012 Posted November 8, 2012 So you should use dictionary with Xrecord then . Quote
Costinbos77 Posted November 8, 2012 Author Posted November 8, 2012 Yes, something like that. How to do it? Quote
Costinbos77 Posted November 8, 2012 Author Posted November 8, 2012 Thank you. It is very helpful. Quote
Lee Mac Posted November 8, 2012 Posted November 8, 2012 On AfraLISP: http://www.afralisp.net/autolisp/tutorials/dictionaries-and-xrecords.php Quote
Costinbos77 Posted November 9, 2012 Author Posted November 9, 2012 (edited) A very good material. Thank you very much. I found some material in the book The Visual LISP Developers Bible 2003 Edition, by David M. Stein, Chapter 15 pages 103 - 106. Edited November 10, 2012 by Costinbos77 Quote
helmut51 Posted November 11, 2012 Posted November 11, 2012 Another possibility is saveData.lsp from Vladimir Nesterovsky -> http://vnestr.tripod.com/SaveData.lsp Quote
Costinbos77 Posted November 12, 2012 Author Posted November 12, 2012 A very good material. Be slightly revised, but it is just the thing. Thank you very much for your recommendation. Quote
BIGAL Posted November 13, 2012 Posted November 13, 2012 Another example may be usefull (defun get-or-create-Dict (/ adict) ;;test if "MyDict" is already present in the main dictionary (if (not (setq adict (dictsearch (namedobjdict) "MyDict"))) ;;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) "MyDict" 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 "MyDict" will be ;;created here in case it doesn't exist ((setq adict (get-or-create-Dict)) (cond ;;if "MyDict" is now valid then look for "MyDictVARS" Xrecord ((not (setq anXrec (dictsearch adict wallvar))) ;the variable MyDictvars is name of xrecord so need to be a variable to add lots ;;if "MyDictVARS" 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 getMyDictvars (/ vars varlist) ;;retrieve XRecord "wallvar" from dictionary "MyDict" ;;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
irneb Posted November 13, 2012 Posted November 13, 2012 Depends on what you want to save. There are basically 5 ways of saving data inside a DWG: Drawing Properties: http://www.cadtutor.net/forum/showthread.php?32034-Drawing-Properties XData XRecods inside dictionaries Lisp data: http://docs.autodesk.com/ACD/2011/ENU/filesALR/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-680c.htm (actually also uses a dictionary ... just already sorted out for you. I'm including it since it's used a bit differently from a normal dictionary) Sheet Sets (though not stricktly inside the DWg itself): http://www.cadtutor.net/forum/showthread.php?64749-Populate-Sheet-Set-Custom-Properties-by-gathering-attributes-from-a-block Each has its use, and you must decide which is preferable for your case. E.g. 1 is for the DWG as a whole and can be listed as a column inside Windows Explorer. 5 is per tab and can be edited in the Sheet Set Manager. As for 2 & 3 ... they can be attached to anything inside the DWG ... both have pro's and cons, e.g.: XData has a maximum size and can only handle certain data types, while Dictionaries have no size barier and can effectively handle any data. On the other hand XData has some "smart" types like linked Handles, and values which transform together with modification to the parent entity (e.g. code 1041 will be a real value number scaled together with the entity http://docs.autodesk.com/ACD/2011/ENU/filesALG/WS73099cc142f4875516d84be10ebc87a53f-7a06.htm) Quote
Costinbos77 Posted November 13, 2012 Author Posted November 13, 2012 Thanks for your answers. Such variable xx = represents the number last drawing numbered parcel (47). When I want to fill the drawing, look in the dictionary value of xx and leave it, resulting in 48, 49, and so on. Quote
BIGAL Posted November 14, 2012 Posted November 14, 2012 Check out Lee-mac's auto-renumbering if you remove 27 it will renumber all block objects also adds. Quote
irneb Posted November 14, 2012 Posted November 14, 2012 Yes, for what you're referring to I'm not sure it's necessary to store the data (and even then why not simply use one of the UserI# variables?) All you need to do is find the last number itself (the text / attribute), and if the parcels are numbered using an attributed block this is very easy to do with a selection set. It's basically what Lee's AutoLabelAttributes does ... simply does so through reactors checking for new block inserts, copying & erasing, then renumbering if such happens without needing extra user input. Alternatively my AutoIncrement routines allow for such ideas onto any text/attrib and allows to insert / remove / shift one from somewhere in the middle as well. It is also showing how to use LispData (vlax-ldata-* dictionaries) to link the individual items to each other - which IMO would be the simplest for you to use if you do want to roll your own data store. Quote
Costinbos77 Posted November 14, 2012 Author Posted November 14, 2012 Thanks for the replies. It's great with dictionaries, because if someone deletes the attribute that contains the value xx, stay eyes in the sun. users, userr use them for other variables . 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.