Author Topic: How to avoid direction of picking points?  (Read 6111 times)

0 Members and 1 Guest are viewing this topic.

pBe

  • Bull Frog
  • Posts: 402
Re: How to avoid direction of picking points?
« Reply #15 on: June 10, 2012, 12:49:20 PM »
uhmm.. i thought you wanted to control/avoid the direction of pick point? the snippet i posted will "avoid" picking a point at the left side of the first pick point, that way you dont need to "swap" the pick point variable. or am i missing a valuable piece of info altogether?

perhaps using CABs approach, <angle> in place of X coordinate. <(< (car p1) (car p2))>

Code - Auto/Visual Lisp: [Select]
  1. (and (setq pk nil  p1 (getpoint "\nPick first point."))
  2.            (while (and (not pk)
  3.                  (setq p2 (getpoint p1 "\nPick second point.")))
  4.            (if (< (/ pi 2) (angle p1 p2) (* pi 1.5))
  5.                  (princ "\nPoint is left of first point, Try again:")(setq pk T))))

Try picking a point at the left side of first point.


irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: How to avoid direction of picking points?
« Reply #16 on: June 10, 2012, 04:23:14 PM »
From my understanding of this sentence:
How to make always left point as pt and right point as p2 even I picked from right to left?
IMO: It means the OP wants to "sort" the returned points such that p1 contains the left-most point picked, and p2 the right-most - no matter in which order the user picked those points. Also that seems to be what HasanCAD's done in his code. Perhaps we just understand it differently.

As for CAB's idea of using angle to figure out which point is left and which is right, does that work if AngDir or AngBase is set different from the defaults? If I test this it goes a bit wonky, especially if there's also a UCS to worry about. BTW, if there's a UCS then getpoint gives the UCS values - not the Screen's or the WCS's, so in this case if the UCS is turned 90deg CCW from the screen display then you effectively get the lower point in p1 (as displayed on screen).

HasanCAD: When you mention left/right, do you refer to as seen on the screen, or as per the current UCS, or as per WCS, or should AngDir/AngBase also be accounted for? By default they all mean the same thing, but some setting changes could throw that idea out the window. At the moment the comparison of X values takes note of the UCS, and the angle takes UCS+AngBase.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

pBe

  • Bull Frog
  • Posts: 402
Re: How to avoid direction of picking points?
« Reply #17 on: June 10, 2012, 11:02:05 PM »
From my understanding of this sentence:
How to make always left point as pt and right point as p2 even I picked from right to left?
IMO: It means the OP wants to "sort" the returned points such that p1 contains the left-most point picked, and p2 the right-most - no matter in which order the user picked those points. Also that seems to be what HasanCAD's done in his code. Perhaps we just understand it differently.

Yup, that appears what HasanCAD did with his code. I would've undertand If the points were not supplied by the user , then swapping the points would make sense. but there are ways to prevent that from happening, as the OP aptly put it "AVOID" direction of picking points. but thats just me  :-D

If I test this it goes a bit wonky,

Wonky, i havent heard that word in a long time.  :lol: guess we better stick with (< (car p1) (car p2)) .... perhaps with trans?


« Last Edit: June 11, 2012, 01:27:40 AM by pBe »

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: How to avoid direction of picking points?
« Reply #18 on: June 11, 2012, 03:29:44 AM »
The "wonky" is just my mind having difficulty in grasping the various settings and seeing something strange like 270 from angle when I expected 90  ::) . I really don't know which is more correct, comparing X values or comparing angles - IMO both do the same thing (or should at least).
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: How to avoid direction of picking points?
« Reply #19 on: June 11, 2012, 04:07:12 AM »
...
HasanCAD: When you mention left/right, do you refer to as seen on the screen, or as per the current UCS, or as per WCS, or should AngDir/AngBase also be accounted for?
....
I was thinking in the same point, In case of UCS changed, This is full code
Code: [Select]
(if (< (car (trans p2 1 0)) (car (trans p1 1 0)))
       (setq tmp p1 p1 p2 p2 tmp) T)
What will habben if both point have same Y value - line is vertical.
I think the best way to tell the user how to pick points
Code: [Select]
(alert "in case of horizantal tendon
Pick left point then right point
In case of vertical tendon
pick lower point then higher point")