See the top rated post in this thread. Click here

Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Retaining variable values for use after saving and closing

  1. #11
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    2

    Default Re: Retaining variable values for use after saving and closing

    There is an undocumented feature (to my knowledge) that allows lisp programmers to attach ldata to a non-graphical object.

    Layer "0" object in the layers collection has the unusual ability to store ldata.

    So if you want to store values in a drawing and retrieve them when you come back...

    Merry Christmas

    P=

    Code:
    ;__________________________________________________________________________________________________________
    ;
    ; This Function stores variable values (strings, integers, reals, lists... not vla-objects or entitynames)
    ; Written By Peter Jamtgaard copyright 2014 all rights reserved
    ;_________________________________________________________________________________________________________
    ;
    ; Syntax: (VariableStore (list 'A 'B 'C)); Where A, B and C are variables you wish to store for example
    ;_________________________________________________________________________________________________________
    
    
    (defun VariableStore (lstOfSymbols / lstOfSublists)
     (and
      lstOfSymbols
      (setq lstOfSublists (mapcar '(lambda (X)(list X (eval (eval X)))) lstOfSymbols))
      (vlax-ldata-put (vla-item (vla-get-layers 
                                 (vla-get-activedocument 
                                  (vlax-get-acad-object))) "0") 
                      "Variables" 
                       lstOfSublists
      )
     )
    )
    
    ;_________________________________________________________________________________________________________
    ;
    ; Syntax (VariableReStore)
    ;_________________________________________________________________________________________________________
    
    (defun VariableReStore (/ lstOfSublists objLayerZero)
     (and
      (setq objLayerZero (vla-item
                          (vla-get-layers 
                           (vla-get-activedocument 
                            (vlax-get-acad-object))) "0")
      )
      (setq lstOfSublists (vlax-ldata-get objLayerZero "Variables" ))
      (mapcar '(lambda (X)(set (car X) (cadr X))) lstOfSublists) 
      ; (vlax-ldata-put objLayerZero "Variables" nil); <- Can delete ldata using this command if desired.
     )
    )
    
    (vl-load-com)
    Attached Files Attached Files
    AutomateCAD

  2. #12
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    2

    Default Re: Retaining variable values for use after saving and closing

    That is just brilliant!!

    Genius!

  3. #13
    Member
    Join Date
    2008-11
    Posts
    13
    Login to Give a bone
    0

    Default Re: Retaining variable values for use after saving and closing

    Brilliant!! Took me a while to get back to this thread so a BIG thank you. Now all i have to do is work out how to incorporate into my routine. At first I couldn't get the (VariableReStore) to run, but hey guess what Typos!!

    Thank you

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 3
    Last Post: 2015-07-15, 03:35 AM
  2. Help With Variable DB Increment Values
    By CADdancer in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2014-10-02, 12:33 PM
  3. Replies: 6
    Last Post: 2009-01-06, 04:08 PM
  4. Multiple Values in a single variable?
    By rmcelvain.103137 in forum Revit Structure - Families
    Replies: 0
    Last Post: 2007-02-02, 02:32 PM
  5. Scale a Derived Part With variable X,, Y & Z Values
    By inventor.wishlist1738 in forum Inventor Wish List
    Replies: 0
    Last Post: 2006-08-01, 03:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •