Author Topic: Lisp won't work in conjunction with OSNAP  (Read 3843 times)

0 Members and 1 Guest are viewing this topic.

M-dub

  • Guest
Lisp won't work in conjunction with OSNAP
« on: July 16, 2004, 01:28:00 PM »
Anyone have any idea why this won't work properly when I have OSNAP turned on?  I use this "Osnap" all the time and it's getting to be a pain, turning osnap off every time I want to use it.

I added BTWN.lsp to my startup suite and added the definition for it in the menu under POP0
ID_OsnapBtwn [&Between]_'btwn

Code: [Select]
(defun c:btwn (/ PT1 PT2)
  (setq PT1
    (getpoint "\nEnter first point:")
  )
  (setq PT2
    (getpoint "\nEnter second point:")
  )
  (polar PT1
    (angle PT1 PT2)
    (/ (distance PT1 PT2) 2)
  )
); end btwn.lsp

sinc

  • Guest
Lisp won't work in conjunction with OSNAP
« Reply #1 on: July 18, 2004, 09:51:35 AM »
How are you using this function?

Sometimes you can get into trouble because osnaps are being applied more often than you intend.  For example, you might expect the following code to draw a line between your midpoint and another point, but it might not:

(setq ptA (btwn))
(setq ptB (getpoint "\nEnter another point"))
(command "_.line" ptA ptB "")

The problem is that osnaps are still turned on when the line command is issued.  For example, if ptA (the midpoint) happens to be near some other line, and the endpoint osnap is on, the new line will be drawn between the endpoint of that existing line and ptB, not between ptA and ptB.

Is this what's going on?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Lisp won't work in conjunction with OSNAP
« Reply #2 on: July 18, 2004, 05:26:33 PM »
Here is an example where the calling routine uses the points entered
in a command. Note that the osnaps are temporarily turned off using the
NONe switch. It has to be used for each point.

Code: [Select]
;;  Routine to return the mid point of two picked points
;;  a poit list pf poit 1 point 2 and mid point is returned
;;  If user quits, nil is returned
(defun btwn (/ pt1 pt2)
  (cond
    ((and
       (setq pt1 (getpoint "\nEnter first point:"))
       (setq pt2 (getpoint pt1 "\nEnter second point:"))
     )
     ;;  both points selected, return the point list with mid point
     (list pt1 pt2 (polar pt1 (angle pt1 pt2) (/ (distance pt1 pt2) 2)))
    )
    ;;  user failed to complete, return nil
    (nil)
  )
) ; end btwn.lsp

;;  Draw a circle from to two end points of the diameter
(defun c:cTest()
  (prompt "\nPick two points for circle diameter.")
  (if (setq plist (btwn))
    (command "._circle" "non" (caddr plist) "non" (car plist))
    (prompt "\n*-*  User Quit *-*")
  )
  (princ)
); defun
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

SMadsen

  • Guest
Lisp won't work in conjunction with OSNAP
« Reply #3 on: July 18, 2004, 06:16:22 PM »
I use one that can be used as standalone or in a command. Either way, it sets LASTPOINT to the chosen point. But if used in a command (transparently) it simply returns "@" which overrides running osnaps. Otherwise, it just returns the point itself.

Code: [Select]
(defun C:BTW (/ p1 p2 pt)
  (cond
    ((setq p1 (getpoint "Between point: "))
     (and (setq p2 (getpoint p1 "and point: "))
       (setvar "LASTPOINT"
               (setq pt (mapcar '+ p1(mapcar '/ (mapcar '- p2 p1) '(2.0 2.0 2.0))))
       )
     )
    )
  )
  (if (> (getvar "CMDACTIVE") 0) "@" pt)
)


E.g.
Command: LINE
Specify first point: 'btw
Between point: and point: "@"
Specify next point or [Undo]:


By the way, after 20 years it finally got implemented!! Just upgrade to 2005 :)  (it's called M2P and works great)

M-dub

  • Guest
Lisp won't work in conjunction with OSNAP
« Reply #4 on: July 18, 2004, 08:01:50 PM »
Thanks guys,
  I'll try those out when I get to work tomorrow.
   If I remember correctly, I think what ends up happening is this:
Let's say I have Endpoint as the running osnap turned on.  If I wanted to draw a circle in the centre of a square, I would use the btwn function and select the 'endpoints' of opposite corners of the square.  I think it basically ignores the btwn command and only uses the endpoint.  However, if I turn the running osnap off and do the same thing, using the 'manual' endpoint osnap, it works fine.

Now...
I'm going to have to check to make sure this problem still exists with 2004 because I know I had the problem with 2000.  I just haven't had time yet to do any cadding since I got the new machine...Mostly just setup and plotting a few drawings here and there.  I just tried it on my 'backup' version of acad 2002 at home and it worked fine, so maybe this is a moot point.  :roll:

Cheers!
Mike