Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Change size/position label - z-value lisp

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
infoH8EQN
625 Views, 7 Replies

Change size/position label - z-value lisp

Hi,

 

I would like to change the size and position of the label on this lisp.

 

Someone can help me, please?

 

Many Thanks

 

Size: 150

Postition: top-center from the point

 

(defun c:zpt ( / i p s )
   (if (setq s (ssget '((0 . "POINT"))))
       (repeat (setq i (sslength s))
           (setq p (assoc 10 (entget (ssname s (setq i (1- i))))))
           (entmake
               (list
                  '(000 . "MTEXT")
                  '(100 . "AcDbEntity")
                  '(100 . "AcDbMText")
                   (cons 1 (strcat "Z = " (rtos (cadddr p))))
                   p
                )
            )
       )
   )
   (princ)

)

 

 

pt.PNG

7 REPLIES 7
Message 2 of 8
ВeekeeCZ
in reply to: infoH8EQN

HERE are codes you need.

Message 3 of 8
infoH8EQN
in reply to: ВeekeeCZ

thanks for this. 

 

I add top-center + text height + conversion in meter.

 

I have a problem with moving up by 210mm

the label. Should be the insertion point (code 20?) but doesn't work.

 

(defun c:zpt ( / i p s )
   (if (setq s (ssget '((0 . "POINT"))))
       (repeat (setq i (sslength s))
           (setq p (assoc 10 (entget (ssname s (setq i (1- i))))))
           (entmake
               (list
                  '(000 . "MTEXT")
                  '(100 . "AcDbEntity")
                  '(100 . "AcDbMText")
				
				  '(40 . 140)
				  
				  '(71 . 2)
				  
				  
				  
                   (cons 1 (strcat  (rtos (/ (cadddr p) 1000.))))
                   p
                )
            )
       )
   )
   (princ)

)

 

This is what I get. In red what it should do. 

 

 

test2.PNG

 

 

Message 4 of 8
ВeekeeCZ
in reply to: infoH8EQN

No, you will have to move the entire text. Use POLAR. 

Why MTEXT, why top-middle?

 

I would prefer this

BeekeeCZ_0-1648114476243.png

 

 

Message 5 of 8
infoH8EQN
in reply to: ВeekeeCZ

Thanks. I found this Lisp in a forum, and it works very well but needed customization. My knowledge of the LISP language is limited, so I'm not sure how to implement a POLAR move.   

 

Regard Mtext... It was Mtext on the original lisp. I don't know the reason for that.

 

Regard Top-Middle... because the final result should be similar to this:

 

pt.PNG

 

Message 6 of 8
ВeekeeCZ
in reply to: infoH8EQN

How does that differ from the screenshot I have posted?

Message 7 of 8
infoH8EQN
in reply to: ВeekeeCZ

Your screenshot is perfect. I need help implementing it in Lisp. My attempt to implement the Polar Move function in Lisp failed. The syntax is incorrect.  

 

(defun c:zpt ( / i p s )
   (if (setq s (ssget '((0 . "POINT"))))
       (repeat (setq i (sslength s))
           (setq p (assoc 10 (entget (ssname s (setq i (1- i))))))
           (entmake
               (list
                  '(000 . "MTEXT")
                  '(100 . "AcDbEntity")
                  '(100 . "AcDbMText")
				  '(40 . 140)
				  '(71 . 2)
                   (cons 1 (strcat  (rtos (/ (cadddr p) 1000.))))
				   (command "._move" s "" "0,0,0" "@150<90")
                   p
                )
            )
       )
   )
   (princ)

)
Message 8 of 8
ВeekeeCZ
in reply to: infoH8EQN

The move is a bad idea.

Version for your mtext which dose not make much sense to me and my text version.

 

(defun c:zpt-mtext ( / i p s )
  (if (setq s (ssget '((0 . "POINT"))))
    (repeat (setq i (sslength s))
      (setq p (assoc 10 (entget (ssname s (setq i (1- i))))))
      (entmake (list
		 '(000 . "MTEXT")
		 '(100 . "AcDbEntity")
		 '(100 . "AcDbMText")
		 '(40 . 140)
		 '(71 . 2)
		 (cons 1 (strcat  (rtos (/ (cadddr p) 1000.) 2 2)))
		 (cons 10 (polar (cdr p) (/ pi 2) 210.))
		 )
	       )
      )
    )
  (princ)
  )

(defun c:zpt-text ( / i p s )
  (if (setq s (ssget '((0 . "POINT"))))
    (repeat (setq i (sslength s))
      (setq p (cdr (assoc 10 (entget (ssname s (setq i (1- i)))))))
      (entmake (list
		 (cons 0 "TEXT")
		 (cons 10 p)
		 (cons 11 p)
		 (cons 40 140)
		 '(72 . 1)
		 '(73 . 1)
		 (cons 1 (strcat  (rtos (/ (caddr p) 1000.) 2 2)))))))
  (princ)
  )

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report