Can you correct & complete the code?

Can you correct & complete the code?

smallƑish
Advocate Advocate
472 Views
6 Replies
Message 1 of 7

Can you correct & complete the code?

smallƑish
Advocate
Advocate

Looking for preview while pressing "tab" key circle of diameter of 100, 200, 300, respectively each press.  then 4th press back to 100 and mouse clicks to draw the chosen diameter circle.

 

 

(defun c:z2 (/)
(setq p1 (getpoint "\np1"));center of circle

(setq option1 (command "_.circle" p1 "d" "100" "" ))
(setq option2 (command "_.circle" p1 "d" "200" "" ))
(setq option2 (command "_.circle" p1 "d" "300" "" ))


(grread (option1 option2 option3 ))

)

0 Likes
Accepted solutions (3)
473 Views
6 Replies
Replies (6)
Message 2 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution

What behavior are you expecting from GRREAD that you're wanting so badly?

 

PS. Convince yourself to no more trying grread, it's too much advanced.

Message 3 of 7

smallƑish
Advocate
Advocate
Accepted solution

A preview can make a more detailed idea of drafting, That is why. Example 45Rectangle program.

If it is too complicated, will try later.

0 Likes
Message 4 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

A Circle command will provide its own center-point prompt.  If you want the center point specified before the cycling through size options, then if the Circle is actually drawn first, (grread) can be used simply to determine whether to change its diameter, rather than to have a Circle drawn differently under each size choice.  Try this [lightly tested]:

 

(defun C:C123 (/ dia)
  (command "_.CIRCLE" pause 50)
  (while
    (and
      (princ
        (strcat
          "\nCircle shown at diameter of "
          (rtos (setq dia (getpropertyvalue (entlast) "Diameter")) 2 0)
          ". Press TAB to cycle to "
          (rtos (setq dia (+ (rem dia 300) 100)) 2 0)
          ", any other key to accept current size."
        ); strcat
      ); prompt
      (equal (grread nil 2 1) '(2 9)); pressed TAB
    ); and
    (setpropertyvalue (entlast) "Diameter" dia); change to next diameter in cycle
  ); while
  (princ)
); defun

 

EDIT:  Changed the cycling calculation to something a little shorter, without the (if) function, using (rem).

Kent Cooper, AIA
Message 5 of 7

john.uhden
Mentor
Mentor

@smallƑish 

If you look at what you've written (and know that the command function always returns nil) then you'll realize that option1 and option2 and option3 (had it been set) are all set to nil, and (grread nil nil nil) gets you nowhere.

John F. Uhden

Message 6 of 7

Sea-Haven
Mentor
Mentor

Its probably not helpful but type C100 and pick a point a circle gets drawn, maybe a keep yes no, type c200 a circle gets drawn, I have  a draw circle reactor that reads the radius as part of a command. You could do some form of start rad and step into the code. 

 

Draw a circle press + gets a unit bigger, press - gets smaller, press enter is keep. Would be easier to code.

 

 

Message 7 of 7

john.uhden
Mentor
Mentor

@smallƑish 

Ya know, another option I just thought of is to draw a circle with a diameter of 100, then offset it twice by 100, and choose the one you want by erasing the others.

OR, we could help you to draw all three with one pick, and then you choose which one to keep.

John F. Uhden

0 Likes