Author Topic: Bearing Orientation and distanse to *.txt  (Read 7547 times)

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Bearing Orientation and distanse to *.txt
« Reply #30 on: December 29, 2013, 12:45:50 PM »
Dear Pedro

Corrected code is as follows :-

Code: [Select]
(defun c:bear2txt (/ p1 p11 p2 p21 p3 p31 d1 fname)
  (setq p1 (getpoint "\nPick Base Referene point: "))
  (setq p11 (getstring "\nEnter Label Base Referene point: "))
  (setq p2 (getpoint p1 "\nPick Second point: "))
  (setq p21 (getstring "\nEnter Label of Second point: "))
  (setq
    fname (getfiled "Save Text File As:" (getvar 'dwgprefix) "TXT" 1)
  )
  (setq fil (open fname "w"))
  (If (< (car p1) (car p2))
    (progn (setq tmp p1) (setq p1 p2) (setq p2 tmp))
  )
  (setq cnt 1)
  (setq pn p1)
  (while (not (equal pn nil))
    (if (setq pn (getpoint (strcat "\nPick point " (itoa cnt) " : ")))
      (progn (setq
       pnl (getstring
     (strcat "\nEnter Label of point " (itoa cnt) " : ")
   )
     )
     (setq ang (/ (* (- (angle p1 p2) (angle p1 pn)) 200) pi))
     (write-line
       (strcat (itoa cnt)
       ","
       pnl
       ","
       (rtos ang 2 2)
       ","
       (rtos (distance p1 pn) 2 2)
       )
       fil
     )
     (setq cnt (1+ cnt))
      )
    )
  )
  (alert
    (strcat (itoa (- cnt 1)) " points written in file " fname)
  )
  (close fil)
  (princ)
)


pedroantonio

  • Guest
Re: Bearing Orientation and distanse to *.txt
« Reply #31 on: December 30, 2013, 02:46:11 AM »
Thank you mailmaverick your lisp work perfect

Don't forget  to thank CAB,Kerry ,Lee Mac,dgorsman,snownut2,roy_043 for there  advises.

Thank you all , Marry Christmas and Happy new year !!!!!!!!!!!!

pedroantonio

  • Guest
Re: Bearing Orientation and distanse to *.txt
« Reply #32 on: December 30, 2013, 03:59:05 AM »
Sorry again mailmaverick i find a little problem with Exterior Angle. Gives me negative angles. Can you fix this ? Here is my *dwg file to understand the problem ..

thanks


mailmaverick

  • Bull Frog
  • Posts: 493
Re: Bearing Orientation and distanse to *.txt
« Reply #33 on: December 30, 2013, 05:38:06 AM »
Dear Pedro

Problem of Negatives corrected !!!!!

Code: [Select]
(defun c:bear2txt (/ p1 p11 p2 p21 p3 p31 d1 fname)
  (setq p1 (getpoint "\nPick Base Referene point: "))
  (setq p11 (getstring "\nEnter Label Base Referene point: "))
  (setq p2 (getpoint p1 "\nPick Second point: "))
  (setq p21 (getstring "\nEnter Label of Second point: "))
  (setq
    fname (getfiled "Save Text File As:" (getvar 'dwgprefix) "TXT" 1)
  )
  (setq fil (open fname "w"))
  (If (< (car p1) (car p2))
    (progn (setq tmp p1) (setq p1 p2) (setq p2 tmp))
  )
  (setq cnt 1)
  (setq pn p1)
  (while (not (equal pn nil))
    (if (setq pn (getpoint (strcat "\nPick point " (itoa cnt) " : ")))
      (progn (setq
       pnl (getstring
     (strcat "\nEnter Label of point " (itoa cnt) " : ")
   )
     )
     (setq ang (/ (* (- (angle p1 p2) (angle p1 pn)) 200) pi))
     (if (< ang 0)
       (setq ang (+ ang 400))
     )
     (write-line
       (strcat (itoa cnt)
       ","
       pnl
       ","
       (rtos ang 2 2)
       "g,"
       (rtos (distance p1 pn) 2 2)
       )
       fil
     )
     (setq cnt (1+ cnt))
      )
    )
  )
  (alert
    (strcat (itoa (- cnt 1)) " points written in file " fname)
  )
  (close fil)
  (princ)
)


roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Bearing Orientation and distanse to *.txt
« Reply #34 on: December 30, 2013, 05:52:18 AM »
but i have an error with the angle
The (angtos) function takes the ANGBASE variable into account. This may explain the wrong values.
« Last Edit: December 30, 2013, 06:05:51 AM by roy_043 »

pedroantonio

  • Guest
Re: Bearing Orientation and distanse to *.txt
« Reply #35 on: December 30, 2013, 06:00:34 AM »
Thank you mailmaverick now works perfect

Happy new year to all ............