See the top rated post in this thread. Click here

Page 2 of 5 FirstFirst 12345 LastLast
Results 11 to 20 of 42

Thread: Custom Lisp Tracker

  1. #11
    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

    Lightbulb Re: Custom Lisp Tracker

    You don't need to completely rewrite it; though some changes are in order for what you want to do. See changes below in bold red (comments are in red):
    Code:
    (vlr-set-notification (vlr-lisp-reactor nil '((:vlr-lispwillstart .
    lispwillstart))) 'active-document-only)
    ;;added CommandName to list of local variables
    (defun lispWillStart (a b / file lis CommandName)
      (setq
          ;;Can these be made local variables?  Or are there other routines that
          ;;rely on these variables to be set by this one?
          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")
        ;;changed to unprotected symbol
        VERS   (getvar "acadver")
        LIN1  (strcat (car b) "          " LGN "          " DATE "          " VERS)
        ;;get just the name of the function - look for a space, then a right paren
        CommandName (substr (car b) 2 (1- (if (vl-string-search " " (car b))
                                           (vl-string-search " " (car b))
                                           (vl-string-search ")" (car b))
                                         )
                                       )
                    )
                        )
        ;;change name to all upper case
        CommandName (strcase CommandName)
      )
      ;;check to see if the file is available AND the command is on we are interested in
      (if (and
           (findfile "S:/LispLog/Lisp-Count.txt")
           ;;If a new function is to be used, make sure to use all upper case characters
           ;;when adding it to the list
           (member CommandName (list "EXP" "LYR" "PROBE" "LYRUP" "SPR"))
        )
        (progn
          (setq file (open "S:/LispLog/Lisp-Count.txt" "a"))
          ;;moved these two lines into the if statement - see comment below
          (write-line LIN1 file)
          (close file)
        )
      )
      ;;commented out these two lines, they should be within the same if
      ;;statement as the line that opens the file
      ;;(write-line LIN1 file)
      ;;(close file)
      ;;The rest of the function has been left alone; we don't know if there are other functions
      ;;that rely on the *LISPCOMMANDS* variable to be set.  So, we will not modify this
      ;;portion of the routine without further information.
      (if 
        (not *LISPCOMMANDS*)
        (setq *LISPCOMMANDS* '())
      )
      (setq lis (vl-string->list (car b)))
      (if (and (= (car lis) 40) (= (cadr lis) 67) (= (caddr lis) 58))
        (progn
          (if (not (member (car b) *LISPCOMMANDS*))
            (setq *LISPCOMMANDS* (cons (car b) *LISPCOMMANDS*))
          )
        (setq *LISPCOMMANDS* (acad_strlsort *LISPCOMMANDS*))
        )
      )
    )
    This is not fully tested, but it should get you pretty close. The bottom portion of the routine has not been modified because I do not know if (or how) *LISPCOMMANDS* is used after this routine has ran.

    HTH,

  2. #12
    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,

  3. #13
    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

  4. #14
    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,

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

    Default Re: Custom Lisp Tracker

    Have you run this code through, step-by-step? Most likely, the AutoLISP commands that you are using contain the "C:" prefix as shown in your original post. Your list does not include that prefix.

    Regarding the AutoCAD version, a simple CONDitional statement should suffice. I am not exactly sure how how you want the output to appear, but I have it as an external function, allowing you to edit the string as desired and reuse in other routines.

    Code:
    (defun lispWillStart (cmdData	    lstCallbacks  /
    		      dscFile	    strLogFile	  strCommandName
    		      lstCommands		  strDate
    		      strDay	    strDayText	  strLogin
    		      strMonth	    strOutput	  strTime
    		      strVersion    strYear
    		     )
      (setq	lstCommands '("C:EXP" "C:LYR" "C:PROBE" "C:LYRUP" "C:SPR")
    	strLogFile     "C:/Lisp-Count.csv"
    	strCommandName (strcase
    			 (substr
    			   (car lstCallbacks)
    			   2
    			   (1- (if (vl-string-search " " (car lstCallbacks))
    				 (vl-string-search " " (car lstCallbacks))
    				 (vl-string-search ")" (car lstCallbacks))
    			       )
    			   )
    
    			 )
    		       )
      )
      (if (and (member strCommandName lstCommands)
    	   (findfile strLogFile)
          )
        (progn
          (setq strVersion (getAcadVersion)
    	    strDayText (menucmd "M=$(edtime, $(getvar,date),DDDD)")
    	    strTime    (menucmd "M=$(edtime, $(getvar,date),hh:mm:ss)")
    	    strMonth   (menucmd "M=$(edtime, $(getvar,date),MOnth)")
    	    strDay     (menucmd "M=$(edtime, $(getvar,date),DD)")
    	    strYear    (menucmd "M=$(edtime, $(getvar,date),yyyy)")
    	    strDate    (strcat strDayText	   ", "	     strMonth
    			       " "	 strDay	   ", "	     strYear
    			       " "	 strTime
    			      )
    	    strLogin   (getvar "loginname")
    	    strOutput  (strcat "\"" (car lstCallbacks)
    			       "\"\t\""
    			       strLogin
    			       "\"\t\""
    			       strDate
    			       "\"\t\""
    			       strVersion
    			       "\""
    		       )
          )
          (setq dscFile (open strLogFile "a"))
          (write-line strOutput dscFile)
          (close dscFile)
        )
      )
    )
    Code:
    (defun getAcadVersion (/ sngVersion )
      (setq sngVersion (atof (getvar 'AcadVer)))
      (cond	((= sngVersion 16.0)
    	 "AutoCAD 2004"
    	)
    	((= sngVersion 16.1)
    	 "AutoCAD 2005"
    	)
    	((= sngVersion 16.2)
    	 "AutoCAD 2006"
    	)
    	((= sngVersion 17.0)
    	 "AutoCAD 2007"
    	)
    	((= sngVersion 17.1)
    	 "AutoCAD 2008"
    	)
    	((= sngVersion 17.2)
    	 "AutoCAD 2009"
    	)
    	((= sngVersion 18.0)
    	 "AutoCAD 2010"
    	)
      )
    )
    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

  6. #16
    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......lots of great info!

    I am going to chew on this for a little bit and then I will get back to you guys.

    Thanks for all the help thus far!

  7. #17
    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

    Morning Guys.....

    So I finally had some time this morning to try Opie's code and it works great! Thanks a bunch!!

    I do have one question though, check out the attached screen shot of the excel document. What's with the question marks in there? And how can I have the date, day and time all in the same column?
    Attached Images Attached Images

  8. #18
    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

    Never mind, I managed to figure it out.

    Thanks again!

  9. #19
    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

    Smile Re: Custom Lisp Tracker

    Quote Originally Posted by fletch97 View Post
    Morning Guys.....

    So I finally had some time this morning to try Opie's code and it works great! Thanks a bunch!!

    I do have one question though, check out the attached screen shot of the excel document. What's with the question marks in there? And how can I have the date, day and time all in the same column?
    The easiest way to get the data formatted the way you want (at least for me) is to format it correctly in Excel, then save it as a CSV file. Once this is done, open it up in Notepad. From here, you can see what changes you may need to make to your output to get the information you want.

    It appears as though Opie's code is using tabs to separate the data; however, it is being sent to a CSV file. The question marks would be the textual representation of the tab character. When Excel opens the file, it is expecting commas to separate the data instead of tabs. You can change all the tabs (\t) to commas.

    HTH,

  10. #20
    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

    That worked out thanks.......

    However, I am ripping my hair out right now! For some reason the lisp is no longer writing to the Excel doc!?!?! ughh...

    I even went back and started fresh by copying Opie's code and now it won't work at all. It's a complete mystery to me!

Page 2 of 5 FirstFirst 12345 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
  •