Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Any way to assign a lisp variable both its name and its value from a string?

41 REPLIES 41
Reply
Message 1 of 42
NashGussetts
2319 Views, 41 Replies

Any way to assign a lisp variable both its name and its value from a string?

 

I.e. given a string "varname1:varval1,varname2:varval2" end up with the equivalent of calling this: (setq varname1 varval1 varname2 varval2) in a lisp routine

 

(I'm flexible as to exact structure of the string, characters used as connectors or spacers, etc.)

41 REPLIES 41
Message 41 of 42

Actually... Ldata creates an extension dictionary for an object/entity and adds your information .as a record to it. So, even with LData you are still working with dictionaries and xrecords just as Nash is doing (although with LData there is a built in "namespace" ability to help keep the data localized to your app).

XData is another matter entirely. So in the end Nash is doing exactly what you suggested Martti... using dictionaries instead of XData.

For myself I use LData put as a means (when using vlisp) to quickly create an extension dictionary, then delete the entry, then use dictadd to add my own sub-dictionary to the (sometimes newly created) Extension dictionary.

Then I add xdata to the object that I attached an extension dictionary to, along with the handle of the dictionary itself, so I can later use a filter in ssget calls to quickly find my "managed" objects and access the data that I stored within, but without the restrictions of xdata 😉

 

OH, and BTW: you can use attach and retrieve Xdata without ever touching the ActiveX interface using "old style" methods of defining an association list and adding that to the entity with entmod.

 

    (setq DictHandle (cdr (assoc 5 (entget DictEName))))
    (setq XData
    (list (list -3 (list AppName
           (cons 1000 "Extension Dictionary Attached")
           (cons 1005 DictHandle)
           )))
   )
    (if (= nil (entmod (append (entget EntOrObj) XData)))
      (Princ "\nError adding XData...")
      )

 

Gary J. Orr
(Your Friendly Neighborhood) CADD/BIM/VDC Applications Manager
http://www.linkedin.com/in/garyorr

aka (current and past user names):
Gary_J_Orr (GOMO Stuff 2008-Present); OrrG (Forum Studio 2005-2008); Gary J. Orr (LHB Inc 2002-2005); Orr, Gary J. (Gossen Livingston 1997-2002)
Message 42 of 42
NashGussetts
in reply to: Gary_J_Orr

Here's some functional demonstration code.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost