Jump to content

Recommended Posts

Posted

In red, the way my lisp does, in blue, the way i want the text, in yellow, the baseline of the rotation. How can i fix this?

 

http://picasaweb.google.com.br/lh/photo/w65MxseLptWKSFq_ORaw2g?feat=directlink

 

Code below

 

(defun c:cc (/ ent obj r l c center p1 p2 p3 p4 p5  lb obj2 ro rot)
 (vl-load-com)
 (if (setq ent (entsel "\nSelecione o ARCO: "))
   (progn
     (setq obj (vlax-ename->vla-object (car ent)))
     (setq r (vla-get-radius obj)
    l (vla-get-arclength obj)
    c (vla-get-center obj)
    )
     (setq center (vlax-safearray->list
      (vlax-variant-value c)))
     )
   )
 (setq p1 (getpoint "\nSelecione ponto de inserção para o texto: "))
 (setq lb (entsel "\nSelecione Linha de alinhamento de texto: "))
 (setq obj2 (vlax-ename->vla-object (car lb)))
 (setq ro (vla-get-angle obj2)
)
 (setq rot (/ (* 180 ro) (* 2 pi))) 

 (setq p2 (polar p1 rot 2.5))
(setq p3 (polar p2 rot 2.5))
 (setq p4 (polar p3 rot 2.5))
 (setq p5 (polar p4 rot 2.5))



     (setq p6 (list (+(car p1)20) (cadr p1)))
   (entmake
     (list
(cons 0 "TEXT")
(cons 1  "CC")
(cons 72 2)
(cons 73 3)
(cons 50 ro)
(cons 40 2.0)
(cons 10 p1)
(cons 11 p1))
     )
   (entmake
     (list
(cons 0 "TEXT")
(cons 1 (strcat "N= " (rtos (car center) 2 3)))
(cons 72 2)
(cons 73 3)
(cons 40 2.0)
(cons 50 ro)
(cons 10 p2)
(cons 11 p2))
     )
   (entmake
     (list
(cons 0 "TEXT")
(cons 1 (strcat "E= " (rtos (cadr center) 2 3)))
(cons 72 2)
(cons 73 3)
(cons 40 2.0)
(cons 50 ro)
(cons 10 p3)
(cons 11 p3))
     )
   (entmake
     (list
(cons 0 "TEXT")
(cons 1 (strcat "R= " (rtos r)))
(cons 72 2)
(cons 73 3)
(cons 40 2.0)
(cons 50 ro)
(cons 10 p4)
(cons 11 p4))
     )
   (entmake
     (list
(cons 0 "TEXT")
(cons 1 (strcat "D= " (rtos l 2 3)))
(cons 72 2)
(cons 73 3)
(cons 40 2.0)
(cons 50 ro)
(cons 10 p5)
(cons 11 p5))
)(princ)
 )

 

I'll enjoy any help. Many thanks!!

Posted
In red, the way my lisp does, in blue, the way i want the text, in yellow, the baseline of the rotation. How can i fix it?

Tested slightly, pick text points under the line only

(defun c:cc (/ ang c center ent la lb obj obj2 p1 p2 p3 p4 p5 pp r rot)
 (vl-load-com)

 (if (setq ent (entsel "\nSelecione o ARCO: "))
  (progn
     (setq obj (vlax-ename->vla-object (car ent)))
     (setq r (vla-get-radius obj)
    la (vla-get-arclength obj)
    c (vla-get-center obj)
    )
     (setq center (vlax-safearray->list
      (vlax-variant-value c)))
     )
   )
 (setq p1 (getpoint "\nSelecione ponto de insercao para o texto: "))
 (setq lb (entsel "\nSelecione Linha de alinhamento de texto: "))
 (setq obj2 (vlax-ename->vla-object (car lb)))
 (setq pp (vlax-curve-getclosestpointto obj2 p1))

(setq ang (angle p1 pp)
      rot (+ ang (/ pi 2))
      ang (+ pi ang)

 )

(if (and (> rot (* 0.5 pi))
 (< rot (* 1.5 pi))
 )
    (setq rot (+ rot pi))
   )

 (setq p2 (polar p1 ang 2.5))
 (setq p3  (polar p2 ang 2.5))
 (setq p4 (polar p3 ang 2.5))
 (setq p5 (polar p4 ang 2.5))
;;set all text alignment to left:
   (entmake
     (list
(cons 0 "TEXT")
(cons 1  "CC")
(cons 71 0)
(cons 72 0)
(cons 73 0)
(cons 50 rot)
(cons 40 2.0)
(cons 10 p1)
(cons 11 (list 0 0 0))
     )
     )
   (entmake
     (list
(cons 0 "TEXT")
(cons 1 (strcat "N= " (rtos (car center) 2 3)))
(cons 71 0)
(cons 72 0)
(cons 73 0)
(cons 40 2.0)
(cons 50 rot)
(cons 10 p2)
(cons 11 (list 0 0 0)))
     )
   (entmake
     (list
(cons 0 "TEXT")
(cons 1 (strcat "E= " (rtos (cadr center) 2 3)))
(cons 71 0)
(cons 72 0)
(cons 73 0)
(cons 40 2.0)
(cons 50 rot)
(cons 10 p3)
(cons 11 (list 0 0 0)))
     )
   (entmake
     (list
(cons 0 "TEXT")
(cons 1 (strcat "R= " (rtos r)))
(cons 71 0)
(cons 72 0)
(cons 73 0)
(cons 40 2.0)
(cons 50 rot)
(cons 10 p4)
(cons 11 (list 0 0 0)))
     )
   (entmake
     (list
(cons 0 "TEXT")
(cons 1 (strcat "D= " (rtos la 2 3)))
(cons 71 0)
(cons 72 0)
(cons 73 0)
(cons 40 2.0)
(cons 50 rot)
(cons 10 p5)
(cons 11 (list 0 0 0)))
)
 (princ)
 )

 

HTH

 

~'J'~

Posted

Work's fine under the line. Can you explain me what do you do?

Posted
Work's fine under the line. Can you explain me what do you do?

 

I calculate angle 'ang' from point of insertion of the text

to line concerning which the text will be aligned iow, perpendicular angle

The rotation angle of text 'rot' in radians will be less than angle 'ang' on value (/pi 2)

Depending on line arrangement on plane this angle can be in interval

from > 90 to

That's all

 

~'J'~

Posted

Understood. I'm soo happy, many thanks man!

I spend half a day trying to fix it.

 

Many thanks fixo.

Posted
Understood. I'm soo happy, many thanks man!

I spend half a day trying to fix it.

 

Many thanks fixo.

 

Glad it helps

Cheers :)

 

~'J'~

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...