Lions60
2007-07-06, 09:29 PM
I am having trouble finding the intersection between two lines. I have searched the help files and also searched here on Augi and couldn't find much. I have all four points needed to find the intersection. In the code below at the bottom where i am finding the interesection there is a commented line of code. This line of code returns the correct intersection point but gives me an error and terminates the program. The uncommented line of code (the on ewithout the ;; in front of it) works without any errors, but does not return the correct intersection point between the two lines. Any help would be appreciated.
An Economizer module is just a rectangle of any width and height. I have been using one with an x dimension of 80 and a y dimension of 120.
(defun C:Econo ()
(setq old_osnap(getvar "osmode"))
;;Getting Upper right Hand corner of Economizer module
(setq pnt1 (getpoint "\nSelect the upper right hand corner of the Economizer Section: \n"))
;;Getting Lower Left Hand corner of Economizer module
(setq pnt2 (getcorner pnt1 "\nSelect the lower left hand corner of the Economizer Section: \n"))
(setvar "osmode" 0)
;;Getting Angle the economizer will be placed at
(setq ang (getreal "Enter angle of economizer <30 or 45>:\n"))
;;Getting Center point of Economizer module.
(setq cpnt (list(/(+(car pnt1)(car pnt2))2)(/(+(cadr pnt1)(cadr pnt2))2)))
;;Second point from center of module at the angle specified by the user.
(setq cpnt1 (polar cpnt (dtr ang)3))
;;Getting the boudary of the economizer module
(setq bndry1 (polar pnt2 (dtr 90) (-(cadr pnt1)(cadr pnt2))))
(setq bndry2 (polar pnt1 (dtr 270) (-(cadr pnt1)(cadr pnt2))))
;;Finding the intersection of where the center point would cross the first point selected.
;;(setq inters1 (inters (car cpnt) (cadr cpnt) (car pnt1) (cadr pnt1)))
(setq inters1 (inters cpnt cpnt1 pnt1 bndry2))
(setvar "osmode" old_osnap)
)
An Economizer module is just a rectangle of any width and height. I have been using one with an x dimension of 80 and a y dimension of 120.
(defun C:Econo ()
(setq old_osnap(getvar "osmode"))
;;Getting Upper right Hand corner of Economizer module
(setq pnt1 (getpoint "\nSelect the upper right hand corner of the Economizer Section: \n"))
;;Getting Lower Left Hand corner of Economizer module
(setq pnt2 (getcorner pnt1 "\nSelect the lower left hand corner of the Economizer Section: \n"))
(setvar "osmode" 0)
;;Getting Angle the economizer will be placed at
(setq ang (getreal "Enter angle of economizer <30 or 45>:\n"))
;;Getting Center point of Economizer module.
(setq cpnt (list(/(+(car pnt1)(car pnt2))2)(/(+(cadr pnt1)(cadr pnt2))2)))
;;Second point from center of module at the angle specified by the user.
(setq cpnt1 (polar cpnt (dtr ang)3))
;;Getting the boudary of the economizer module
(setq bndry1 (polar pnt2 (dtr 90) (-(cadr pnt1)(cadr pnt2))))
(setq bndry2 (polar pnt1 (dtr 270) (-(cadr pnt1)(cadr pnt2))))
;;Finding the intersection of where the center point would cross the first point selected.
;;(setq inters1 (inters (car cpnt) (cadr cpnt) (car pnt1) (cadr pnt1)))
(setq inters1 (inters cpnt cpnt1 pnt1 bndry2))
(setvar "osmode" old_osnap)
)