TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: hmspe on June 13, 2009, 02:35:40 PM

Title: filtering getpoint
Post by: hmspe on June 13, 2009, 02:35:40 PM
As an example, draw a circle, then draw a 3 point arc that starts at the center of the circle (via osnap).  The midpoint and other end of the of the arc should be outside the circle.  I do electrical plans.  For the example the circle represents a receptacle symbol and the arc would be a connection to the next receptacle.

I have a lisp that draws a new arc that uses getpoint to get the first endpoint for the arc.  If I have osnap set to center and select the circle's center getpoint returns the center point of the arc, not the center of the circle.  Any thoughts or suggestions on the best way to get the center of the circle, not the center of the arc?  I can (and will) hack something together, but I'm thinking that someone else may already have a more elegant solution.

Thanks.

Martin
Title: Re: filtering getpoint
Post by: ronjonp on June 13, 2009, 02:43:13 PM
If you always want the centerpoint of the circle use (cdr (assoc 10 (entget (car (entsel))))) instead of getpoint.
Title: Re: filtering getpoint
Post by: hmspe on June 13, 2009, 03:04:28 PM
Thanks.

I actually found a solution just now.  The code I was running was

Code: [Select]
      (setq Pt1 (getpoint "\nEnco_arc>  Pick endpoints: "))
      (command "_.pline" pt1 "a" "a" "90" pause "")

Osmode was set to center and the pline command was obeying osmode for pt1.  With the actual symbols the only thing at pt1 is the arc.  Changing to

Code: [Select]
      (setq Pt1 (getpoint "\nEnco_arc>  Pick endpoints: "))
      (command "_.pline" "non" pt1 "a" "a" "90" pause "")

seems to fix things.  I should have checked what was actually being returned by getpoint instead of assuming....   

Title: Re: filtering getpoint
Post by: Lee Mac on June 13, 2009, 03:37:04 PM
As Ron said, something like this would do the trick  :wink:

Code: [Select]
(defun c:test ()
  (command "_circle")
  (while (> (getvar "CMDACTIVE") 0)
    (command pause))
  (command "_.pline" "_non" (cdr (assoc 10 (entget (entlast)))) "a" "a" "90" pause "")
  (princ))