Retrieves LISP data from a drawing dictionary or an object
(vlax-ldata-get dict key [default-data [private]])
Note that a separate-namespace VLX can store both private and non-private data using the same dict and key. The private data can be accessed only by the same VLX, but any application can retrieve the non-private data.
Enter the following commands at the Visual LISP Console window:
(vlax-ldata-put "mydict" "mykey" "Mumbo Dumbo") "Mumbo Dumbo" (vlax-ldata-get "mydict" "mykey") "Mumbo Dumbo"
To test the use of private data from a VLX
- Enter the following commands at the Visual LISP Console window:
(vlax-ldata-put "mydict" "mykey" "Mumbo Dumbo") "Mumbo Dumbo" (vlax-ldata-get "mydict" "mykey") "Mumbo Dumbo"
- Enter the following code in a file and use Make Application to build a VLX from the file. Use the Expert mode of the Make Application wizard, and select the Separate Namespace option on the Compile Options tab.
(vl-doc-export 'ldataput) (vl-doc-export 'ldataget) (vl-doc-export 'ldataget-nilt) (defun ldataput () (princ "This is a test of putting private ldata ") (vlax-ldata-put "mydict" "mykey" "Mine! Mine! " T) ) (defun ldataget () (vlax-ldata-get "mydict" "mykey") ) (defun ldataget-nilt () (vlax-ldata-get "mydict" "mykey" nil T) )
- Load the VLX file.
- Run ldataput to save private data:
(ldataput) This is a test of putting private ldata
Refer to the code defining ldataput : this function stores a string containing “Mine! Mine!”
- Run ldataget to retrieve LISP data:
(ldataget) "Mumbo Dumbo"
Notice that the data returned by ldataget is not the data stored by ldataput . This is because ldataget does not specify the private argument in its call to vlax-ldata-get . So the data retrieved by ldataget is the data set by issuing vlax-ldata-put from the Visual LISP Console in step 1.
(ldataget-nilt) "Mine! Mine!"
- Run ldataget-nilt to retrieve LISP data:
(ldataget-nilt) "Mine! Mine!"
This time the private data saved by ldataput is returned, because ldataget-nilt specifies the private argument in its call to vlax-ldata-get .
- From the Visual LISP Console prompt, issue the same call that ldataget-nilt uses to retrieve private data:
(vlax-ldata-get "mydict" "mykey" nil T) "Mumbo Dumbo"
The private argument is ignored when vlax-ldata-get is issued outside a separate-namespace VLX. If non-private data exists for the specified dict and key (as in this instance), that data will be retrieved.