LISP FOR DISTANCE BETWEEN 2 CIRCLE SELECTION

LISP FOR DISTANCE BETWEEN 2 CIRCLE SELECTION

Jgmargarito26
Enthusiast Enthusiast
992 Views
11 Replies
Message 2 of 12

LISP FOR DISTANCE BETWEEN 2 CIRCLE SELECTION

Jgmargarito26
Enthusiast
Enthusiast

COULD I GET SOME HELP, ON CREATING A LISP WERE INSTEAD OF PICKING CENTER POINT TO CENTERPOINT, YOU COULD BE ABLE TO SELECT A CIRCLE TO CIRCLE AND IT GIVES YOU A DISTANCE ON YOUR COMMAND BAR OR IN A DIM STYLE.

0 Likes
993 Views
11 Replies
Replies (11)
Message 1 of 12

Jgmargarito26
Enthusiast
Enthusiast

COULD I GET SOME HELP, ON CREATING A LISP WERE INSTEAD OF PICKING CENTER POINT TO CENTERPOINT, YOU COULD BE ABLE TO SELECT A CIRCLE TO CIRCLE AND IT GIVES YOU A DISTANCE ON YOUR COMMAND BAR OR IN A DIM STYLE.

0 Likes
Message 3 of 12

imadHabash
Mentor
Mentor

Hi,

 

Try QDIM command . 

Imad Habash

EESignature

0 Likes
Message 4 of 12

Jgmargarito26
Enthusiast
Enthusiast

THAT ITS GOOD, BUT IT CREATES A DIMENSION I WAS HOPING FOR SOMETHING WERE IT TELLS YOU IN THE COMMAND BAR, WE DEAL WITH A HIGH VOLUME OF WORK SO SOMETHING FAST WITH OUT ME GOING BACK AND DELETING. 

0 Likes
Message 5 of 12

Moshe-A
Mentor
Mentor

@Jgmargarito26  hi,

 

here you are but untested Smiley LOL

 

enjoy

moshe

 

 

 

(defun c:cdist ( / ss elist0 elist1 c0 c1)
 (if (setq ss (ssget '((0 . "circle"))))
  (cond
   ((/= (sslength ss) 2)
    (prompt "\nerror: select only two circles.")
   ); case
   ( t
    (setq elist0 (entget (ssname ss 0)) elist1 (entget (ssname ss 1)))
    (setq c0 (cdr (assoc '10 elist0)) c1 (cdr (assoc '10 elist1)))
    (princ (strcat "\nDistance= " (rtos (distance c0 c1))))
   ); case
  ); cond
 (princ)
)

 

0 Likes
Message 6 of 12

Kent1Cooper
Consultant
Consultant

The Customization Forum is the better place to request something like this, but quickly and in simplest terms [and untested]:

(defun C:C2CD (/ c1 c2); = Circle-{to}-Circle Distance
  (setq
    c1 (car (entsel "\nSelect a Circle: "))
    c2 (car (entsel "\nSelect another Circle: "))
  ); setq
  (prompt
    (strcat
      "\nDistance between Circle centers is "
      (rtos ; [in current Units mode/precision settings]
        (distance
          (cdr (assoc 10 (entget c1)))
          (cdr (assoc 10 (entget c2)))
        ); distance
      ); rtos
      "."
    ); strcat
  ); prompt
); defun

It could be made to verify that you actually picked two Circles, and not the same one twice, and could make different use of the information, etc., etc.

Kent Cooper, AIA
0 Likes
Message 7 of 12

Jgmargarito26
Enthusiast
Enthusiast

NO LUCKSmiley Sad

0 Likes
Message 8 of 12

Jgmargarito26
Enthusiast
Enthusiast

HEY THIS IS EXACTLY WHAT I WAS LOOKING FOR, IS THERE A WAY FOR IT SELECT MULTIPLE INSTEAD OF CHOSSING ONE CIRCLE AT A TIME? I KNOW IAM ASKING FOR TO MUCH

0 Likes
Message 9 of 12

Kent1Cooper
Consultant
Consultant

@Jgmargarito26 wrote:

.... IS THERE A WAY FOR IT SELECT MULTIPLE INSTEAD OF CHOSSING ONE CIRCLE AT A TIME? ....


 

I'm not sure I see the advantage in that.  You'd still need to make at least two picks, to define a window, or at best a pick-and-hold and a release using Lasso selection.  What if the selection contains more than two  Circles?  What should it do then?

Kent Cooper, AIA
0 Likes
Message 10 of 12

Jgmargarito26
Enthusiast
Enthusiast

WHEN I MEANT MULTIPLE I MEAN JUST 2 CIRCLES. 

0 Likes
Message 11 of 12

Moshe-A
Mentor
Mentor

you are right, here's a fix

 

(defun c:cdist ( / ss elist0 elist1 c0 c1)
 (if (setq ss (ssget '((0 . "circle"))))
  (cond
   ((/= (sslength ss) 2)
    (prompt "\nerror: select only two circles.")
   ); case
   ( t
    (setq elist0 (entget (ssname ss 0)) elist1 (entget (ssname ss 1)))
    (setq c0 (cdr (assoc '10 elist0)) c1 (cdr (assoc '10 elist1)))
    (princ (strcat "\nDistance= " (rtos (distance c0 c1))))
   ); case
  ); cond
 ); if
 (princ)
)
0 Likes
Message 12 of 12

Kent1Cooper
Consultant
Consultant

@Jgmargarito26 wrote:

WHEN I MEANT MULTIPLE I MEAN JUST 2 CIRCLES. 


 

Well, you can do this, to have it keep asking until you pick two and only two Circles:

(defun C:C2CD (/ ss); = Circle-{to}-Circle Distance
  (prompt "\nFor the distance betwen two Circle centers,")
  (while
    (not
      (and
        (setq ss (ssget '((0 . "CIRCLE"))))
        (= (sslength ss) 2)
      ); and
    ); not
    (prompt "\nMust select 2 and only 2 Circles.")
  ); while
  (prompt
    (strcat
      "\nDistance between Circle centers is "
      (rtos ; [in current Units mode/precision settings]
        (distance
          (cdr (assoc 10 (entget (ssname ss 0))))
          (cdr (assoc 10 (entget (ssname ss 1))))
        ); distance
      ); rtos
      "."
    ); strcat
  ); prompt
  (princ)
); defun

But that seems a disadvantage to me, in terms of selection steps.  Not only do you still need at least two picks or a pick-and-hold-and-release to make the selection, but you also need to Enter to complete the selection.  For me, I'd rather use just two picks as in my first suggestion.

Kent Cooper, AIA
0 Likes