Author Topic: help with azimuth lisp  (Read 3993 times)

0 Members and 1 Guest are viewing this topic.

pedroantonio

  • Guest
help with azimuth lisp
« on: November 16, 2016, 11:22:33 AM »
My unit settings are decimal , grads ,clock wise ,and direction noth and i use annotation texts.

I have found a lisp code for azimuth and distance but not working for clockwise and grads. Can any one fix it ?

Code: [Select]
;;; ROTINA PARA COTAR E OU AZIMUTAR POLYLINES - TEXTO NO DESENHO = 2.34 ou 2.34 - Az 23°15΄7"
;;; AS MEDIDAS APARECEM COMO FORAM DIGITADAS NO DESENHO (METROS, MILΝMETROS, ETC)
;;; A ALTURA DO TEXTO Ι SOLICITADA NA EXECUΗΓO DA ROTINA E O STYLE Ι O CORRENTE
;;; ACERTAR ALTURA DO TEXTO DE ACORDO COM A ESCALA DE PLOTAGEM. PARA DEIXAR EM DEFAULT USE O COMMAND: TEXTSIZE
;;; Forum www.autolisp.com.br - Nome da rotina original: AZPOL - Autor: Orlei 29/08/2006
;;; Adaptaηγo: Rogιrio Zanini e Mαrcio
;;;---------------------------------------------------------- ------------------------

(princ "\nDigite AZI para iniciar - Verificar TextStyle corrente")
(defun C:AZI2 ()
(command "undo" "begin"); Voltar de uma sσ vez toda a operaηγo da Rotina - ACRESCENTADO ROGΙRIO
;---------------Sub-functions - Start-------------
(defun RTD ()
(/ (* (angle A B) 180) Pi)
)
;-------------------------------------------------
(defun DTR (AZIMUTE)
(* (/ AZIMUTE 180) Pi)
)
;-------------------------------------------------
(defun PARALELO ()
(setq A1 (polar A (+ (/ pi 2)(angle B A )) (+ (* 0.60 htext) (/ htext 2)))) ;0.60 x ALTURA TEXTO = distβncia do texto da Pline ;MODIFICAΗΓO ROGΙRIO
(setq B1 (polar B (+ (/ pi 2)(angle B A )) (+ (* 0.60 htext) (/ htext 2)))) ;0.60 x ALTURA TEXTO = distβncia do texto da Pline ;MODIFICAΗΓO ROGΙRIO

(setq ptx (/ (+ (car B1) (car A1)) 2))
(setq pty (/ (+ (cadr B1) (cadr A1)) 2))
(setq ponto_meio (list ptx pty))
(if (< (car A1)(car B1))
(setq inicio B1)
(setq inicio A1)
)
)
;-------------------------------------------------
(defun MUDAR ()
(setq XL 2)
(setq J "d")
(setq COM1 (substr D 1 1))
(while (< XL 5)
(setq LETRAT (substr D XL 1))
(setq RESTOT (substr D (+ 1 XL) ))
(if (= LETRAT J)
(progn (setq J "%%d")
(setq XL 6)
(setq PALAV (strcat COM1 J RESTOT))
)
)
(setq COM1 (strcat COM1 LETRAT ))
(setq XL (1+ XL))
)
)
;----------------Sub-functions - End -------------
(setq tsize (getvar "textsize"))
(initget "Y N")
(setq opt (getkword "\nIncluir Dados de Azimute? [Y/N] <N>: "))

(if (= nil
(setq htext (getreal (strcat "\nAltura do texto <" (rtos (getvar "textsize") 2 2) ">: ")))
)
(setq htext (getvar "textsize")))

(setvar"cmdecho" 0)
(command "osmode" 0)
(command "angbase" 270)
(command "angdir" 1)
(setq flagv "falso")
(setq controle 0)
(setq controle1 0)
(setq contador 0)
(while (= flagv "falso")
(setq mostre (entsel "\nSelecione a Polyline <2d> : "))
(setq linha (entget (car mostre )))
(setq verificador (cdr(assoc 0 linha)))
(if (= verificador "LWPOLYLINE")
(progn
(setq verif (cdr (assoc 70 linha)))
(setq flagv "verdade")
)
(princ "\nNγo ι Polyline !! ")
)
)

(setq controle1 (length linha))
(setq amostra '())
(repeat controle1
(setq x (caar linha))
(if (= x 10)
(progn
(setq item (car linha))
(setq amostra (cons item amostra))
(setq contador (1+ contador))
)
)
(setq linha (cdr linha))
)
(setq amostra1 (reverse amostra))
(if (= verif 1)
(setq amostra (cons (car amostra1) amostra))
(setq contador (1- contador))
)
(setq controle contador)
(repeat controle
(setq PTO1 (cdr(car amostra)))
(setq PTO2 (cdr(car(cdr amostra))))
(AZIMUTAR)
(setq amostra(cdr amostra))
)
(command "undo" "end")
(princ)
)
(defun AZIMUTAR ()
(setq padroes (getvar "osmode"))
(setvar"cmdecho" 0)
(command "osmode" 0)
(setq A PTO1)
(setq B PTO2)
(setq C " - Az "); PREFIXO DO ΒNGULO OU "m - Az " m=para metros OU mm=para milνmetros
(setq D (angtos (angle A B) 1 3)) ;UNIDADE/N°DE CASAS 1= Decimal degrees = 45.0000 / 4= N° CASAS = 270°0'0"
(MUDAR)
;------------- MODIFICAΗΓO ROGΙRIO OPΗΓO AZIMUTE ----------------
(setq E (Strcat(rtos (distance A B) 2 2)"m"))  ;PRIMEIRO 2= UNIDADE DECIMAL / SEGUNDO 2= N°DE CASAS
(setq DADO E)
(if (= opt "Y") (setq DADO (strcat E C PALAV)))
;---------------------------------------------------------- ------
(PARALELO)
;;; (command "text" "J" "MC" ponto_meio htext inicio dado ) ;htext = ALTURA TEXTO ;MODIFICAΗΓO ROGΙRIO
(entmake
(list
(cons 0 "TEXT")
(cons 7 (getvar "textstyle")) ;STYLE DE TEXTO CORRENTE DO DESENHO
; (cons 8 "0") ;ATIVADO A COTA FICA NA LAYER "0" OU OUTRA INDICADA
(cons 100 "AcDbText")
(cons 10 ponto_meio)
(cons 11 ponto_meio)
(cons 40 htext) ;ALTURA DO TEXTO CORRENTE NO DESENHO
(cons 1 dado)
(cons 50 (angle ponto_meio inicio)) ;TEXTO PARALELO A LINHA
(cons 72 1) ;JUSTIFICAΗΓO TEXTO HORIZONTAL - CENTER
(cons 73 2) ;JUSTIFICAΗΓO TEXTO VERTICAL - MIDDLE
)
)

(setvar "textsize" tsize)
(command "osmode" padroes)
(command "osmode" "37") ; ACRESCENTADO MΑRCIO - OSNAP END/INT/CEN
(princ)
)

thanks

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: help with azimuth lisp
« Reply #1 on: November 16, 2016, 11:53:51 AM »
I think this is the original lisp post.  https://goo.gl/mo6wSL

;;; ROUTINE FOR POLLING AND OR AZIMUTING POLYLINES - TEXT IN DESIGN = 2.34 or 2.34 - Az 23 ° 15'7 "
;;; THE MEASURES APPEAR AS THEY WERE DIGITED IN THE DESIGN (METERS, MILLIMETERS, ETC)
;;; TEXT HEIGHT REQUIRED IN ROUTINE IMPLEMENTATION AND STYLE IS THE CURRENT
;;; CHOOSE TEXT HEIGHT ACCORDING TO PLOTAGE SCALE. TO LEAVE DEFAULT USE COMMAND: TEXTSIZE
;;; Forum www.autolisp.com.br - Name of the original routine: AZPOL - Author: Orlei 29/08/2006
;;; Adaptation: Rogério Zanini and Márcio
----------------------------------------------- ----------- ------------------------
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

pedroantonio

  • Guest
Re: help with azimuth lisp
« Reply #2 on: November 16, 2016, 02:55:32 PM »
Hi CAB i dont know if is the same code. Can you fix this code . Thanks

Code: [Select]
;;; ROTINA PARA COTAR E OU AZIMUTAR POLYLINES - TEXTO NO DESENHO = 2.34 ou 2.34 - Az 23°15΄7"
;;; AS MEDIDAS APARECEM COMO FORAM DIGITADAS NO DESENHO (METROS, MILΝMETROS, ETC)
;;; A ALTURA DO TEXTO Ι SOLICITADA NA EXECUΗΓO DA ROTINA E O STYLE Ι O CORRENTE
;;; ACERTAR ALTURA DO TEXTO DE ACORDO COM A ESCALA DE PLOTAGEM. PARA DEIXAR EM DEFAULT USE O COMMAND: TEXTSIZE
;;; Forum www.autolisp.com.br - Nome da rotina original: AZPOL - Autor: Orlei 29/08/2006
;;; Adaptaηγo: Rogιrio Zanini e Mαrcio
;;;---------------------------------------------------------- ------------------------

(princ "\nDigite AZI para iniciar - Verificar TextStyle corrente")
(defun C:AZI ()
(command "undo" "begin"); Voltar de uma sσ vez toda a operaηγo da Rotina - ACRESCENTADO ROGΙRIO
;---------------Sub-functions - Start-------------
(defun RTD ()
(/ (* (angle A B) 180) Pi)
)
;-------------------------------------------------
(defun DTR (AZIMUTE)
(* (/ AZIMUTE 180) Pi)
)
;-------------------------------------------------
(defun PARALELO ()
(setq A1 (polar A (+ (/ pi 2)(angle B A )) (+ (* 0.60 htext) (/ htext 2)))) ;0.60 x ALTURA TEXTO = distβncia do texto da Pline ;MODIFICAΗΓO ROGΙRIO
(setq B1 (polar B (+ (/ pi 2)(angle B A )) (+ (* 0.60 htext) (/ htext 2)))) ;0.60 x ALTURA TEXTO = distβncia do texto da Pline ;MODIFICAΗΓO ROGΙRIO

(setq ptx (/ (+ (car B1) (car A1)) 2))
(setq pty (/ (+ (cadr B1) (cadr A1)) 2))
(setq ponto_meio (list ptx pty))
(if (< (car A1)(car B1))
(setq inicio B1)
(setq inicio A1)
)
)
;-------------------------------------------------
(defun MUDAR ()
(setq XL 2)
(setq J "d")
(setq COM1 (substr D 1 1))
(while (< XL 5)
(setq LETRAT (substr D XL 1))
(setq RESTOT (substr D (+ 1 XL) ))
(if (= LETRAT J)
(progn (setq J "%%d")
(setq XL 6)
(setq PALAV (strcat COM1 J RESTOT))
)
)
(setq COM1 (strcat COM1 LETRAT ))
(setq XL (1+ XL))
)
)
;----------------Sub-functions - End -------------
(setq tsize (getvar "textsize"))
(initget "Y N")
(setq opt (getkword "\nIncluir Dados de Azimute? [Y/N] <N>: "))

(if (= nil
(setq htext (getreal (strcat "\nAltura do texto <" (rtos (getvar "textsize") 2 2) ">: ")))
)
(setq htext (getvar "textsize")))

(setvar"cmdecho" 0)
(command "osmode" 0)
(command "angbase" 270)
(command "angdir" 1)
(setq flagv "falso")
(setq controle 0)
(setq controle1 0)
(setq contador 0)
(while (= flagv "falso")
(setq mostre (entsel "\nSelecione a Polyline <2d> : "))
(setq linha (entget (car mostre )))
(setq verificador (cdr(assoc 0 linha)))
(if (= verificador "LWPOLYLINE")
(progn
(setq verif (cdr (assoc 70 linha)))
(setq flagv "verdade")
)
(princ "\nNγo ι Polyline !! ")
)
)

(setq controle1 (length linha))
(setq amostra '())
(repeat controle1
(setq x (caar linha))
(if (= x 10)
(progn
(setq item (car linha))
(setq amostra (cons item amostra))
(setq contador (1+ contador))
)
)
(setq linha (cdr linha))
)
(setq amostra1 (reverse amostra))
(if (= verif 1)
(setq amostra (cons (car amostra1) amostra))
(setq contador (1- contador))
)
(setq controle contador)
(repeat controle
(setq PTO1 (cdr(car amostra)))
(setq PTO2 (cdr(car(cdr amostra))))
(AZIMUTAR)
(setq amostra(cdr amostra))
)
(command "undo" "end")
(princ)
)
(defun AZIMUTAR ()
(setq padroes (getvar "osmode"))
(setvar"cmdecho" 0)
(command "osmode" 0)
(setq A PTO1)
(setq B PTO2)
(setq C " - Az "); PREFIXO DO ΒNGULO OU "m - Az " m=para metros OU mm=para milνmetros
(setq D (angtos (angle A B) 1 4)) ;UNIDADE/N°DE CASAS 1= Decimal degrees = 45.0000 / 4= N° CASAS = 270°0'0"
(MUDAR)
;------------- MODIFICAΗΓO ROGΙRIO OPΗΓO AZIMUTE ----------------
(setq E (Strcat(rtos (distance A B) 2 2)"m"))  ;PRIMEIRO 2= UNIDADE DECIMAL / SEGUNDO 2= N°DE CASAS
(setq DADO E)
(if (= opt "Y") (setq DADO (strcat E C PALAV)))
;---------------------------------------------------------- ------
(PARALELO)
;;; (command "text" "J" "MC" ponto_meio htext inicio dado ) ;htext = ALTURA TEXTO ;MODIFICAΗΓO ROGΙRIO
(entmake
(list
(cons 0 "TEXT")
(cons 7 (getvar "textstyle")) ;STYLE DE TEXTO CORRENTE DO DESENHO
; (cons 8 "0") ;ATIVADO A COTA FICA NA LAYER "0" OU OUTRA INDICADA
(cons 100 "AcDbText")
(cons 10 ponto_meio)
(cons 11 ponto_meio)
(cons 40 htext) ;ALTURA DO TEXTO CORRENTE NO DESENHO
(cons 1 dado)
(cons 50 (angle ponto_meio inicio)) ;TEXTO PARALELO A LINHA
(cons 72 1) ;JUSTIFICAΗΓO TEXTO HORIZONTAL - CENTER
(cons 73 2) ;JUSTIFICAΗΓO TEXTO VERTICAL - MIDDLE
)
)

(setvar "textsize" tsize)
(command "osmode" padroes)
(command "osmode" "37") ; ACRESCENTADO MΑRCIO - OSNAP END/INT/CEN
(princ)
)

danallen

  • Guest
Re: help with azimuth lisp
« Reply #3 on: November 16, 2016, 03:09:59 PM »
Can you fix this code

This is too generic of request for help. Someone has to recreate your environment and settings, then run the code and hope to find out why the code needs to be fixed. Please post specifics on the problem you're having and you might get a response.

Also did you look at the post Cab sent? It had a history of changes to the code that might have fixed your problem (whatever that is).

Dan

pedroantonio

  • Guest
Re: help with azimuth lisp
« Reply #4 on: November 16, 2016, 03:44:35 PM »
Yes i know and i am sorry. But i am not goo in lisp and i am  confiused with the grads and the clockwise . If you tell me what to change i will try it and with this way i will learn something

danallen

  • Guest
Re: help with azimuth lisp
« Reply #5 on: November 16, 2016, 04:45:39 PM »
please describe what happens when you run the lisp, and what the error is. If it helps, try copying & pasting the command history (put in code tags)

pedroantonio

  • Guest
Re: help with azimuth lisp
« Reply #6 on: November 16, 2016, 06:09:01 PM »
My unit settings are decimal , grads ,clock wise ,and direction noth and i use annotation texts.

this lisp gives the azimuth in degrees , i think is not clockwize , give the distanc in meters (thats ok) and the thext is not annotated

pedroantonio

  • Guest
Re: help with azimuth lisp
« Reply #7 on: November 17, 2016, 04:58:39 AM »
I did some changes to the code .

1) I change the rad to grad but the angle is in dregrees (i dont know why)  :?
2) the direction is clockwise 
3)I try to change the direction to north but i am not sure if is correct  :?
4)I add a layer
5)I add annotate text style (but is not working with the text , something is missing)

6) I want all the time this ti be Yes
Quote
(setq tsize (getvar "textsize"))
(initget "Y N")
(setq opt (getkword "\nIncluir Dados de Azimute? [Y/N] <N>: "))

I need some help

Thanks

Code - Auto/Visual Lisp: [Select]
  1. ;;; ROTINA PARA COTAR E OU AZIMUTAR POLYLINES - TEXTO NO DESENHO = 2.34 ou 2.34 - Az 23°15&#900;7"
  2. ;;; AS MEDIDAS APARECEM COMO FORAM DIGITADAS NO DESENHO (METROS, MIL&#925;METROS, ETC)
  3. ;;; A ALTURA DO TEXTO &#921; SOLICITADA NA EXECU&#919;&#915;O DA ROTINA E O STYLE &#921; O CORRENTE
  4. ;;; ACERTAR ALTURA DO TEXTO DE ACORDO COM A ESCALA DE PLOTAGEM. PARA DEIXAR EM DEFAULT USE O COMMAND: TEXTSIZE
  5. ;;; Forum www.autolisp.com.br - Nome da rotina original: AZPOL - Autor: Orlei 29/08/2006
  6. ;;; Adapta&#951;&#947;o: Rog&#953;rio Zanini e M&#945;rcio
  7. ;;;---------------------------------------------------------- ------------------------
  8.  
  9. (princ "\nDigite AZI para iniciar - Verificar TextStyle corrente")
  10. (defun C:AZI ()
  11. (command "undo" "begin"); Voltar de uma s&#963; vez toda a opera&#951;&#947;o da Rotina - ACRESCENTADO ROG&#921;RIO
  12. ;---------------Sub-functions - Start-------------
  13. (defun RTD ()
  14. (/ (* (angle A B) 200) Pi)
  15. )
  16. ;-------------------------------------------------
  17. (defun DTR (AZIMUTE)
  18. (* (/ AZIMUTE 200) Pi)
  19. )
  20. ;-------------------------------------------------
  21. (defun PARALELO ()
  22. (setq A1 (polar A (+ (/ pi 2)(angle B A )) (+ (* 0.15 htext)))) ;0.60 x ALTURA TEXTO = dist&#946;ncia do texto da Pline ;MODIFICA&#919;&#915;O ROG&#921;RIO
  23. (setq B1 (polar B (+ (/ pi 2)(angle B A )) (+ (* 0.15 htext)))) ;0.60 x ALTURA TEXTO = dist&#946;ncia do texto da Pline ;MODIFICA&#919;&#915;O ROG&#921;RIO
  24.  
  25. (setq ptx (/ (+ (car B1) (car A1)) 2))
  26. (setq pty (/ (+ (cadr B1) (cadr A1)) 2))
  27. (setq ponto_meio (list ptx pty))
  28. (if (< (car A1)(car B1))
  29. (setq inicio B1)
  30. (setq inicio A1)
  31. )
  32. )
  33. ;-------------------------------------------------
  34. (defun MUDAR ()
  35. (setq XL 2)
  36. (setq J "d")
  37. (setq COM1 (substr D 1 1))
  38. (while (< XL 5)
  39. (setq LETRAT (substr D XL 1))
  40. (setq RESTOT (substr D (+ 1 XL) ))
  41. (if (= LETRAT J)
  42. (progn (setq J "%%d")
  43. (setq XL 6)
  44. (setq PALAV (strcat COM1 J RESTOT))
  45. )
  46. )
  47. (setq COM1 (strcat COM1 LETRAT ))
  48. (setq XL (1+ XL))
  49. )
  50. )
  51. ;----------------Sub-functions - End -------------
  52. (setq tsize (getvar "textsize"))
  53. (initget "Y N")
  54. (setq opt (getkword "\nIncluir Dados de Azimute? [Y/N] <N>: "))
  55.  
  56. (setq htext 2.5)
  57. (COMMAND "_layer" "_m" "_AZIMUTH" "_c" "150" "" "")
  58. (command "_.-style" "_TopoCad" "arial.ttf" "_annotative" "_yes" "_no" 2.5 1.0 0.0 "_no" "_no" "_no")
  59. (setvar"cmdecho" 0)
  60. (command "osmode" 0)
  61. (command "angbase" 300)
  62. (command "angdir" 1)
  63. (setq flagv "falso")
  64. (setq controle 0)
  65. (setq controle1 0)
  66. (setq contador 0)
  67. (while (= flagv "falso")
  68. (setq mostre (entsel "\nSelecione a Polyline <2d> : "))
  69. (setq linha (entget (car mostre )))
  70. (setq verificador (cdr(assoc 0 linha)))
  71. (if (= verificador "LWPOLYLINE")
  72. (setq verif (cdr (assoc 70 linha)))
  73. (setq flagv "verdade")
  74. )
  75. (princ "\nN&#947;o &#953; Polyline !! ")
  76. )
  77. )
  78.  
  79. (setq controle1 (length linha))
  80. (setq amostra '())
  81. (repeat controle1
  82. (setq x (caar linha))
  83. (if (= x 10)
  84. (setq item (car linha))
  85. (setq amostra (cons item amostra))
  86. (setq contador (1+ contador))
  87. )
  88. )
  89. (setq linha (cdr linha))
  90. )
  91. (setq amostra1 (reverse amostra))
  92. (if (= verif 1)
  93. (setq amostra (cons (car amostra1) amostra))
  94. (setq contador (1- contador))
  95. )
  96. (setq controle contador)
  97. (repeat controle
  98. (setq PTO1 (cdr(car amostra)))
  99. (setq PTO2 (cdr(car(cdr amostra))))
  100. (AZIMUTAR)
  101. (setq amostra(cdr amostra))
  102. )
  103. (command "undo" "end")
  104. )
  105. (defun AZIMUTAR ()
  106. (setq padroes (getvar "osmode"))
  107. (setvar"cmdecho" 0)
  108. (command "osmode" 0)
  109. (setq A PTO1)
  110. (setq B PTO2)
  111. (setq C " - Az "); PREFIXO DO &#914;NGULO OU "m - Az " m=para metros OU mm=para mil&#957;metros
  112. (setq D (angtos (angle A B) 1 4)) ;UNIDADE/N°DE CASAS 1= Decimal degrees = 45.0000 / 4= N° CASAS = 270°0'0"
  113. (MUDAR)
  114. ;------------- MODIFICA&#919;&#915;O ROG&#921;RIO OP&#919;&#915;O AZIMUTE ----------------
  115. (setq E (Strcat(rtos (distance A B) 2 2)"m"))  ;PRIMEIRO 2= UNIDADE DECIMAL / SEGUNDO 2= N°DE CASAS
  116. (setq DADO E)
  117. (if (= opt "Y") (setq DADO (strcat E C PALAV)))
  118. ;---------------------------------------------------------- ------
  119. (PARALELO)
  120. ;;; (command "text" "J" "bC" ponto_meio htext inicio dado ) ;htext = ALTURA TEXTO ;MODIFICA&#919;&#915;O ROG&#921;RIO
  121. (cons 0 "TEXT")
  122. (cons 7 (getvar "textstyle")) ;STYLE DE TEXTO CORRENTE DO DESENHO
  123. ; (cons 8 "0") ;ATIVADO A COTA FICA NA LAYER "0" OU OUTRA INDICADA
  124. (cons 100 "AcDbText")
  125. (cons 10 ponto_meio)
  126. (cons 11 ponto_meio)
  127. (cons 40 htext) ;ALTURA DO TEXTO CORRENTE NO DESENHO
  128. (cons 1 dado)
  129. (cons 50 (angle ponto_meio inicio)) ;TEXTO PARALELO A LINHA
  130. (cons 72 1) ;JUSTIFICA&#919;&#915;O TEXTO HORIZONTAL - CENTER
  131. (cons 73 1) ;JUSTIFICA&#919;&#915;O TEXTO VERTICAL - MIDDLE
  132. )
  133. )
  134.  
  135. (setvar "textsize" tsize)
  136. (command "osmode" padroes)
  137. (command "osmode" "37") ; ACRESCENTADO M&#913;RCIO - OSNAP END/INT/CEN
  138. )
« Last Edit: November 17, 2016, 05:17:34 AM by Topographer »

pedroantonio

  • Guest
Re: help with azimuth lisp
« Reply #8 on: November 17, 2016, 09:40:15 AM »
I update the code but i have the same problems


1) I change the rad to grad but the angle is in dregrees (i dont know why)  :?
2) the direction is clockwise
3)I try to change the direction to north but i am not sure if is correct . I want to calculate the angle a  :?
4)I add a layer
5)I add annotate text style (but is not working with the text , something is missing). I want the paper text height to be 2.5  not the text height in model space

6) I want all the time this ti be Yes

Code - Auto/Visual Lisp: [Select]
  1. ;;; ROTINA PARA COTAR E OU AZIMUTAR POLYLINES - TEXTO NO DESENHO = 2.34 ou 2.34 - Az 23°15&#38;#900;7"
  2. ;;; AS MEDIDAS APARECEM COMO FORAM DIGITADAS NO DESENHO (METROS, MIL&#38;#925;METROS, ETC)
  3. ;;; A ALTURA DO TEXTO &#38;#921; SOLICITADA NA EXECU&#38;#919;&#38;#915;O DA ROTINA E O STYLE &#38;#921; O CORRENTE
  4. ;;; ACERTAR ALTURA DO TEXTO DE ACORDO COM A ESCALA DE PLOTAGEM. PARA DEIXAR EM DEFAULT USE O COMMAND: TEXTSIZE
  5. ;;; Forum www.autolisp.com.br - Nome da rotina original: AZPOL - Autor: Orlei 29/08/2006
  6. ;;; Adapta&#38;#951;&#38;#947;o: Rog&#38;#953;rio Zanini e M&#38;#945;rcio
  7. ;;;---------------------------------------------------------- ------------------------
  8.  
  9. (defun C:AZI ()
  10. (command "undo" "begin")
  11. ;---------------Sub-functions - Start-------------
  12. (defun Radtograds ()
  13. (/ (* (angle A B) 200) Pi)
  14. )
  15. ;-------------------------------------------------
  16. (defun Gradstorad (AZIMUTE)
  17. (* (/ AZIMUTE 200) Pi)
  18. )
  19. ;-------------------------------------------------
  20. (defun PARALELO ()
  21. (setq A1 (polar A (+ (/ pi 2)(angle B A )) (+ (* 0.15 htext))))
  22. (setq B1 (polar B (+ (/ pi 2)(angle B A )) (+ (* 0.15 htext))))
  23. (setq ptx (/ (+ (car B1) (car A1)) 2))
  24. (setq pty (/ (+ (cadr B1) (cadr A1)) 2))
  25. (setq ponto_meio (list ptx pty))
  26. (if (< (car A1)(car B1))
  27. (setq inicio B1)
  28. (setq inicio A1)
  29. )
  30. )
  31. ;-------------------------------------------------
  32. (defun MUDAR ()
  33. (setq XL 2)
  34. (setq J "d")
  35. (setq COM1 (substr D 1 1))
  36. (while (< XL 5)
  37. (setq LETRAT (substr D XL 1))
  38. (setq RESTOT (substr D (+ 1 XL) ))
  39. (if (= LETRAT J)
  40. (progn (setq J "%%d")
  41. (setq XL 6)
  42. (setq PALAV (strcat COM1 J RESTOT))
  43. )
  44. )
  45. (setq COM1 (strcat COM1 LETRAT ))
  46. (setq XL (1+ XL))
  47. )
  48. )
  49. ;----------------Sub-functions - End -------------
  50. (setq tsize (getvar "textsize"))
  51. (setq htext 2.5)
  52. (COMMAND "_layer" "_m" "_AZIMUTH" "_c" "150" "" "")
  53. (command "_.-style" "_TopoCad" "arial.ttf" "_annotative" "_yes" "_no" 2.5 1.0 0.0 "_no" "_no" "_no")
  54. (setvar"cmdecho" 0)
  55. (command "osmode" 0)
  56. (command "angbase" 300)
  57. (command "angdir" 1)
  58. (setq flagv "falso")
  59. (setq controle 0)
  60. (setq controle1 0)
  61. (setq contador 0)
  62. (while (= flagv "falso")
  63. (setq mostre (entsel "\nSelecione a Polyline <2d> : "))
  64. (setq linha (entget (car mostre )))
  65. (setq verificador (cdr(assoc 0 linha)))
  66. (if (= verificador "LWPOLYLINE")
  67. (setq verif (cdr (assoc 70 linha)))
  68. (setq flagv "verdade")
  69. )
  70. (princ "\nN&#38;#947;o &#38;#953; Polyline !! ")
  71. )
  72. )
  73. (setq controle1 (length linha))
  74. (setq amostra '())
  75. (repeat controle1
  76. (setq x (caar linha))
  77. (if (= x 10)
  78. (setq item (car linha))
  79. (setq amostra (cons item amostra))
  80. (setq contador (1+ contador))
  81. )
  82. )
  83. (setq linha (cdr linha))
  84. )
  85. (setq amostra1 (reverse amostra))
  86. (if (= verif 1)
  87. (setq amostra (cons (car amostra1) amostra))
  88. (setq contador (1- contador))
  89. )
  90. (setq controle contador)
  91. (repeat controle
  92. (setq PTO1 (cdr(car amostra)))
  93. (setq PTO2 (cdr(car(cdr amostra))))
  94. (AZIMUTAR)
  95. (setq amostra(cdr amostra))
  96. )
  97. (command "undo" "end")
  98. )
  99. (defun AZIMUTAR ()
  100. (setq padroes (getvar "osmode"))
  101. (setvar"cmdecho" 0)
  102. (command "osmode" 0)
  103. (setq A PTO1)
  104. (setq B PTO2)
  105. (setq C " - Az ")
  106. (setq D (angtos (angle A B) 1 4))
  107. (MUDAR)
  108. ;------------- MODIFICA&#38;#919;&#38;#915;O ROG&#38;#921;RIO OP&#38;#919;&#38;#915;O AZIMUTE ----------------
  109. (setq E (Strcat(rtos (distance A B) 2 2)"m"))  
  110. (setq DADO (strcat E C PALAV))
  111. ;---------------------------------------------------------- ------
  112. (PARALELO)
  113. (cons 0 "TEXT")
  114. (cons 7 (getvar "textstyle")) ;STYLE DE TEXTO CORRENTE DO DESENHO
  115. (cons 100 "AcDbText")
  116. (cons 10 ponto_meio)
  117. (cons 11 ponto_meio)
  118. (cons 40 htext) ;ALTURA DO TEXTO CORRENTE NO DESENHO
  119. (cons 1 dado)
  120. (cons 50 (angle ponto_meio inicio)) ;TEXTO PARALELO A LINHA
  121. (cons 72 1) ;JUSTIFICA&#38;#919;&#38;#915;O TEXTO HORIZONTAL - CENTER
  122. (cons 73 1) ;JUSTIFICA&#38;#919;&#38;#915;O TEXTO VERTICAL - MIDDLE
  123. )
  124. )
  125. (setvar "textsize" tsize)
  126. (command "osmode" padroes)
  127. (command "osmode" "37") ; ACRESCENTADO M&#38;#913;RCIO - OSNAP END/INT/CEN
  128. )
  129.  
« Last Edit: November 18, 2016, 08:34:39 AM by Topographer »

pedroantonio

  • Guest
Re: help with azimuth lisp
« Reply #9 on: November 17, 2016, 10:26:05 AM »
Any ideas?  :-o

rw2691

  • Newt
  • Posts: 133
Re: help with azimuth lisp
« Reply #10 on: November 17, 2016, 02:55:11 PM »
CAD wants to provide data as RADS and UNITS. Angles (as RADS) are referenced horizontally to the right, and turn counter-clockwise. UNITS are what you set them to be... feet, meters, etc.

You can change UNITS to supply clock-wise RADS, but I prefer to translate the CAD standard to what I want. It's simple math to rotate the angle to a vertical reference (as north), and to translate counter-clockwise to clockwise. The same with changing RADS to anything... degrees or grads. Likewise you can make inches, feet, or meters for distances. Once you have made the translations you convert them to a text string for display.

The trick is to not be overly fancy with it all. Just build simple functions that get it done. All the fancy stuff is performed separately on a need basis.

Rick
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

pedroantonio

  • Guest
Re: help with azimuth lisp
« Reply #11 on: November 17, 2016, 03:26:29 PM »
hi rw2691 can you help me with the code ?

rw2691

  • Newt
  • Posts: 133
Re: help with azimuth lisp
« Reply #12 on: November 18, 2016, 08:16:29 AM »
try using (command "-STYLE" ...) or (command "-TEXT" ...) instead of "_.-STYLE"

I don't see that you are using Radtograds or Gradstorad in your code.
Hippocrates (400BC), "Life is short, craft long, opportunity fleeting, experiment treacherous, judgment difficult."

pedroantonio

  • Guest
Re: help with azimuth lisp
« Reply #13 on: November 18, 2016, 08:47:14 AM »
Quote
try using (command "-STYLE" ...) or (command "-TEXT" ...) instead of "_.-STYLE"

I try it but nothing

didier

  • Newt
  • Posts: 48
  • expatrié
Re: help with azimuth lisp
« Reply #14 on: November 19, 2016, 07:47:59 AM »
Coucou

What is the expected result ?
Should we reproduce the result of the image?
eternal beginner ...
my english is not fluent ...