+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 28
  1. #11
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,418

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Bluebird1973 View Post
    is there a way to not pank my draftsman the whole day?
    ... 3 or 4 times would be enough ...
    Something like this perhaps:
    Code:
    (   (lambda ( lst / age itm ord ret tmp )
            (defun ord ( n ) (cond ((< 10 (rem n 100) 14) "th") ((nth (rem n 10) '(nil "st" "nd" "rd"))) ("th")))
            (cond
                (   (null (setq itm (assoc (strcase (getvar 'loginname)) lst)))
                    (princ "\nSorry, user not listed!")
                )
                (   (and (zerop (rem (setq age (- (fix (getvar 'cdate)) (caddr itm))) 10000))
                         (or (null (setq tmp (getenv "CurrentAge")))
                             (/= age (atoi tmp))
                         )
                    )
                    (setenv "CurrentAge" (itoa age))
                    (setq age (/ age 10000)
                          ret (- (cadddr itm) age)
                    )
                    (alert
                        (strcat 
                            "Hello " (cadr itm) "!"
                            "\n\nHerzlichen Glückwunsch zum " (itoa age) ". Geburtstag !!!"
                            "\n\nCongratulations on your " (itoa age) (ord age) " Birthday !!!"
                            "\n\n\n\nVon jetzt an, sind es nur noch " (itoa ret) " Jahre bis zur Rente \n... Also hau rein ... :-)"
                            "\n\nFrom now on, there are only " (itoa ret) " years left to retirement \n... so get in there ... :-)"
                            "\n\n\nKeyuser Michael"
                        )
                    )
                )
            )
            (princ)
        )
       '(
            ("MH019" "Michael" 19991003 67)
            ("MH019" "Michael" 20180109 67)
            ("MH019" "Michael" 20180110 67)
        )
    )
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  2. #12
    Full Member
    Using
    Architecture 2016
    Join Date
    Nov 2014
    Posts
    32

    Default

    Great !!!

    ... but I would like to prank a little bit...
    is it possible to add a counter which I could set to show up 3-4 times?

  3. #13
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,224

    Default

    Quote Originally Posted by Grrr View Post
    This made me wonder, why not write some generic function that uses one of the arguments:
    '(day week month year)
    Code:
    ; (RunOnceA 'day (lambda nil (alert "Hello world!")))
    (defun RunOnceA ( sym func / env dateL tmp new old aL )
      
      (defun SubstrByN ( n str ) (if (and (eq 'INT (type n)) (> n 0) (/= "" str)) (cons (substr str 1 n) (SubstrByN n (substr str (1+ n))))) )
      
      (setq env "RunOnceA")
      (setq dateL
        (lambda nil
          (mapcar 'cons '(year month day)
            (apply '(lambda (a b c d) (list (strcat a b) c d))
              (SubstrByN 2 (vl-prin1-to-string (fix (getvar 'cdate))))
            )
          )
        )
      )
      (and ; first time using 'RunOnceA' function
        (or (= (setq tmp (getenv env)) "") (not tmp) )
        (progn
          (setenv env (vl-prin1-to-string (dateL)))
          (func)
        ); progn
      ); and
      
      (if (member sym '(day month year)) ; check if valid symbol is provided, to avoid redundant prompts
        (if
          (not 
            (equal
              (setq new (assoc sym (dateL)))
              (setq old (assoc sym (setq aL (read (getenv env)))))
            )
          )
          (progn (setenv env (vl-prin1-to-string (subst new old aL))) (func) ) ; first store the current date, incase (func) crashes
          (prompt (strcat "\nRunOnceA: will evaluate the next " (strcase (vl-prin1-to-string sym) t) "."))
        ); if
        (prompt "\nRunOnceA: invalid symbol provided, use [day/month/year].")
      ); if
      
    ); defun RunOnceA

  4. #14
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    686

    Default

    Quote Originally Posted by Grrr View Post
    Code:
    ; (RunOnceA 'day (lambda nil (alert "Hello world!")))
    (defun RunOnceA ( sym func / env dateL tmp new old aL )
      
      (defun SubstrByN ( n str ) (if (and (eq 'INT (type n)) (> n 0) (/= "" str)) (cons (substr str 1 n) (SubstrByN n (substr str (1+ n))))) )
      
      (setq env "RunOnceA")
      (setq dateL
        (lambda nil
          (mapcar 'cons '(year month day)
            (apply '(lambda (a b c d) (list (strcat a b) c d))
              (SubstrByN 2 (vl-prin1-to-string (fix (getvar 'cdate))))
            )
          )
        )
      )
      (and ; first time using 'RunOnceA' function
        (or (= (setq tmp (getenv env)) "") (not tmp) )
        (progn
          (setenv env (vl-prin1-to-string (dateL)))
          (func)
        ); progn
      ); and
      
      (if (member sym '(day month year)) ; check if valid symbol is provided, to avoid redundant prompts
        (if
          (not 
            (equal
              (setq new (assoc sym (dateL)))
              (setq old (assoc sym (setq aL (read (getenv env)))))
            )
          )
          (progn (setenv env (vl-prin1-to-string (subst new old aL))) (func) ) ; first store the current date, incase (func) crashes
          (prompt (strcat "\nRunOnceA: will evaluate the next " (strcase (vl-prin1-to-string sym) t) "."))
        ); if
        (prompt "\nRunOnceA: invalid symbol provided, use [day/month/year].")
      ); if
      
    ); defun RunOnceA
    Nicely coded

    Gr. Rlx

  5. #15
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,224

    Default

    Quote Originally Posted by rlx View Post
    Nicely coded

    Gr. Rlx
    Thanks!
    I hope it works as supposed - didn't found any problems in my initial testing.

  6. #16
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,418

    Default

    Quote Originally Posted by Bluebird1973 View Post
    Great !!!

    ... but I would like to prank a little bit...
    is it possible to add a counter which I could set to show up 3-4 times?
    The following will 'prank' the user between 1 and 5 times if they 'roll a 3' when opening a drawing :
    Code:
    ;; Rand  -  Lee Mac
    ;; PRNG implementing a linear congruential generator with
    ;; parameters derived from the book 'Numerical Recipes'
    
    (defun LM:rand ( / a c m )
        (setq m   4294967296.0
              a   1664525.0
              c   1013904223.0
              $xn (rem (+ c (* a (cond ($xn) ((getvar 'date))))) m)
        )
        (/ $xn m)
    )
    
    ;; Random in Range  -  Lee Mac
    ;; Returns a pseudo-random integral number in a given range (inclusive)
    
    (defun LM:randrange ( a b )
        (+ (min a b) (fix (* (LM:rand) (1+ (abs (- a b))))))
    )
    
    (   (lambda ( lst / age itm ord ret tmp )
            (defun ord ( n ) (cond ((< 10 (rem n 100) 14) "th") ((nth (rem n 10) '(nil "st" "nd" "rd"))) ("th")))
            (cond
                (   (null (setq itm (assoc (strcase (getvar 'loginname)) lst)))
                    (princ "\nSorry, user not listed!")
                )
                (   (and (zerop (rem (setq age (- (fix (getvar 'cdate)) (caddr itm))) 10000))
                         (= 3 (LM:randrange 1 6)) ;; Adding some randomness to when the message is displayed
                         (cond
                             (   (or (null (setq tmp (getenv "CurrentAge"))) (< (atoi tmp) age))
                                 (setenv "CurrentAge" (itoa (+ age (LM:randrange 1 5))))
                             )
                             (   (< age (atoi tmp))
                                 (setenv "CurrentAge" (itoa (1- (atoi tmp))))
                             )
                         )
                    )
                    (setq age (/ age 10000)
                          ret (- (cadddr itm) age)
                    )
                    (alert
                        (strcat 
                            "Hello " (cadr itm) "!"
                            "\n\nHerzlichen Glückwunsch zum " (itoa age) ". Geburtstag !!!"
                            "\n\nCongratulations on your " (itoa age) (ord age) " Birthday !!!"
                            "\n\n\n\nVon jetzt an, sind es nur noch " (itoa ret) " Jahre bis zur Rente \n... Also hau rein ... :-)"
                            "\n\nFrom now on, there are only " (itoa ret) " years left to retirement \n... so get in there ... :-)"
                            "\n\n\nKeyuser Michael"
                        )
                    )
                )
            )
            (princ)
        )
       '(
            ("MH019" "Michael" 19991003 67)
            ("MH019" "Michael" 20180109 67)
            ("MH019" "Michael" 20180110 67)
        )
    )
    
    (princ)
    Last edited by Lee Mac; 13th Jan 2018 at 07:31 pm.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  7. #17
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    686

    Default

    Well thank you Lee
    Attached Images

  8. #18
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,224

    Default

    Just imagine Lee's code triggering some Sapi voices randomly!

  9. #19
    Super Member rlx's Avatar
    Computer Details
    rlx's Computer Details
    Operating System:
    W10
    Computer:
    i74ghz/ssd500/2tbhdd
    Discipline
    Electrical
    rlx's Discipline Details
    Occupation
    electrical designer dragon
    Discipline
    Electrical
    Details
    I dont excel in anything but I rearly give up
    Using
    AutoCAD 2016
    Join Date
    Nov 2014
    Location
    Bergen op Zoom , Netherlands
    Posts
    686

    Default

    Quote Originally Posted by Grrr View Post
    Just imagine Lee's code triggering some Sapi voices randomly!

    Most people here have muted their pc but the colleague right in front of me hasn't ... he would make a good candidate. In fact , I have 'pranked' him in the past. He likes to kill rabbits in his spare time so one day I arranged for a slide to appear with each drawing he opened with a armed rabbit showing

  10. #20
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,224

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by rlx View Post
    Most people here have muted their pc but the colleague right in front of me hasn't ... he would make a good candidate. In fact , I have 'pranked' him in the past. He likes to kill rabbits in his spare time so one day I arranged for a slide to appear with each drawing he opened with a armed rabbit showing
    That sounds like a good practice,
    I was imaginig more like a windows XP loading sound upon running autocad (annoying nostalgia).

Similar Threads

  1. iPhone Photo Prank this Week
    By Between the Lines in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 16th Jan 2015, 09:30 pm

Bookmarks

Posting Permissions

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