A question that I haven't been able to find is how I can tie a key from a custom dictionary to display in a field?
I know that I can dump the custom dictionary into globals and the fields can track those values, but instead of strangling my available memory I'd rather track the dictionary key directly.
How can I utilize the Entity name or the actual dictionary name & key?
Thank you in advance for any help/suggestions you may be able to offer.
Solved! Go to Solution.
Solved by Lee_Mac. Go to Solution.
Haven't tried it, since fields are built to be tied to entities or LISP values I suspect any implementation would be unreliable. Usually any data being linked would be a value rather than a key.
LISP variables aren't *that* expensive to memory, unless you have hordes of them. In that case you are probably better off setting up data links to a database, and manipulating the database contents.
Maybe I cannot answer your full question, but i use dictionary funtion like this:
Create my own dictionary "GFM_3DSPRO", if it doesn't exist.
(if (not (dictsearch (namedobjdict) "GFM_3DSPRO")) (progn (dictadd (namedobjdict) "GFM_3DSPRO" (entmakex (list '(0 . "DICTIONARY") '(100 . "AcDbDictionary")))) );endprogn );endif
Store data.
(vlax-ldata-put "GFM_3DSPRO" "myname" "Franz Kefer") (vlax-ldata-put "GFM_3DSPRO" "age" 47)
Read data.
(vlax-ldata-get "GFM_3DSPRO" "myname") (vlax-ldata-get "GFM_3DSPRO" "age")
read the full dictionary list, e.g. to see all stored variables.
(entget (cdr (car (cdr (member '(3 . "GFM_3DSPRO") (entget (namedobjdict)))))))
Remove dictionary from drawing.
(dictremove (namedobjdict) "GFM_3DSPRO")
Although not formally documented and not available through the standard AutoCAD Field command, an AutoCAD Field Expression can in fact reference almost any ActiveX property of almost any VLA-Object.
Therefore, it is indeed possible to reference a key from a custom dictionary using a Field Expression, as the following example demonstrates:
;; An example demonstrating how to create an AutoCAD Field Expression ;; referencing a custom dictionary entry - Lee Mac 2013-10-10 (defun c:dictfield ( / dic ins nod xrc ) (setq nod (namedobjdict)) (if (null (setq dic (cdr (assoc -1 (dictsearch nod "MyCustomDictionary"))))) (setq dic (dictadd nod "MyCustomDictionary" (entmakex '( (000 . "DICTIONARY") (100 . "AcDbDictionary") ) ) ) ) ) (if dic (progn (if (null (setq xrc (cdr (assoc -1 (dictsearch dic "MyCustomData"))))) (setq xrc (dictadd dic "MyCustomData" (entmakex '( (000 . "XRECORD") (100 . "AcDbXrecord") (001 . "My Data") ) ) ) ) ) (if xrc (if (setq ins (getpoint "\nSpecify point for Field: ")) (vlax-invoke (vlax-get-property (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace ) ) 'addmtext (trans ins 1 0) 0.0 (strcat "%<\\AcObjProp Object(%<\\_ObjId " (LM:objectid (vlax-ename->vla-object xrc)) ">%).Name>%" ) ) ) (princ "\nUnable to create xrecord: \"MyCustomData\".") ) ) (princ "\nUnable to create dictionary: \"MyCustomDictionary\".") ) (princ) ) ;; ObjectID - Lee Mac ;; Returns a string containing the ObjectID of a supplied VLA-Object ;; Compatible with 32-bit & 64-bit systems (defun LM:ObjectID ( obj ) (eval (list 'defun 'LM:ObjectID '( obj ) (if (and (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE")) (vlax-method-applicable-p (vla-get-utility (LM:acdoc)) 'getobjectidstring) ) (list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false) '(itoa (vla-get-objectid obj)) ) ) ) (LM:ObjectID obj) ) ;; Active Document - Lee Mac ;; Returns the VLA Active Document Object (defun LM:acdoc nil (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object)))) (LM:acdoc) ) (vl-load-com) (princ)
@mid-awe wrote:
Lee Mac - LISP NINJA Extraordinaire 🙂
@mid-awe wrote:
I had given up on this approach. You are constantly changing my mind about Visual LISP limitations.
Thank you very much Lee.
Although nowhere near as powerful as .NET, where customisation of existing functionality is concerned, there really isn't too much that Visual LISP & Vanilla AutoLISP cannot achieve (of course, that's coming from a LISP advocate )
As always, you're most welcome mid-awe, happy to help.
@mid-awe
I am happy if i could help you a little bit. The main reason for use dictionary is simple. It is the best way for me to store process data in a drawing.
I use ACAD, especially 3D-functions for a radial forging simulation with 4 or more forging dies. During simulation, actual progress data are stored in my dictionary object and the dwg-file on harddisc.
If ACAD crashed, I reload the last saved drawing und start my programm again. If my dictionary is present and contain data, the programm read it and continue simulation process on correct position without any user intervention. (save a lot of time for complex simulations)
Take a look to added images, one before start, and one after finish of simulation.
@Lee Mac
Thanks for the demonstration of the possibility of professional software eingineereing ... my head is smoking
with kind regards
Franz
Franz,
Thank you for the explaination. I obviously use the dictionary for different reasons and I'm still testing the waters with new ideas (new to me and the company that employs me at this time). I've dabbled often over the years and am only now really stretching my imagination for applications of this great asset.
As for 3D, I do all my 3D work with Blender 2.68. Not only because it's awesome and free, but also because the Python API is fast & flexible. Plus, AutoCAD can't touch the incredible Modifiers, Modeling tools, Cycles rendering, Bullet Physics, Particles, Simulators, etc., etc... Interactive 3D Visualiztion at my fingertips. It literally takes less than 30min to drop a camera in a scene, add some logic (with a template appended it's even faster), and presto - nearly instant walkthrough with high quality realtime rendering. And; if I choose, I can save an excutable of my project and give it to the client to run on their own machine with no concern for royalties or other BS.