Author Topic: Help ME re - format code  (Read 267 times)

0 Members and 1 Guest are viewing this topic.

HOSNEYALAA

  • Mosquito
  • Posts: 19
Help ME re - format code
« on: November 07, 2018, 01:40:12 AM »
I have a code that gives the point the height of the nearest TEXT of the point
Is it possible to choose points and numbers at once?
And the requirement that the number of Texts equal the number of characters until the code works

Thanks a lot to everyone.


Code - Auto/Visual Lisp: [Select]
  1. (defun c:DTP (/ AP AT DD END1 END2 H HH HTT I II J LEN NP NT XL1 XL2 YL1 YL2 ZND2)
  2. ; ***************************************
  3.   (ALERT "Required number of points = number of writings")
  4. (command "layer" "m" "NEW_TXT" "")
  5. (command "color" "t" "253,176,23")
  6. (command "CMDECHO" "0")
  7.  (princ "\nSelect POINT :")
  8. (SETQ AP (SSGET (LIST(CONS 0 "POINT"))))
  9.  (princ "\nSelect POINT :")
  10. (setq NP (sslength AP)) ; No of POINT
  11.  
  12. (princ "\nSelect TEXT :")
  13. (SETQ AT (SSGET (LIST(CONS 0 "TEXT,MTEXT"))))
  14.  (princ "\nSelect TEXT,MTEXT :")
  15. (setq NT (sslength AT)) ; No of TEXT
  16.  
  17. ;******************************************************************
  18.  
  19. (setq I 0) ; Order of POINT
  20. (setq II 0) ; Order of TEXT
  21. (setq DD 100) ; No. of Intersection
  22.  
  23. (while (< I NP )
  24.  
  25. (while (< II NT )
  26. (setq END1 (cdr (assoc 10 (entget (ssname AP I ))))) ; Get Point
  27. (setq END2 (cdr (assoc 10 (entget (ssname AT II ))))) ; GetTEXT
  28.        (setq ZND2 (ATOF(cdr (assoc 1 (entget (ssname AT II )))))) ; GetTEXT
  29.  
  30.        (setq XL1 (car END1)) ; Get X cordinate for START POINT.
  31. (setq YL1 (cadr END1)) ; Get Y cordinate for START POINT.
  32. (setq XL2 (car END2)) ; Get X cordinate for END TEXT.
  33. (setq YL2 (cadr END2)) ; Get Y cordinate for END TEXT.
  34.  
  35.        (setq len (sqrt (ABS(+ (expt(- YL2 YL1) 2) (expt(- XL2 XL1) 2)))))
  36.  (if (< LEN DD)
  37.      (progn
  38. (setq hh (list XL1 YL1 ZND2))
  39. (setq DD LEN))
  40.      (progn
  41. (setq h (list XL1 YL1))))
  42.  
  43.  (SETQ II(+ 1 II))
  44.  
  45.  );while
  46.  (SETQ htT (RTOS(CADDR HH) 2 2))
  47.  (command "._Text" "j" "mc" HH 2 "0" htt)
  48.  (command "._point" hh)
  49. ;;;  (command "._Change" (entlast) "" "p" "ELEV" "ZND2" "")
  50.  (setq II 0)
  51.  (SETQ I (+ 1 I))
  52.  (setq DD 100)
  53.  
  54.  );while
  55.  
  56.  )
 
   
EDIT (John): Added code tags to post for formatting.

« Last Edit: November 07, 2018, 07:25:38 AM by John Kaul (Se7en) »

BIGAL

  • Bull Frog
  • Posts: 217
  • 30 + years of using Autocad
Re: Help ME re - format code
« Reply #1 on: February 06, 2019, 07:54:57 PM »
Just search this has been answered many times using a distance between point and text.
A man who never made a mistake never made anything