Author Topic: Find opposite points diagonally  (Read 7040 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
Find opposite points diagonally
« on: January 07, 2014, 06:36:54 AM »
hello guys .

I am stick with one problem and I hope someone can help me with it .  :-)

I have the points p1 and p2 and I need to find p3 and p4 .

is it difficult  ?

Code: [Select]
(if (and (setq p1 (getpoint "\n first point :"))
         (setq p2 (getpoint p1 "\n second point :"))
         )
  (progn
  ( ................


Many thanks .

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Find opposite points diagonally
« Reply #1 on: January 07, 2014, 07:18:52 AM »
You're going to need more information than just 2 points.  Any other know values or predetermined conditions ?  -David
« Last Edit: January 11, 2014, 08:35:17 AM by David Bethel »
R12 Dos - A2K

Coder

  • Swamp Rat
  • Posts: 827
Re: Find opposite points diagonally
« Reply #2 on: January 07, 2014, 07:52:07 AM »
You're going to need more information than just 2 points.  Any other know values or predetermined conditions ?  -David

Thank you David .

I am sorry not  :oops: , I am after to draw a box with the four points and offset box from the first one .

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Find opposite points diagonally
« Reply #3 on: January 07, 2014, 08:18:01 AM »
Look into vlax-curve-getclosestpointto.
(vlax-curve-getclosestpointto (car (entsel)) (getpoint))

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Bhull1985

  • Guest
Re: Find opposite points diagonally
« Reply #4 on: January 07, 2014, 08:27:10 AM »
The two bounding lines would be good info for finding angle, rise/run

Coder

  • Swamp Rat
  • Posts: 827
Re: Find opposite points diagonally
« Reply #5 on: January 07, 2014, 08:31:43 AM »
Look into vlax-curve-getclosestpointto.
(vlax-curve-getclosestpointto (car (entsel)) (getpoint))

I don't have line to select , I need to get the points 3 and 4 after specifying the points 1 and 2

The two bounding lines would be good info for finding angle, rise/run

I did not understand your reply Bhull  :-(

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find opposite points diagonally
« Reply #6 on: January 07, 2014, 09:06:16 AM »
In addition to p1 and p2 you will need one angle.
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.

efernal

  • Bull Frog
  • Posts: 206
Re: Find opposite points diagonally
« Reply #7 on: January 07, 2014, 09:27:36 AM »
if you have a line p1/p3 or p2/p4 so you have the angle...
e.fernal

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Find opposite points diagonally
« Reply #8 on: January 07, 2014, 10:50:56 AM »
From the screen cap it seems you already have the 2 bounding lines. After picking P1 & P2 it should then be possible to select those lines from those points (no further user input needed) - you could use ssget for this (send the P1 & P2 points as single selection points to ssget). From this you then have the angle(s) to calculate P3 & P4. If you don't want to calculate then what about using osnap to pick the perpendicular points as-and-when you pick 1 & 2 (you might have to fiddle with the lastpoint setvar to work out the correct perp)? If the lines are always longer than the resulting "rectangle" then you could also simply use the vlax-curve-getClosestPointTo.

E.g. here's the quickest way I know of doing this without ssget and only using old ALisp functions:
Code - Auto/Visual Lisp: [Select]
  1. (if (and (setq p1 (getpoint "\n first point :"))
  2.          (setq p2 (getpoint p1 "\n second point :"))
  3.          )
  4.   (progn
  5.     (setq p3 (osnap p1 "_Perp"))
  6.     (setvar "LastPoint" p1)
  7.     (setq p4 (osnap p2 "_Perp"))
  8.     ;; Continue using the 4 points here
  9.   )
  10. )

If your screen cap is indicating something other than 2 bounding entities, then there's no way for ACad to "know" what angle the rectangle is to be drawn at. You need to specify it somehow, either ask the user to provide the angle, or default to the current UCS.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find opposite points diagonally
« Reply #9 on: January 07, 2014, 11:10:40 AM »
See reply #5, he said he doesn't have a line to select.
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.

Coder

  • Swamp Rat
  • Posts: 827
Re: Find opposite points diagonally
« Reply #10 on: January 07, 2014, 11:31:24 AM »
See reply #5, he said he doesn't have a line to select.

That is correct ,

The grey colored hidden lines representing a wall and the other two lines are the two sides of pipe , and I want to find the other two points p3 and p4 .

Many thanks

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Find opposite points diagonally
« Reply #11 on: January 07, 2014, 01:11:06 PM »
Would you know the distance say p1 to p4 or p1 to p3, that would work. (angle would not matter)

Then you could do a distance/distance intersection type of function to create points p3 & p4.
« Last Edit: January 07, 2014, 01:14:37 PM by snownut2 »

Bhull1985

  • Guest
Re: Find opposite points diagonally
« Reply #12 on: January 07, 2014, 03:53:18 PM »
"bounding lines" are the lines that pass through points p1 and p3, and p2 and p4 respectively.
The line that is created by going through either set of these two points in relation to the p1-p2 line, doing an angle command on those two lines will tell you your base angle.
your base angle minus 90 degrees will tell you the angle at which to draw your new line from p2 to leave a perfect 90 perpendicular system as shown in the screencap...I think

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Find opposite points diagonally
« Reply #13 on: January 07, 2014, 04:02:20 PM »
The included angle from p1 to p2 to p4 is definitely not 90deg.  That is the problem in trying to get you an answer....

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Find opposite points diagonally
« Reply #14 on: January 07, 2014, 04:02:30 PM »
See reply #5, he said he doesn't have a line to select.

That is correct ,

The grey colored hidden lines representing a wall and the other two lines are the two sides of pipe , and I want to find the other two points p3 and p4 .

Many thanks

If the pipe and / or wall exist (no lines but pline or block object) then that would work for establishing a perpendicular.
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.