Jump to content

display the distance dynamically


vivekgrs

Recommended Posts

hi everybody,

 

I need to write a code for display the horizontal and vertical distance dynamically. while the user pick the start point and move the mouse. can anyone help me how to proceed.

 

 

Thanks

 

Vivek

Link to comment
Share on other sites

hi gile,

 

Thanks for ur immediate response. i had tried dynmode in autocad 2004. it is not working. i had read in some other website that this system variables are available from autocad 2007 onwards. whether its true or what. can u reply me regarding this.

 

regards

vivek

Link to comment
Share on other sites

see if this get you close

 
;;; modemacro will display at the bottom left of the autocad screen before the coordinates read out
(defun c:trk (/ pt1 c)
  (setq pt1 (getpoint "\nSelect a point: "))
(setq x T)
  (while x
       (setq ms (grread T 1))
       (if (= (nth 0 ms) 5)            
  (setvar "modemacro" (rtos(distance pt1 (nth 1 ms))))
       (setq x nil)
       );_if
  );_while
(setvar "modemacro" "");_reset modemacro
 );_defun

Link to comment
Share on other sites

see if this get you close

 
;;; modemacro will display at the bottom left of the autocad screen before the coordinates read out
(defun c:trk (/ pt1 c)
  (setq pt1 (getpoint "\nSelect a point: "))
(setq x T)
  (while x
       (setq ms (grread T 1))
       (if (= (nth 0 ms) 5)            
  (setvar "modemacro" (rtos(distance pt1 (nth 1 ms))))
       (setq x nil)
       );_if
  );_while
(setvar "modemacro" "");_reset modemacro
 );_defun

 

Interesting idea John. Give grtext a look, you can use it and avoid having to set/reset the modemacro system variable.

 

You could also put:

(redraw)
(grdraw pt1 (cadr ms) 7)

so the user has an idea of the origin point.

 

I hope you take no offense to my blathering, just offering additional goodies.

Link to comment
Share on other sites

No offence taken. That is what forums like this are for.

Just remember there is always more than one way to skin a cat.

But it still taste like chicken.

Link to comment
Share on other sites

No offence taken. That is what forums like this are for.

Just remember there is always more than one way to skin a cat.

But it still taste like chicken.

How right you are. :)

Link to comment
Share on other sites

Just to go along with what I was saying...

 

(defun c:Test (/ *error* #Pnt #Read #Dist)
 (setq *error* (lambda (x) (grtext) (redraw)))
 (and (setq #Pnt (getpoint "\nSpecify base point: "))
      (while (eq 5 (car (setq #Read (grread T 15 0))))
        (redraw)
        (grdraw #Pnt (cadr #Read) 1 1)
        (setq #Dist (strcat "Distance: " (rtos (distance #Pnt (cadr #Read)))))
        (princ (strcat "\r" #Dist "          "))
        (grtext -1 #Dist)
      ) ;_ while
 ) ;_ and
 (*error* nil)
 (princ)
) ;_ defun

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...