Author Topic: How would you handle this: Timer function?  (Read 13065 times)

0 Members and 1 Guest are viewing this topic.

nivuahc

  • Guest
Re: How would you handle this: Timer function?
« Reply #30 on: September 14, 2006, 02:02:58 PM »
have been out of this thread, and no idea the status....

have anyone had think to provide a function, with the same ability as the command 3dOrbit?

How are the presentations are going to be?.... using AutoCAD?..... sorry no comprende bien (understand well).


Cheers.

The presentation is going to be AutoCAD running on a touch-screen monitor.

T.Willey

  • Needs a day job
  • Posts: 5241
Re: How would you handle this: Timer function?
« Reply #31 on: September 14, 2006, 02:06:39 PM »
Quote
Error   1   The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?)   C:\Documents and Settings\cchauvin\Local Settings\Application Data\Temporary Projects\Test\Class1.cs   4   14   Test
The only thing I can think of, is that you are not referenceing a windows dll file.  I'm using Windos2000, and Acad06.  You might have to ask one of the .Net gurus for help there.

Edit:  I can supply a dll file if you want, but I know most people don't want to trust a dll file, so I posted the code.  Let me know.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

nivuahc

  • Guest
Re: How would you handle this: Timer function?
« Reply #32 on: September 14, 2006, 02:14:38 PM »
missing resource, got it, found it, compiled it, now have a dll file.

So how do I load a DLL into AutoCAD?  :ugly:

T.Willey

  • Needs a day job
  • Posts: 5241
Re: How would you handle this: Timer function?
« Reply #33 on: September 14, 2006, 02:16:43 PM »
missing resource, got it, found it, compiled it, now have a dll file.

So how do I load a DLL into AutoCAD?  :ugly:
'netload' command.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9484
Re: How would you handle this: Timer function?
« Reply #34 on: September 14, 2006, 08:39:09 PM »
A Script? Why do you want to use a script? AutoLisp is a procedural language, isn't that enough? (Its smarter then just a plain old script.)

CAB and T.Willey, the real problem would be with the scoping aspect. The procedure that does the counting would also have to control the other aspects as well -i.e. I don't really see a way to have a separate proced for handling one thing like timing and one for command handling.

Now, CAB you did hit on a interesting topic (well sorta.) We could build a master procedure for doing all that we need and allow the programmer to ``plug'' process' into that procedure. However that could prove to be difficult, so i think just a ``custom roll'' would have to be the way to go in this case.

In my opinion, all we really need as far as tools is a way for the user to `view the part' , a `way to control end user commands' and `a way to time the whole process'. Everything else like automatic loading and lists of drawings is almost trivial.

*** Sizzle, POP!  HOLD ON ONE SEC! (IDEA) ***
T.Willey, Your SeeSharp proced got me thinking a bit...theoretically speaking, We could:
o  Have lisp set up
o  Pass controll to a separate .DLL / app
o  Which would just start a countdown proced and pass back a var to AutoLisp.
    ( Potential problem! )
o  Have lisp watch environment for command and extra stuff.
o  Once timer is done the timer proced could send a cancel command to Acad and that would trigger the lisp to move on.

hummm...What do you think? Now obviously there are tons more we would have to do/account for, but my thought is that by moving the timer process outside of the acad session, we would not cause Acad to draw more system resources.
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9484
Re: How would you handle this: Timer function?
« Reply #35 on: September 14, 2006, 08:42:51 PM »
BTW, we would prolly have to use a plain old See+Plus or VBee .DLL so that would be no problems with dot-Butterfly-Net.
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1542
  • Moscow (Russia)
Re: How would you handle this: Timer function?
« Reply #36 on: September 15, 2006, 06:14:39 AM »

Code: [Select]
(defun test-3dorbit (/ DOC PT1 PT2 R S V V1 VD VP W)
  ;;  ElpanovEvgeniy, Russia, Moscow, 2006
  ;;  Example of creation function "3dorbit"
  ;;  This variant spins only around of an origin coordinates
  ;;  and does not handle PAN...
  (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))
        v1  (vla-add (vla-get-Views doc) "tmp1")
        pt2 (trans (cadr (grread nil 5)) 1 2)
  ) ;_  setq
  (while (= (car (setq pt1 (grread nil 5))) 5)
    (setq r   (/ (getvar "VIEWSIZE") 4.)
          pt1 (trans (cadr pt1) 1 2)
          v   (trans
                ((lambda (x1 y1 x2 y2)
                   (list
                     (- x1 x2)
                     (- y1 y2)
                     (- (sqrt (abs (- (* R R) (* x1 x1) (* y1 y1))))
                        (sqrt (abs (- (* R R) (* x2 x2) (* y2 y2))))
                     ) ;_  -
                   ) ;_  list
                 ) ;_  lambda
                  (car pt2)
                  (cadr pt2)
                  (car pt1)
                  (cadr pt1)
                )
                2
                1
              ) ;_  trans
          pt2 pt1
          s   (/ r (distance '(0 0 0) (getvar "VIEWDIR")))
          vd  (mapcar (function (lambda (x) (* x s))) (getvar "VIEWDIR"))
          v   (mapcar (function +) vd v)
          s   (/ r (distance '(0 0 0) v))
          v   ((lambda (s) (list (* (car v) s) (* (cadr v) s) (* (caddr v) s)))
                (/ r (distance '(0 0 0) v))
              )
          w   (* (/ r (vla-get-Height (setq vp (vla-get-ActiveViewport doc)))) (vla-get-Width vp) 4.)
    ) ;_  setq
    (vla-put-Direction
      v1
      (vlax-3d-point v)
    ) ;_  vla-put-Direction
    (vla-SetView vp v1)
    (vla-put-Height vp (* r 4.))
    (vla-put-Width vp w)
    (vla-put-ActiveViewport doc vp)
  ) ;_  while
) ;_  defun
Stay home. Stay safe. Save lives.

nivuahc

  • Guest
Re: How would you handle this: Timer function?
« Reply #37 on: September 15, 2006, 09:25:28 AM »
ElpanovEvgeniy, that's very cool. Gorgeous, even. :)

I think his intent was to leave the view shaded, though, while it was being rotated. But that is definately one to stick into the bag of tricks.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1542
  • Moscow (Russia)
Re: How would you handle this: Timer function?
« Reply #38 on: September 15, 2006, 11:17:10 AM »
ElpanovEvgeniy, that's very cool. Gorgeous, even. :)

I think his intent was to leave the view shaded, though, while it was being rotated. But that is definately one to stick into the bag of tricks.


Code: [Select]
(defun test-3dorbit (/ PT1 PT2 R S V V1 VD W)
  ;;  ElpanovEvgeniy, Russia, Moscow, 2006
  ;;  Example of creation function "3dorbit"
  ;;  This variant spins only around of an origin coordinates
  ;;  and does not handle PAN...

  ;;  Add SadeMode
  ;;  (test-3dorbit)
  (setq
    v1  (entmakex
          (list
            '(0 . "VIEW")
            '(100 . "AcDbSymbolTableRecord")
            '(100 . "AcDbViewTableRecord")
            '(2 . "tmp1")
            '(70 . 0)
            (cons 40 (getvar "VIEWSIZE"))
            (cons 10 (getvar "VIEWCTR"))
            (cons
              41
              (* (getvar "VIEWSIZE")
                 (apply
                   (function /)
                   (getvar "SCREENSIZE")
                 ) ;_  apply
              ) ;_  *
            ) ;_  cons
            (cons 11 (getvar "VIEWDIR"))
            (cons 12 (getvar "TARGET"))
            (cons 42 (getvar "LENSLENGTH"))
            (cons 43 (getvar "FRONTZ"))
            (cons 44 (getvar "BACKZ"))
            (cons 50 (getvar "VIEWTWIST"))
            (cons 71 (getvar "VIEWMODE"))
            '(281 . 6)
            '(72 . 0)
          ) ;_  list
        ) ;_  entmakex
    pt2 (trans (cadr (grread nil 5)) 1 2)
  ) ;_  setq
  (while (= (car (setq pt1 (grread nil 5))) 5)
    (setq r   (/ (getvar "VIEWSIZE") 4.)
          r   (if (> r 1e10)
                1e10
                r
              ) ;_  if
          pt1 (trans (cadr pt1) 1 2)
          v   (trans
                ((lambda (x1 y1 x2 y2)
                   (list
                     (- x1 x2)
                     (- y1 y2)
                     (- (sqrt (abs (- (* R R) (* x1 x1) (* y1 y1))))
                        (sqrt (abs (- (* R R) (* x2 x2) (* y2 y2))))
                     ) ;_  -
                   ) ;_  list
                 ) ;_  lambda
                  (car pt2)
                  (cadr pt2)
                  (car pt1)
                  (cadr pt1)
                )
                2
                1
              ) ;_  trans
          pt2 pt1
          s   (/ r (distance '(0 0 0) (getvar "VIEWDIR")))
          vd  (mapcar (function (lambda (x) (* x s))) (getvar "VIEWDIR"))
          v   (mapcar (function +) vd v)
          s   (/ r (distance '(0 0 0) v))
          v   ((lambda (s) (list (* (car v) s) (* (cadr v) s) (* (caddr v) s)))
                (/ r (distance '(0 0 0) v))
              )
          w   (* (/ r (getvar "VIEWSIZE"))
                 (* (getvar "VIEWSIZE")
                    (apply
                      (function /)
                      (getvar "SCREENSIZE")
                    ) ;_  apply
                 ) ;_  *
                 4.
              ) ;_  *
    ) ;_  setq
    (entmod
      (subst (cons 41
                   (* (getvar "VIEWSIZE")
                      (apply
                        (function /)
                        (getvar "SCREENSIZE")
                      ) ;_  apply
                   ) ;_  *
             ) ;_  cons
             (assoc 41 (entget v1))
             (subst (cons 40 (getvar "VIEWSIZE"))
                    (assoc 40 (entget v1))
                    (subst (cons 11 v) (assoc 11 (entget v1)) (entget v1))
             ) ;_  subst
      ) ;_  subst
    ) ;_  entmod
    (entupd v1)
    (setview (tblsearch "VIEW" "tmp1"))
  ) ;_  while
  (entdel v1)
) ;_  defun
Stay home. Stay safe. Save lives.

nivuahc

  • Guest
Re: How would you handle this: Timer function?
« Reply #39 on: September 15, 2006, 11:19:50 AM »
Dude!

That rocks completely!  :kewl:

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1542
  • Moscow (Russia)
Re: How would you handle this: Timer function?
« Reply #40 on: September 15, 2006, 11:41:10 AM »
Fix bag (entdel v1)

Code: [Select]
(defun test-3dorbit (/ PT1 PT2 R S V V1 VD W)
  ;;  ElpanovEvgeniy, Russia, Moscow, 2006
  ;;  Example of creation function "3dorbit"
  ;;  This variant spins only around of an origin coordinates
  ;;  and does not handle PAN...

  ;;  Add SadeMode
  ;;  (test-3dorbit)
  (if (tblsearch "VIEW" "tmp1")
    (setq
      v1  (tblobjname "VIEW" "tmp1")
      pt2 (trans (cadr (grread nil 5)) 1 2)
    ) ;_  setq
    (setq
      v1  (entmakex
            (list
              '(0 . "VIEW")
              '(100 . "AcDbSymbolTableRecord")
              '(100 . "AcDbViewTableRecord")
              '(2 . "tmp1")
              '(70 . 0)
              (cons 40 (getvar "VIEWSIZE"))
              (cons 10 (getvar "VIEWCTR"))
              (cons
                41
                (* (getvar "VIEWSIZE")
                   (apply
                     (function /)
                     (getvar "SCREENSIZE")
                   ) ;_  apply
                ) ;_  *
              ) ;_  cons
              (cons 11 (getvar "VIEWDIR"))
              (cons 12 (getvar "TARGET"))
              (cons 42 (getvar "LENSLENGTH"))
              (cons 43 (getvar "FRONTZ"))
              (cons 44 (getvar "BACKZ"))
              (cons 50 (getvar "VIEWTWIST"))
              (cons 71 (getvar "VIEWMODE"))
              '(281 . 6)
              '(72 . 0)
            ) ;_  list
          ) ;_  entmakex
      pt2 (trans (cadr (grread nil 5)) 1 2)
    ) ;_  setq
  ) ;_  if
  (while (= (car (setq pt1 (grread nil 5))) 5)
    (setq r   (/ (getvar "VIEWSIZE") 4.)
          r   (if (> r 1e10)
                1e10
                r
              ) ;_  if
          pt1 (trans (cadr pt1) 1 2)
          v   (trans
                ((lambda (x1 y1 x2 y2)
                   (list
                     (- x1 x2)
                     (- y1 y2)
                     (- (sqrt (abs (- (* R R) (* x1 x1) (* y1 y1))))
                        (sqrt (abs (- (* R R) (* x2 x2) (* y2 y2))))
                     ) ;_  -
                   ) ;_  list
                 ) ;_  lambda
                  (car pt2)
                  (cadr pt2)
                  (car pt1)
                  (cadr pt1)
                )
                2
                1
              ) ;_  trans
          pt2 pt1
          s   (/ r (distance '(0 0 0) (getvar "VIEWDIR")))
          vd  (mapcar (function (lambda (x) (* x s))) (getvar "VIEWDIR"))
          v   (mapcar (function +) vd v)
          s   (/ r (distance '(0 0 0) v))
          v   ((lambda (s) (list (* (car v) s) (* (cadr v) s) (* (caddr v) s)))
                (/ r (distance '(0 0 0) v))
              )
          w   (* (/ r (getvar "VIEWSIZE"))
                 (* (getvar "VIEWSIZE")
                    (apply
                      (function /)
                      (getvar "SCREENSIZE")
                    ) ;_  apply
                 ) ;_  *
                 4.
              ) ;_  *
    ) ;_  setq
    (entmod
      (subst (cons 41
                   (* (getvar "VIEWSIZE")
                      (apply
                        (function /)
                        (getvar "SCREENSIZE")
                      ) ;_  apply
                   ) ;_  *
             ) ;_  cons
             (assoc 41 (entget v1))
             (subst (cons 40 (getvar "VIEWSIZE"))
                    (assoc 40 (entget v1))
                    (subst (cons 11 v) (assoc 11 (entget v1)) (entget v1))
             ) ;_  subst
      ) ;_  subst
    ) ;_  entmod
    (entupd v1)
    (setview (tblsearch "VIEW" "tmp1"))
  ) ;_  while
) ;_  defun
Stay home. Stay safe. Save lives.

T.Willey

  • Needs a day job
  • Posts: 5241
Re: How would you handle this: Timer function?
« Reply #41 on: September 15, 2006, 11:58:52 AM »
Nicely done Evgeniy!  I don't know/use views enough to have EVER come up with this bit of code.  I will study it and learn some new tricks.  Thanks for sharing.

Edit:  One thing you might want to add, is turning off (or making as small as possible) the cross hairs.
« Last Edit: September 15, 2006, 12:02:59 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1542
  • Moscow (Russia)
Re: How would you handle this: Timer function?
« Reply #42 on: September 15, 2006, 12:01:50 PM »
Code: [Select]
(defun time-3dorbit (/ s)
  ;;  ElpanovEvgeniy, Russia, Moscow, 2006
  ;;  Timer for test-3dorbit
  ;; (time-3dorbit)
  (princ "\n tiner set 60 sec ")
  (princ)
  (setq s ((lambda (sec) (+ (* 86400 (- sec (fix sec))) 60)) (getvar "DATE")))
  (while (> s ((lambda (sec) (* 86400 (- sec (fix sec)))) (getvar "DATE")))
    (VL-CATCH-ALL-APPLY (function test-3dorbit) (list s))
  ) ;_  while
) ;_  defun
(defun test-3dorbit (sec / PT1 PT2 R S V V1 VD W)
  ;;  ElpanovEvgeniy, Russia, Moscow, 2006
  ;;  Example of creation function "3dorbit"
  ;;  This variant spins only around of an origin coordinates
  ;;  and does not handle PAN...

  ;;  Add SadeMode
  ;;  (test-3dorbit)
  (if (tblsearch "VIEW" "tmp1")
    (setq
      v1  (tblobjname "VIEW" "tmp1")
      pt2 (trans (cadr (grread nil 5)) 1 2)
    ) ;_  setq
    (setq
      v1  (entmakex
            (list
              '(0 . "VIEW")
              '(100 . "AcDbSymbolTableRecord")
              '(100 . "AcDbViewTableRecord")
              '(2 . "tmp1")
              '(70 . 0)
              (cons 40 (getvar "VIEWSIZE"))
              (cons 10 (getvar "VIEWCTR"))
              (cons
                41
                (* (getvar "VIEWSIZE")
                   (apply
                     (function /)
                     (getvar "SCREENSIZE")
                   ) ;_  apply
                ) ;_  *
              ) ;_  cons
              (cons 11 (getvar "VIEWDIR"))
              (cons 12 (getvar "TARGET"))
              (cons 42 (getvar "LENSLENGTH"))
              (cons 43 (getvar "FRONTZ"))
              (cons 44 (getvar "BACKZ"))
              (cons 50 (getvar "VIEWTWIST"))
              (cons 71 (getvar "VIEWMODE"))
              '(281 . 6)
              '(72 . 0)
            ) ;_  list
          ) ;_  entmakex
      pt2 (trans (cadr (grread nil 5)) 1 2)
    ) ;_  setq
  ) ;_  if
  (while (and (= (car (setq pt1 (grread nil 5))) 5)
              (> sec ((lambda (sec) (* 86400 (- sec (fix sec)))) (getvar "DATE")))
         ) ;_  and
    (setq r   (/ (getvar "VIEWSIZE") 4.)
          r   (if (> r 1e10)
                1e10
                r
              ) ;_  if
          pt1 (trans (cadr pt1) 1 2)
          v   (trans
                ((lambda (x1 y1 x2 y2)
                   (list
                     (- x1 x2)
                     (- y1 y2)
                     (- (sqrt (abs (- (* R R) (* x1 x1) (* y1 y1))))
                        (sqrt (abs (- (* R R) (* x2 x2) (* y2 y2))))
                     ) ;_  -
                   ) ;_  list
                 ) ;_  lambda
                  (car pt2)
                  (cadr pt2)
                  (car pt1)
                  (cadr pt1)
                )
                2
                1
              ) ;_  trans
          pt2 pt1
          s   (/ r (distance '(0 0 0) (getvar "VIEWDIR")))
          vd  (mapcar (function (lambda (x) (* x s))) (getvar "VIEWDIR"))
          v   (mapcar (function +) vd v)
          s   (/ r (distance '(0 0 0) v))
          v   ((lambda (s) (list (* (car v) s) (* (cadr v) s) (* (caddr v) s)))
                (/ r (distance '(0 0 0) v))
              )
          w   (* (/ r (getvar "VIEWSIZE"))
                 (* (getvar "VIEWSIZE")
                    (apply
                      (function /)
                      (getvar "SCREENSIZE")
                    ) ;_  apply
                 ) ;_  *
                 4.
              ) ;_  *
    ) ;_  setq
    (entmod
      (subst (cons 41
                   (* (getvar "VIEWSIZE")
                      (apply
                        (function /)
                        (getvar "SCREENSIZE")
                      ) ;_  apply
                   ) ;_  *
             ) ;_  cons
             (assoc 41 (entget v1))
             (subst (cons 40 (getvar "VIEWSIZE"))
                    (assoc 40 (entget v1))
                    (subst (cons 11 v) (assoc 11 (entget v1)) (entget v1))
             ) ;_  subst
      ) ;_  subst
    ) ;_  entmod
    (entupd v1)
    (setview (tblsearch "VIEW" "tmp1"))
  ) ;_  while
) ;_  defun
Stay home. Stay safe. Save lives.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1542
  • Moscow (Russia)
Re: How would you handle this: Timer function?
« Reply #43 on: September 15, 2006, 02:11:16 PM »
I was interested with this problem, and I often recollected it!
To release a ideas for work, today I have allocated time, for its decision... :-)

Last variant, shows as it to start for a time, that it would be impossible to stop.
« Last Edit: September 15, 2006, 02:12:26 PM by ElpanovEvgeniy »
Stay home. Stay safe. Save lives.

Greg B

  • Seagull
  • Posts: 12359
  • Tell me a Joke!
Re: How would you handle this: Timer function?
« Reply #44 on: September 15, 2006, 02:18:48 PM »
that it would be impossible to stop.

Nothing is impossible to stop!