Author Topic: filtering getpoint  (Read 1305 times)

0 Members and 1 Guest are viewing this topic.

hmspe

  • Bull Frog
  • Posts: 362
filtering getpoint
« 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
"Science is the belief in the ignorance of experts." - Richard Feynman

ronjonp

  • Needs a day job
  • Posts: 7529
Re: filtering getpoint
« Reply #1 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.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

hmspe

  • Bull Frog
  • Posts: 362
Re: filtering getpoint
« Reply #2 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....   

"Science is the belief in the ignorance of experts." - Richard Feynman

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: filtering getpoint
« Reply #3 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))