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

0 Members and 2 Guests are viewing this topic.

pedroantonio

  • Guest
Bearing Orientation and distanse to *.txt
« on: December 05, 2013, 06:08:56 AM »
i am searching for a bearing a distance lisp like the example *.gif

and then give the name of the export  txt file
« Last Edit: December 05, 2013, 06:16:56 AM by pedroantonio »

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Bearing Orientation and distanse to *.txt
« Reply #1 on: December 05, 2013, 06:45:17 AM »
Pedro,

This is a pretty simple task.  It seems you are requesting a lot of "Free" stuff lately, this would be a good time to try something on your own.  Once you show some initiative and get something started I am sure folks here would be happy to assist in any areas you are having trouble with.


Bruce

pedroantonio

  • Guest
Re: Bearing Orientation and distanse to *.txt
« Reply #2 on: December 05, 2013, 11:34:49 AM »
Ok snownut2 i agree with you . I try this

Code - Auto/Visual Lisp: [Select]
  1. (defun c:bear2txt (/ *error* p1 p11 p2 p21 p3 p31 d1 out del)
  2.   (setq p1 (getpoint "\nPick Base Referene point: "))
  3.   (setq p11 (getstring "\nEnter Label Base Referene point: "))
  4.   (setq p2 (getpoint p1 "\nPick Second point: "))
  5.   (setq p21 (getstring "\nEnter Label of Second point: "))
  6. )
  7.   (setq angs (If (> (car p1) (car p2)) "ang(p1,p3,p2)" "ang(p1,p2,p3)")
  8.   )
  9.   (while (setq p3 (getpoint p1 (strcat "\nPick point :")))
  10.     (setq p3l (getstring "\nEnter Label of point: "))
  11.     (setq d1 (rtos (distance p1 p3) 2 2)) data))
  12.     (princ)
  13.    ((setq out ((vl-filename-base (getvar 'dwgname))) ".txt") del ",")
  14.   (princ)
  15.  

And i have this error

[CHECKING TEXT <Untitled-2> loading...]
....
; error: too few arguments in SETQ: (SETQ OUT (( ... )) ".txt")
..


Any ideas?

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Bearing Orientation and distanse to *.txt
« Reply #3 on: December 05, 2013, 02:38:45 PM »
LISP works from the inside bracket out.  So, find the deepest nested function in the line where you have problems.  Put it at the command line, and check the result.  Is it what you expected?  If not, then what needs to be changed?  If it is providing the correct result, grab the next inner-most bracket and put that to the command line.  Repeat the process until you come up to where it isn't giving the expected/correct result.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

pedroantonio

  • Guest
Re: Bearing Orientation and distanse to *.txt
« Reply #4 on: December 06, 2013, 01:39:21 AM »
i try it but i still have problem.

pedroantonio

  • Guest
Re: Bearing Orientation and distanse to *.txt
« Reply #5 on: December 06, 2013, 06:18:15 PM »
I try and this but nothing !!

Code - Auto/Visual Lisp: [Select]
  1. (defun c:bear2txt (/ *error* p1 p11 p2 p21 p3 p31 d1 fname)
  2.   (setq p1 (getpoint "\nPick Base Referene point: "))
  3.   (setq p11 (getstring "\nEnter Label Base Referene point: "))
  4.   (setq p2 (getpoint p1 "\nPick Second point: "))
  5.   (setq p21 (getstring "\nEnter Label of Second point: "))
  6. )
  7.   (setq angs (If (> (car p1) (car p2))
  8.                "ang(p1,p3,p2)"
  9.                "ang(p1,p2,p3)"
  10.              )
  11.   )
  12.   (while (setq p3 (getpoint p1 (strcat "\nPick point :")))
  13.     (setq p3l (getstring "\nEnter Label of point: "))
  14.     (setq d1 (rtos (distance p1 p3) 2 2))
  15.     data
  16.   )
  17. )
  18. (setvar "cmdecho" 0)
  19. (setq fname (getfiled "Save Text File As:" "" "txt" 1))
  20. )
  21.   (strcat "\n* Text file " fname " \n has been created *")
  22.  
  23.   (princ)
  24. )
  25. )
  26.  

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Bearing Orientation and distanse to *.txt
« Reply #6 on: December 06, 2013, 07:51:39 PM »
Pedro,

Just what CAD program are you using ?

pedroantonio

  • Guest
Re: Bearing Orientation and distanse to *.txt
« Reply #7 on: December 07, 2013, 03:21:22 AM »
autocad 2012

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Bearing Orientation and distanse to *.txt
« Reply #8 on: December 07, 2013, 09:09:47 AM »
Pedro,

For LISP development you really need to become familiar with the VLIDE option in ACAD.  Just type VLIDE at the command prompt and a new window will open (the LISP Editor).  You can then open an existing LISP or DCL file for editing.  Using the EDITOR will help you check for syntax errors, and you can test your code right within the editor.

Taking some time to become familiar with this function will save you tons of headaches as you are developing LISP functions.

Bruce

pedroantonio

  • Guest
Re: Bearing Orientation and distanse to *.txt
« Reply #9 on: December 07, 2013, 04:26:47 PM »
I know that snownut2 and i use VLIDE . I do this chage and the VLIDE shows me no errors but when  i run in autocad this lisp  gives me  this error

; error: bad argument type: point: nil

Code - Auto/Visual Lisp: [Select]
  1. (defun c:bear2txt (/ *error* p1 p11 p2 p21 p3 p31 d1 fname)
  2.   (setq p1 (getpoint "\nPick Base Referene point: "))
  3.   (setq p11 (getstring "\nEnter Label Base Referene point: "))
  4.   (setq p2 (getpoint p1 "\nPick Second point: "))
  5.   (setq p21 (getstring "\nEnter Label of Second point: "))
  6. )
  7.   (setq angs (If (> (car p1) (car p2))
  8.                "ang(p1,p3,p2)"
  9.                "ang(p1,p2,p3)"
  10.              )
  11.   )
  12.   (while (setq p3 (getpoint p1 (strcat "\nPick point :")))
  13.     (setq p3l (getstring "\nEnter Label of point: "))
  14.     (setq d1 (rtos (distance p1 p3) 2 2))
  15.     data
  16.   )
  17. )
  18. (setvar "cmdecho" 0)
  19. (setq fname (getfiled "Save Text File As:" "" "txt" 1))
  20.  
  21.  

I don't know what to do please show me ......

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Bearing Orientation and distanse to *.txt
« Reply #10 on: December 07, 2013, 04:49:39 PM »
i use VLIDE . I do this chage and the VLIDE shows me no errors but when  i run in autocad this lisp  gives me  this error

; error: bad argument type: point: nil

I don't know what to do please show me ......

Follow this tutorial.

pedroantonio

  • Guest
Re: Bearing Orientation and distanse to *.txt
« Reply #11 on: December 08, 2013, 02:58:18 AM »
Thank you Lee for the tutorial.Helps me a lot.

Now the lisp have no errors but when i save the txt file on my desktop i can't  find it ?? I don't know . I thing that something is missing here !! :embarrassed:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:bear2txt (/ p1 p11 p2 p21 p3 p31 d1 fname)
  2.   (setq p1 (getpoint "\nPick Base Referene point: "))
  3.   (setq p11 (getstring "\nEnter Label Base Referene point: "))
  4.   (setq p2 (getpoint p1 "\nPick Second point: "))
  5.   (setq p21 (getstring "\nEnter Label of Second point: "))
  6.  
  7.   (setq angs (If (> (car p1) (car p2))
  8.                "ang(p1,p3,p2)"
  9.                "ang(p1,p2,p3)"
  10.              )
  11.   )
  12.   (while (setq p3 (getpoint p1 (strcat "\nPick point :")))
  13.     (setq p3l (getstring "\nEnter Label of point: "))
  14.     (setq d1 (rtos (distance p1 p3) 2 2))
  15.     data
  16.   )
  17. )
  18. (setvar "cmdecho" 0)
  19. (setq fname (getfiled "Save Text File As:" "" "txt" 1))
  20. )
  21.  
  22.  

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Bearing Orientation and distanse to *.txt
« Reply #12 on: December 08, 2013, 05:08:00 AM »
Quote
I thing that something is missing here !!

Looks to me like you aren't actually writing the data to a file ??
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Bearing Orientation and distanse to *.txt
« Reply #13 on: December 08, 2013, 05:10:08 AM »
and why are you using (vl-load-com)??
I suggest you read up on it's usage  ... both why and where.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

pedroantonio

  • Guest
Re: Bearing Orientation and distanse to *.txt
« Reply #14 on: December 08, 2013, 01:03:55 PM »
I try and this but i have the same problem withthe file. I don't know. Perhaps is samething easy but i don;t know haw to do it !!

Code - Auto/Visual Lisp: [Select]
  1. (defun c:bear2txt (/ p1 p11 p2 p21 p3 p31 d1 fname)
  2.   (setq p1 (getpoint "\nPick Base Referene point: "))
  3.   (setq p11 (getstring "\nEnter Label Base Referene point: "))
  4.   (setq p2 (getpoint p1 "\nPick Second point: "))
  5.   (setq p21 (getstring "\nEnter Label of Second point: "))
  6.  
  7.   (progn
  8.     (setq angs (If (> (car p1) (car p2))
  9.                  "ang(p1,p3,p2)"
  10.                  "ang(p1,p2,p3)"
  11.                )
  12.     )
  13.     (while (setq p3 (getpoint p1 (strcat "\nPick point :")))
  14.       (setq p3l (getstring "\nEnter Label of point: "))
  15.       (setq d1 (rtos (distance p1 p3) 2 2))
  16.       data
  17.     )
  18.   )
  19.  
  20.   (princ)
  21.   (setvar "cmdecho" 0)
  22.      (str fname (getfiled "Save Text File As:" "" "txt" 1) fil)
  23.  
  24.      (close fil)
  25.      (format stream content)
  26.    )
  27.     (princ)
  28.   )
  29. )
  30.