Author Topic: Autolisp help sought  (Read 1680 times)

0 Members and 1 Guest are viewing this topic.

diarmuid

  • Bull Frog
  • Posts: 417
Autolisp help sought
« on: August 11, 2006, 07:32:25 AM »
help sought on a lisp routine,

below i have attached a little routine that i have been banging my head over for the last few hours.
i run into difficulties when i get as far as calculating angles.

i can get it to extract the angles that i need, but i then want to draw a line @ point p2 90 degrees away from line pt1 pt2.  the start point of this new line is at pt 2 and will have a distance inputted by the user.

can anyone shed some light.  i think i might have to convert the angle back into radians but i am have problems wiht that as well.

any help would be greatly appreciated


(defun c:1()
   
   (setq layerold(getvar "clayer"));      get the current layer
   (setq offdistold(getvar "offsetdist"));      get the offset distance
   (command "-layer" "make" "windows_doors" "c" "6" "" "" );   set the proper layer


   (setq ope(getreal "\nenter the actual ope size..."))

(setq oldsnap(getvar "osmode"))

   (setvar "osmode" 512)
   (princ "\n pick the 1st point of the ope...")
   (setq p1(getpoint))
   (setvar "osmode" 128)
   (princ "\n pick the 2nd point of the ope...")
   (setq p2(getpoint p1 ))
   (command "line" p1 p2 ""); draw line form point pt1 to pt2
   (setq wallwidth(distance p1 p2))
      
      (setq rad1(angle p1 p2))
      (setq ang1(/ (* rad1 180)pi))
      (setq ang2(- ang1 90))


      (setq p3 (polar p2  ang2 ope))

   (command "line" p2 p3 "")

)
If you want to win something run the 100m, if you want to experience something run a marathon

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Autolisp help sought
« Reply #1 on: August 11, 2006, 09:52:00 AM »
Hi,

When using angles calculus you'd rather use radians as AutoCAD do. Only (command ...) function needs angles in the current unit.
So try :

(setq rad1 (angle p1 p2))
(setq ang2 (- rad1 (/ pi 2)))
(setq p3 (polar p2  ang2 ope))
« Last Edit: August 11, 2006, 10:44:33 AM by gile »
Speaking English as a French Frog

Patrick_35

  • Guest
Re: Autolisp help sought
« Reply #2 on: August 11, 2006, 10:22:41 AM »
Un Mosquito qui passe  8-)
Je me doutais bien que tu repondrais à ce type de question  ^-^
A quand l'avatar...  :?

@+

diarmuid

  • Bull Frog
  • Posts: 417
Re: Autolisp help sought
« Reply #3 on: August 11, 2006, 10:57:17 AM »
thats it! thanks for the pointer

Diarmuid
If you want to win something run the 100m, if you want to experience something run a marathon