See the top rated post in this thread. Click here

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

Thread: Custom Lisp Tracker

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    I could stop if I wanted to
    Join Date
    2004-12
    Location
    California
    Posts
    283
    Login to Give a bone
    0

    Default Custom Lisp Tracker

    OK fellow Lisp'rs, I have another challenge.

    I came across this lisp routine years ago, not sure where it came from.....regardless, it helps track the usage of my custom lisp routines. I like to see how often all of my lisp routines are being used and who is using them. For the most part it works but could use some tweaking. This is where you guys come in.....

    - Right now it's picking up express tool commands as well as individual's custom commands they have locally. I need a way to tell the lisp routine to exclude those. Is there a way I can tell the lisp to only record my commands? If not, how about excluding commands. With 250+ people recording to one location, the txt file can be hassle to go through.

    - Acad version list the registry code rather than the version name. (i.e. 16.2s (LMS Tech)) Anyway to change that?

    - Anyway to send this info to an excel doc or even word doc rather than a txt file? Formatting is a bit of a mess in the txt file.

    Attached is the lisp file and below is a snip from the txt file it logs.....

    (C:FILLET) dcastillo Friday, September 11, 2009 14:34:53 17.1s (LMS Tech)
    (C:FILLET) jemiller Friday, September 11, 2009 14:35:29 16.2s (LMS Tech)
    (C:FILLET) jemiller Friday, September 11, 2009 14:35:31 16.2s (LMS Tech)
    (C:TE) mrodriguez Friday, September 11, 2009 14:36:35 17.1s (LMS Tech)
    Attached Files Attached Files

  2. #2
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: Custom Lisp Tracker

    If your routine names are the same as the filename (c:Yes = Yes.lsp) and you keep the ones you've written in a specific location, you could just have it check if (findfile (strcat "location" (substr 2 (car b)) ".lsp"))

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

    Default Re: Custom Lisp Tracker

    Do you have a list of the commands you wish to log the usage of? If not, you will need to create a list, then filter the commands before writing to the log file.
    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

  4. #4
    I could stop if I wanted to
    Join Date
    2004-12
    Location
    California
    Posts
    283
    Login to Give a bone
    0

    Default Re: Custom Lisp Tracker

    Alanjt - Most are the same lisp name/command name but not all.

    Opie - Here are the commands I want the lisp to track......
    From the command line - exp, lyr, probe, lyrup, spr

  5. #5
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    1

    Default Re: Custom Lisp Tracker

    Quote Originally Posted by fletch97 View Post
    Alanjt - Most are the same lisp name/command name but not all.

    Opie - Here are the commands I want the lisp to track......
    From the command line - exp, lyr, probe, lyrup, spr
    (if (member CommandName (list "exp" "lyr" "probe" "lyrup" "spr"))
    (do stuff

  6. #6
    I could stop if I wanted to
    Join Date
    2004-12
    Location
    California
    Posts
    283
    Login to Give a bone
    0

    Default Re: Custom Lisp Tracker

    Alanjt......that sounds easy enough but how to incorporate that into that attached count.lsp? I am assuming that (setq *LISPCOMMANDS* '()) needs to be taken out at this point since I am specifying?

  7. #7
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: Custom Lisp Tracker

    Quote Originally Posted by fletch97 View Post
    Alanjt......that sounds easy enough but how to incorporate that into that attached count.lsp? I am assuming that (setq *LISPCOMMANDS* '()) needs to be taken out at this point since I am specifying?
    If it's a member, write string to file. If not, do nothing.

  8. #8
    I could stop if I wanted to msretenovic's Avatar
    Join Date
    2002-02
    Location
    Galloway, Oh
    Posts
    305
    Login to Give a bone
    1

    Cool Re: Custom Lisp Tracker

    Just realized, neither of these two have been addressed yet.

    Quote Originally Posted by fletch97 View Post
    - Acad version list the registry code rather than the version name. (i.e. 16.2s (LMS Tech)) Anyway to change that?

    - Anyway to send this info to an excel doc or even word doc rather than a txt file? Formatting is a bit of a mess in the txt file.
    I assume you want the year version (i.e. 2008, 2009, etc.). If so, you can write something to give that to you.
    Code:
    15.0 = 2000
    15.1 = 2000i
    15.6 = 2002
    After version 15.x, they become more predictable.
    16.0 = 2004
    16.1 = 2005
    16.2 = 2006
    17.0 = 2007
    17.1 = 2008
    17.2 = 2009
    18.0 = 2010
    With this information, you can write something that takes the version (i.e. 17.2) as the input and outputs the year version (i.e. 2009). If you need help with this, just ask.

    As for the other question, you could separate all the information with a comma and save as a CSV file instead of a text file. This will enable you to open it in Excel. If you need to see an actual comma in the data, surround the data with quotes.

    HTH,

  9. #9
    I could stop if I wanted to
    Join Date
    2004-12
    Location
    California
    Posts
    283
    Login to Give a bone
    0

    Default Re: Custom Lisp Tracker

    Wow.....information overload!

    - OK...so let's tackle one thing here at a time. I took your lisp, and tried it but nothing actually got written to the txt file?


    Code:
    (vlr-set-notification (vlr-lisp-reactor nil '((:vlr-lispwillstart .
    lispwillstart))) 'active-document-only)
    
    (defun lispWillStart (a b / file lis CommandName)
      (setq
          V1    (menucmd "M=$(edtime, $(getvar,date),DDDD)")
          TM    (menucmd "M=$(edtime, $(getvar,date),hh:mm:ss)")
          MO    (menucmd "M=$(edtime, $(getvar,date),MOnth)")
          DAY   (menucmd "M=$(edtime, $(getvar,date),DD)")
          YR    (menucmd "M=$(edtime, $(getvar,date),yyyy)")
          DATE  (strcat V1 ", " MO " " DAY ", " YR " " TM)
          LGN   (getvar "loginname")
          VERS  (getvar "acadver")
          LIN1  (strcat (car b) "          " LGN "          " DATE "          " VERS)
    
          CommandName (substr (car b) 2 (1- (if (vl-string-search " " (car b))
                                            (vl-string-search " " (car b))
                                            (vl-string-search ")" (car b))
                                            )
                                        )
    
                      )
        CommandName (strcase CommandName)
      )
      (if (and
           (findfile "C:/Lisp-Count.txt")
           (member CommandName (list "EXP" "LYR" "PROBE" "LYRUP" "SPR"))
          )
        (progn
          (setq file (open "C:/Lisp-Count.txt" "a"))
          (write-line LIN1 file)
          (close file)
        )
      )
    )

    - The *Lispcommands* aren't used anywhere else in the lisp, so I removed them.

    - Not sure what you were asking here?........
    ;;Can these be made local variables? Or are there other routines that
    ;;rely on these variables to be set by this one?

    - Regarding the code for the versions, not sure how to get those to read better in the txt file. Can you offer additional help on this?
    15.0 = 2000
    15.1 = 2000i
    15.6 = 2002
    After version 15.x, they become more predictable.
    16.0 = 2004
    16.1 = 2005
    16.2 = 2006
    17.0 = 2007
    17.1 = 2008
    17.2 = 2009
    18.0 = 2010

    - Last question........When creating a post here in Augi, how do you break out the code into it's on box?

    Moderator's Note:

    By using [code] [/code] tags


    OK.....so the big issue right now is that it's not even logging the lisps to the txt file when I use them in a session of CAD. We can build from there.......thanks a bunch for the help!!
    Last edited by Opie; 2009-09-23 at 01:23 AM. Reason: [code] tags added and Moderator note

  10. #10
    I could stop if I wanted to msretenovic's Avatar
    Join Date
    2002-02
    Location
    Galloway, Oh
    Posts
    305
    Login to Give a bone
    0

    Question Re: Custom Lisp Tracker

    The first question I have for you is this: Are you using the VLIDE or Notepad? If you are using the VLIDE, have you stepped thorugh your code? If not, put a breakpoint (you can use the F9 key to place a breakpoint) here (at the bold red left paren):
    Code:
    (if (and
          (findfile "C:/Lisp-Count.txt")
          (member CommandName (list "EXP" "LYR" "PROBE" "LYRUP" "SPR"))
        )
    When you run your code, it should stop here. At this point, bring up the Watch window (Ctrl+Shift+W or View->Watch Window). Put the CommandName variable in the Watch window to see its value. Is it what you expect? What should it be and what is the actual value?

    This is just to help you in debugging. But, I do have an idea as to why nothing is being logged. Here is a hint, and I am hoping the debugging info above along with this can help you figure it out. Ok, here is the hint:
    How are your LISP routines defined?
    Code:
    (defun c:exp
    or 
    (defun exp
    Keep in mind, when the routine is pulling the name of the LISP function out of the callback information, it is stripping only the left paren off and nothing else.

    Also, notice in the location of where the information is being logged. When I was looking at it before, I changed it to C:\ and forgot to change it back to where you were using it before (my bad). So, as you are testing it, you may not find the log where you expect it (sorry about that).

    Now, for your other questions:
    - Not sure what you were asking here?........
    ;;Can these be made local variables? Or are there other routines that
    ;;rely on these variables to be set by this one?
    Code:
    V1
    TM
    MO
    DAY
    YR
    DATE
    LGN
    VERS
    LIN1
    These variables are used in your code. They have not been localized. Is this because they are used by other routines? Or can they be localized similar to the CommandName variable?

    And for your last question:
    - Regarding the code for the versions, not sure how to get those to read better in the txt file. Can you offer additional help on this?
    The list I gave you is the AutoCAD versions along with their 'year' versions. I still assume this is what you are after and there are several ways to select the correct version. One method is to do something similar to this:
    Code:
      (setq strVersion (substr (getvar "AcadVer") 1 4)
            intMajor   (atoi (substr strVersion 1 2))
            intMinor   (atoi (substr strVersion 4 1))
      )
    
      (setq strVersion (cond
                         ((= intMajor 15)
                           (cond
                             ((= intMinor 0) "2000")
                             ((= intMinor 1) "2000i")
                             ((= intMinor 6) "2002")
                           )
                         )
                         ((= intMajor 16)(itoa (+ 2004 intMinor)))
                         ((= intMajor 17)(itoa (+ 2007 intMinor)))
                         ((= intMajor 18)(itoa (+ 2010 intMinor)))
                         (t nil)
                       )
      )
    You will notice that this code returns a string instead of an integer. This is because of version 15.1, which was released as 2000i. Though, if you assume that this code will never run on a version less that 16.0, an integer can be returned instead.

    This code also assumes (based on recent history) that version 18.1 will be AutoCAD 2011, 18.2 will be AutoCAD 2012 and so on. Please modify as needed.

    This may seem a bit much, but take your time and ask any questions you may have.
    HTH,

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 2015-08-07, 03:58 PM
  2. Custom LISP Routine please!
    By Crask422 in forum AutoLISP
    Replies: 1
    Last Post: 2015-02-08, 06:24 PM
  3. Get SSM Custom Property Via LISP
    By BlackBox in forum AutoLISP
    Replies: 3
    Last Post: 2010-07-20, 08:30 PM
  4. Custom Fypon lisp
    By BCrouse in forum AutoLISP
    Replies: 3
    Last Post: 2005-08-08, 07:07 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
  •