See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Retaining variable values for use after saving and closing

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

    Default Retaining variable values for use after saving and closing

    I've written a couple of routines for numbering terminals and wires in an electrical schematic circuit. How can I retain the values of variables for use again after the drawing has been saved and then re-opened. For example a variable numVal would have a value of 101 (the last wire number used). When I re-open the drawing I would like to retrieve that value and continue numbering.

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

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

    Your explanations are not clear enough at least to me . So more info is needed .

  3. #3
    Login to Give a bone
    0

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

    Timothy, don't know if you mean AutoCAD so I'm going to give it a shot ... I had to create a lisp routine since some of the variables reset every time I close and re-open. I call it Variables.lsp and in it I have the following:

    (setvar 'HPDRAWORDER 1)
    (setvar 'DYNMODE 3)
    (setvar 'FIELDEVAL 16)
    (setvar 'DXEVAL 0)
    (setvar 'OSMODE 63)

    Make sure to put it in your Startup Suite

  4. #4
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

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

    You could look into dictionary records to store your data to be reused for a per drawing variables. You could look into using the registry for a drawing independent variable.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

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

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

    AutoCAD 2014. The routines are written using Autolisp. In the code I create a variable called numVal. This variable is incremented after each pick point places a number in the drawing in a while loop...(setq numVal (+ numVal numInc))... The routine works very well in the drawing session. What I am trying to achieve is to retain the value of numVal so that it can be re-used the next time the drawing is opened. Currently, all variables are reset when the drawing is re-opened.

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

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

    It's user defined variables that I am trying to retain rather than system variables. I have a copy of "Inside Autolisp" (J. Smith and R. Gesner New Riders Publishing 1989 ). It refers to a routine called PVAR.lsp. It provides functions for creating personal variable system which can retain variable values in a drawings LTYPE table. So I'm playing with that at the moment. It should be noted that I am very new programming.

  7. #7
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

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

    Again, searching these forums for the methods previously mentioned will help you find the code samples you are looking to implement.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  8. #8
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

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

    Quote Originally Posted by Imkie View Post
    It's user defined variables that I am trying to retain rather than system variables. I have a copy of "Inside Autolisp" (J. Smith and R. Gesner New Riders Publishing 1989 ). It refers to a routine called PVAR.lsp. It provides functions for creating personal variable system which can retain variable values in a drawings LTYPE table. So I'm playing with that at the moment. It should be noted that I am very new programming.
    Firstly, I'd recommend that you read David Stein's The Visual LISP Developer's Bible:




    As for your plight, there are only a few ways to achieve what you're after, and you're going to have to decide which is best.

    It is unfortunate that you're using 2014 in lieu of 2015, and the latter introduces a simple means by which to add custom System Variables as shown here, with a working example here.

    As you cannot use this new functionality in 2014, you're relegated to storing either externally (i.e., external file, registry, etc.), or to internal database (i.e., NOD [named object dictionary], etc.). It sounds as though you're after the latter, so you may want to read up on the differences between Dictionaries and XRecords for saving data, let alone their LISP and Visual LISP counterparts.

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

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

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

    Thank you for the links and the book idea.

  10. #10
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

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

    Quote Originally Posted by Imkie View Post
    How can I retain the values of variables for use again after the drawing has been saved and then re-opened.
    Do you want to store the data in the DWG file or somewhere else such as the users local hard drive or a network drive?

    See also:
    http://www.eng-tips.com/faqs.cfm?fid=175
    http://www.cadtutor.net/forum/archiv...p/t-34829.html
    R.K. McSwain | CAD Panacea |

Page 1 of 2 12 LastLast

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
  •