Is this a bug?

It seems that the lisp function 'osnap' doesn't work properly with the "cen" mode.
If you have a circle drawn and the 'center' snap set, type something like (setq s (osnap (getpoint) "cen")) and enter that.
Then pick near the edge of the circle when the snap indicator (center) is shown. It always returns nil for me. It should,
I think, return the snap position, that is, the circle center. Other snaps I have tried such as "end" and "int" work.
Am I doing something wrong? I have tried different forms of the mode like "center", "cenp" and "centerp" but no luck.
By the way, this problem also occurs when running external lisp code, not just on the command line.

Comments

  • I should have mentioned the Bricscad version is Linux beta 11.3.13 . The machine is AMD 64 running Ubuntu 10.04.
  • I just tried (osnap (getpoint) "cen") in V11.3.13 under Ubuntu 10.04 - it correctly returns the center point;
    but I did not get the snap marker (and it should even not appear at all, using Lisp expression).
    so I'm not sure how you can get the snap marker ...
    I also tried with acitvated object snap (ESNAP status bar field), but no difference, that Lisp expression
    works as expected ...
  • I can reproduce the problem on Windows. It only happens when center point esnap is on. 
  • Torsten, thanks for your reply. I stand by the statement in my original post. If the center snap (esnap) is set, the snap marker is visible and the (setq s (osnap (getpoint) "cen")) expression always returns nil. Now if I cancel the center snap, no snap marker is visible, and the expression does correctly return the position. This somewhat contradictory behavior presents a problem for my intended use of the osnap function in lisp programs. If I want to pick the center of a circle or arc to locate a subsequently created entity and I want to use the osnap function to check the position, I can't use the active center snap to show the marker. No other snap mode I've tried in the osnap expression behaves this way. They work correctly with or without the snap set. By the way, my old Icad 4 Std has the same problem!
  • Dear Randy, Dear Mehmet,
    now I got it ... and can also reproduce on both Windows + Linux,
    but I'm not sure whether this is really a bug.

    (osnap ) uses the argument input, and tries
    to find the appropriate snap point due to - so far so good.

    BUT as you use (getpoint) for the argument, the (getpoint) function
    itself also respects current (permanent) snap mode - thus, (getpoint) itself
    returns the center point of the circle, as visualised by the "center" indocator glyph;
    and then *that* center point is passed to (osnap) function.

    Of course, given that center point to (osnap) does not find an object then, around aperture
    area of center point - and returns NIL then.

    I verified with AutoCAD - and it is the same, NIL is returned.

    I also remember similar problems with Lisp programs using (osnap), but having permanent
    snap modes active ...
    the only safe solution is to set snapmode off like (setvar "osmode" o) when running (osnap)
    function ... and, btw, the same applies when using (command) function : "osmode" should be
    set to 0, otherwise you can get unpredictable results (as point arguments passed to (command)
    function will also tirgger point snapping, thus, other than intended points might be used by commands
    then).

    I hope this clarifies the situation ?
    Many greetings to all, Torsten

  • Torsten,
      Thank you for the explanation. Now I see how the center snap is a special case. I'll have to work with it. Thanks again.
  • Something I've noticed while using the osnap lisp function in Bricscad. It seems that
    when there are more than one mode listed, e.g. (osnap (getpoint) "end,cen,int"), only
    the first in the list is used, the rest are ignored. This does not happen in my old
    ICAD 4. Could someone verify this? Thanks.

  • I just tried (osnap (getpoint) "cen,int,end") on an isolated line,
    no _center point of course available, and no _intersection possible :
    clicking onto the line correctly returned the closer end point of the line.

    Can you give a scenario where the problem you encountered does happen ?

    Many greetings, Torsten
  • Hi Torsten,
      The expected behavior from the osnap function is that it returns the snap position x,y,z when the cursor is close enough (within the aperture box) to a snap whose mode is in the mode string. So, if the command is (osnap (getpoint) "cen,int,end"), and I have two crossed lines on the screen, I think I should be able to get osnap to return any of all four endpoints and the intersection with five repetitions of the command and appropriate location of the cursor near the snap points. What I get in these cases is nothing, that is, the osnap returns nil. If I rewrite the command as (osnap (getpoint) "end,int,cen"), the osnap will correctly return the endpoint positions as I locate them, one by one. If I try to find the intersection, I just get the nearest endpoint. If I rewrite the command again as
    (osnap (getpoint) "int,end,cen"), I will get the intersection position but no endpoints. I hope this clarifies it.
  • I forgot to mention that no snaps are active in the above examples.
  • Dear Randy,

    I will try to reproduce, and will keep you updated ... many thanks for the hints.
  • Dear Randy,

    thanks to your samples + explanations I was now able to reproduce.
    First I got the impression, that this effect - returning NIL instead of found snap point -
    would only apply under OpenSUSE, but then I could reproduce even under Ubuntu.

    As it seems, that bug was present in all V11 versions ... now I tried with V12 build,
    and it seems to completely fine, (osnap) always returned the correct point, in all scenarios
    as you mentioned.

    I tried V12 with Ubuntu 10.04 + 11.04 + 11.10, and OpenSUSE 11.4 and 12.1,
    and (osnap) was correct ... so it seems, the issue is safely fixed with V12.

    Many greetings !
  • Thanks Torsten,
      Looks like I'll be upgrading soon.
This discussion has been closed.