Draw line and circle together

Draw line and circle together

Anonymous
Not applicable
1,947 Views
10 Replies
Message 1 of 11

Draw line and circle together

Anonymous
Not applicable

Hi, I want my program to prompt the user to draw a circle without asking for any keyboard inputs, the program show understand the size/radius of the circle just by how much the user drags the mouse after clicking. Once, the circle is drawn, I want the program to prompt the user to draw a line, again, no keyboard input just depends on the user how long he/she wants the link to be. I have seen multiple codes for drawing a circle and a line separately but I still haven't figured out how to combine the two. 

0 Likes
1,948 Views
10 Replies
Replies (10)
Message 2 of 11

roland.r71
Collaborator
Collaborator

@Anonymouswrote:

Hi, I want my program to prompt the user to draw a circle without asking for any keyboard inputs, the program show understand the size/radius of the circle just by how much the user drags the mouse after clicking. Once, the circle is drawn, I want the program to prompt the user to draw a line, again, no keyboard input just depends on the user how long he/she wants the link to be. I have seen multiple codes for drawing a circle and a line separately but I still haven't figured out how to combine the two. 


Any special reason why they should not ask for keyboard input? as those are just optional.

So, whats wrong with:

(Command "circle" pause pause "line" pause pause "")

Circle:

   Pause 1: Select starting / center point

   Pause 2: Assign radius (by dragging and clicking mouse)

Line:

   Pause 1: Select starting point

   Pause 2: Select next (end) point

"":

Empty string to end command

 

This does exactly what you ask for, but you do still have all the optional prompts...

0 Likes
Message 3 of 11

Anonymous
Not applicable

Thank you for your help,  I appreciate it. The reason I want to do this is so I can just draw multiple circles and lines attached to them at one go without typing every single time.

0 Likes
Message 4 of 11

ВeekeeCZ
Consultant
Consultant

This is really simple, but I think that for the CIRCLE command may be better to NOT determinant the precise amount of user inputs (= amount of PAUSEs) in case you ever want to change a setting to diameter... If you  use a (command-s) instead, then you stays within the command as long as you need... try:

 

(defun c:CircleLine ()
  (command-s "_.CIRCLE")
  (command "_.LINE" PAUSE PAUSE)
  (princ)
)

On the other hand, for the LINE command makes using the pause twice more sense, because you don't need to do an extra click to finish the command.

0 Likes
Message 5 of 11

stevor
Collaborator
Collaborator

This is a basic form for a string of connected circles:

 

 ; Distance with default of D, prompt of S,  AusCadd.com
 (Defun Get_D (D S / A)  (if (setq D (if (numberp D) D 1.0)
   A (getdist (strcat " " S " < " (rtos D 2 4) " > "))) A D) )
 
 (setq Cir*D (Get_D Cir*D  "\n Circle Diameter: "))
 
 ; connected circles
 (Defun C:CCL ( / P1 P2 C1 C2)
  (if (setq C1 (getpoint "\n Starting Center "))
   (while (setq C2 (getpoint C1 "\n Next Center "))
    (setq P1 (polar C1 (angle C1 C2) (/ Cir*D 2.))
          P2 (polar C2 (angle C2 C1) (/ Cir*D 2.)) )
    (command "CIRCLE" C1 "D" Cir*D  "CIRCLE" C2  "D" Cir*D
             "LINE" P1 P2 "")
    (setq C1 C2)  )) (princ) ) ; def
  
 (C:CCL ) ; begins execution

S
0 Likes
Message 6 of 11

Anonymous
Not applicable

@ВeekeeCZ Thanks a lot! This is almost what I am looking for. How to modify this code by adding some while loop so that it repeatedly asks the user to first draw a circle and then draw line? It can exit the while loop if the user types something specific

0 Likes
Message 7 of 11

ВeekeeCZ
Consultant
Consultant

Sure. You can end the command by RT click. Also changed the wording of the first line prompt to actually say that is point FOR LINE. At this point you can also hit RT to <no line> option if that ever be a case... or remove those words - the option would still be possible but hidden for the user and not disturbing.

 

(defun c:CircleLine (/ pnt)
  (while (setq pnt (getpoint "\nSpecify center point for circle <exit>: "))
    (command-s "_.CIRCLE" "_none" pnt)
    (if (setq pnt (getpoint "\nSpecify first point for line <no line>: "))
      (command "_.LINE" "_none" pnt PAUSE "")))
  (princ)
)
0 Likes
Message 8 of 11

Anonymous
Not applicable

@ВeekeeCZ Can you also help me with extending this code to trim the lines inside the circles?

0 Likes
Message 9 of 11

ВeekeeCZ
Consultant
Consultant

@Anonymouswrote:

@ВeekeeCZ Can you also help me with extending this code to trim the lines inside the circles?


Sure thing that I can you help you... but, unfortunately, you forgot to post something you need to help with. Don't be wrong - not going to do the whole thing for you.

Message 10 of 11

Anonymous
Not applicable

Alright, I am working on it. 🙂

0 Likes
Message 11 of 11

scot-65
Advisor
Advisor
Beekee:

🙂

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes