See the top rated post in this thread. Click here

Results 1 to 9 of 9

Thread: External counter

  1. #1
    I could stop if I wanted to
    Join Date
    2009-04
    Location
    Houston, TX
    Posts
    204
    Login to Give a bone
    0

    Default External counter

    I recently wrote a routine with a dialog box etc., and in order to save the user from having to input the same information if they wanted to run it on "X" number of drawings, it writes all the input out to a txt file if the number of drawings entered is more than 1. It also writes out the result of counter "Y" each time the routine is run and reads it back each time the routine is run until counter "Y" equals the # of drawings initially entered by user, which is stored as count "Z", then both txt files are deleted.

    I'm just wondering if there's some way to store counter "Y" within the routine vs. sending it to a txt file? I haven't explored combining any of this through a script etc to have it run based on a selection of drawings. I was hoping to use an existing batch routine to run it, but that hasn't worked out very well (so far).

    From everything I know, each drawing session is totally isolated and there is no remembering variables between them.

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

    Default Re: External counter

    Quote Originally Posted by M. Kubitza View Post
    I'm just wondering if there's some way to store counter "Y" within the routine vs. sending it to a txt file?
    Hi,
    You can save them as strings then anytime a user calls the program, the dialog appears then you need to add these strings into the column XXX which is maybe a listbox tile I believe.

    Is this what you are after?

    If so, then where is the codes to add the strings into your ListBox tile or even popup_list tile.
    Code:
    (setq strings '("a" "b" "c" "d"))
    (start_list <ListBox_key> ) (mapcar 'add_list strings) (end_list)

  3. #3
    I could stop if I wanted to
    Join Date
    2009-04
    Location
    Houston, TX
    Posts
    204
    Login to Give a bone
    0

    Default Re: External counter

    I am familiar with populating lists and such. This however would need to count for and update itself each time a drawing was processed, which is where I'm left wondering if is possible without exporting the current number out to a txt file and reading it each time the routine runs.

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

    Default Re: External counter

    Can you give an example with images or so to make your idea clear enough to read?

  5. #5
    I could stop if I wanted to
    Join Date
    2009-04
    Location
    Houston, TX
    Posts
    204
    Login to Give a bone
    0

    Default Re: External counter

    Quote Originally Posted by Tharwat View Post
    Can you give an example with images or so to make your idea clear enough to read?
    Example.jpg

    The number circled in red needs to increment by +1 until it hits 7, and the batch is done. I can't think of a way to store this as some variable internally as it seems with each drawing session all is lost, so I have it set to read and update the value via txt file.

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

    Default Re: External counter

    You can use the functions setenv & getenv as demonstrated below instead of exporting and importing one value to txt file which is not that required with this simple task.

    Code:
    (setenv "ExternalCounter" "7")
    (getenv "ExternalCounter")

  7. #7
    AUGI Addict
    Join Date
    2015-12
    Posts
    2,095
    Login to Give a bone
    1

    Default Re: External counter

    Quote Originally Posted by M. Kubitza View Post
    Example.jpg

    The number circled in red needs to increment by +1 until it hits 7, and the batch is done. I can't think of a way to store this as some variable internally as it seems with each drawing session all is lost, so I have it set to read and update the value via txt file.
    LISP is per-document, not per-session. You can try using the blackboard functions which allow for variables to be referenced across multiple documents. That can be a little tricky as well, since it's popular to work across multiple documents in a open program => open document => run => close program sequence when scripting or using the core console. You really don't have much choice other than using the registry or an external file to keep track of values in that case.

  8. #8
    I could stop if I wanted to
    Join Date
    2009-04
    Location
    Houston, TX
    Posts
    204
    Login to Give a bone
    0

    Default Re: External counter

    Quote Originally Posted by Tharwat View Post
    You can use the functions setenv & getenv as demonstrated below instead of exporting and importing one value to txt file which is not that required with this simple task.

    Code:
    (setenv "ExternalCounter" "7")
    (getenv "ExternalCounter")
    Didn't even think about exploring environment vars. This worked perfectly, I can probably apply this to a number of things. Thanks so much!

    - - - Updated - - -

    Quote Originally Posted by dgorsman View Post
    LISP is per-document, not per-session. You can try using the blackboard functions which allow for variables to be referenced across multiple documents. That can be a little tricky as well, since it's popular to work across multiple documents in a open program => open document => run => close program sequence when scripting or using the core console. You really don't have much choice other than using the registry or an external file to keep track of values in that case.
    My mistake... incorrect terminology, per drawing is what I meant yes. Never heard of these blackboard functions... I don't get into lisp etc. very often. Might you have a link which goes into detail about this? I'll google in the meantime.

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

    Default Re: External counter

    Quote Originally Posted by M. Kubitza View Post
    Didn't even think about exploring environment vars. This worked perfectly, I can probably apply this to a number of things. Thanks so much!
    Great. You are welcome anytime.

Similar Threads

  1. counter....visibility
    By ntnik in forum Revit Architecture - General
    Replies: 2
    Last Post: 2008-04-16, 06:59 PM
  2. Block Counter
    By cadd4la in forum VBA/COM Interop
    Replies: 24
    Last Post: 2006-04-14, 12:05 AM
  3. Counter Top Material
    By max in forum Revit - Rendering
    Replies: 4
    Last Post: 2006-02-27, 11:14 PM
  4. Looking for Block Counter
    By cadd4la in forum AutoLISP
    Replies: 31
    Last Post: 2005-08-18, 07:08 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
  •