Author Topic: Catch it if you can, dynamic circle draw  (Read 2323 times)

0 Members and 1 Guest are viewing this topic.

Adesu

  • Guest
Catch it if you can, dynamic circle draw
« on: October 23, 2007, 03:48:28 AM »
This code as animation, if your cursor far from a circle, that circle would bigger and opposite if nearest.
Code: [Select]
; acfc is stand for Animation Circle From Cursor
;        Design by  : Adesu <Ade Suharna>
;        Email      : mteybid@yuasabattery.co.id
;        Homepage   : http://www.yuasa-battery.co.id
;        Website    : http://cadesu.multiply.com
;        Create     : 23 October 2007
;        Program no.: 0667/10/2007
;        Edit by    :
(defun c:acfc (/ c1 dis gr p1 rad vgad vgao vgms xrad)
   (vl-load-com)
   (setq vgao (vlax-get-acad-object))
   (setq vgad (vla-get-activedocument vgao))
   (setq vgms (vla-get-modelspace vgad))
   (setq p1 '(0 0 0))
   (setq rad 0.5)
   (setq c1 (vla-addCircle vgms (vlax-3d-point p1) rad))
   (vla-put-color c1 acred)
   (while
      (setq gr (cadr (grread nil 7)))
      (setq xrad (vlax-get c1 'radius))
      (setq dis (distance p1 gr))
      (if
         (< dis xrad)
         (vla-put-radius c1 (* dis 0.5))
         ) ; if
       (if
         (> dis xrad)
         (vla-put-radius c1 (* dis 0.5))
         ) ; if
      ) ; while
   )    ; defun


<edit: title change by CAB>
« Last Edit: October 23, 2007, 10:41:14 AM by CAB »

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Catch it if you can
« Reply #1 on: October 23, 2007, 04:34:59 AM »
Sight on the other hand...  :-)
Code: [Select]
(defun test-1 (/ e g)
 ;;(test-1)
 (setq e (entget (entmakex '((0 . "CIRCLE") (62 . 1) (10 0. 0. 0.) (40 . 10)))))
 (while (and (setq g (grread nil 7)) (= 5 (car g)))
  (setq e (entmod (subst (cons 40 (distance '(0. 0. 0.) (cadr g))) (assoc 40 e) e)))
 ) ;_  while
 (princ)
)

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Catch it if you can
« Reply #2 on: October 23, 2007, 05:05:58 AM »
return radius, do not create entities...
Code: [Select]
(defun test-2 (/ A G R)
 ;;(test-2)
 (while (= (car (setq g (grread nil 5))) 5)
  (setq r (distance '(0. 0. 0.) (trans (cadr g) 1 3))
        a 0.
  ) ;_  setq
  (redraw)
  (repeat 200
   (grvecs
    '(1
      (0.9998766324816601 -0.01570731731184392)
      (0.9998766324816601 0.01570731731184392)
     )
    (list (list (* (cos (setq a (+ a 0.03141592653589793))) r) (- (* (sin a) r)) 0. 0)
          (list (* (sin a) r) (* (cos a) r) 0. 0)
          (list 0. 0. r 0.)
          '(0. 0. 0. 1.)
    ) ;_  list
   ) ;_  grvecs
  ) ;_  repeat
 ) ;_  while
 (princ (strcat "\n Radius = " (rtos r 2)))
 (princ )
)

Maverick®

  • Seagull
  • Posts: 14778
Re: Catch it if you can
« Reply #3 on: October 23, 2007, 10:33:11 AM »
Adesu, Could you please change the thread title to explain what your code does?  Thanks!