Jump to content

Insert coordinate text always on the same side and at the same angle as the alignment parameter


Recommended Posts

Posted

Hello guys,
Any way to insert coordinate text always on the same side and at the same angle as the alignment parameter of a block?

and my text can not be turned upside down?

I'll attach an example for better viewing !!

 

Example2.dwg

Posted

Hi,

Give this a shot and let me know. :) 

(defun c:Test (/ text_ inc int sel ent get ins rot ang ctr)
  ;; Tharwat - 02.Dec.2018	;;
  (defun text_ (ins str rot clr lay)
    (entmake
      (list '(0 . "TEXT")
            (cons 8 lay)
            (cons 62 clr)
            (cons 10 ins)
            '(40 . 1.1543)
            (cons 1 str)
            (cons 50
                  (if (and (> rot (* pi 0.5)) (< rot (* pi 1.5)))
                    (+ rot pi)
                    rot
                  )
            )
            '(41 . 1.0)
            '(71 . 0)
            '(72 . 1)
            (cons 11 ins)
            '(73 . 2)
      )
    )
  )
  (if (setq inc 0
            int -1
            sel (ssget '((0 . "INSERT")))
      )
    (while (setq ent (ssname sel (setq int (1+ int))))
      (setq get (entget ent)
            ins (cdr (assoc 10 get))
            rot (cdr (assoc 50 get))
            ang (+ rot (* pi 1.5))
            inc (1+ inc)
      )
      (mapcar 'text_
              (list (polar ins ang 1.97715)
                    (polar ins ang 3.96145)
                    (setq ctr (polar ins ang 7.0083))
              )
              (list (strcat "X:" (rtos (car ins) 2 2))
                    (strcat "Y:" (rtos (cadr ins) 2 2))
                    (if (< inc 10)
                      (strcat "0" (itoa inc))
                      (itoa inc)
                    )
              )
              (list rot rot rot)
              '(2 2 1)
              '("Coordenada" "Coordenada" "N_Postes")
      )
      (entmake (list '(0 . "CIRCLE")
                     '(8 . "N_Postes")
                     (cons 10 ctr)
                     '(62 . 1)
                     '(40 . 1.5)
               )
      )
    )
  )
  (princ)
)

 

  • Thanks 1
Posted
33 minutes ago, JuniorNogueira said:

@Tharwat

Thank you very much, it worked very well !!!!

You're welcome anytime. 

  • Like 1
Posted
29 minutes ago, JuniorNogueira said:

@Tharwat  Why is not the coordinate coming out of the parameter side?

Drawing3.dwg

Because the rotation of the block that you posted in the first reply is different than the one into this drawing. ;) 

So just replace the following from the above posted codes:

ang (cdr (assoc 50 get))
rot (+ ang (* pi 0.5))

 

  • Thanks 1

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...