Author Topic: Insert text to center  (Read 1390 times)

0 Members and 1 Guest are viewing this topic.

carmi

  • Newt
  • Posts: 27
Insert text to center
« on: July 09, 2021, 06:21:18 AM »
Hi all,
i want to change this lisp and insert text at center.
I think i have to change text alignment to center but im not able.
Can you help me?
thank you very much

Code: [Select]
(defun C:AP2 ( / a e1 ar ptx Text)
(print)
(setq a (getpoint "\nSelect Internal Point: "))
(command "-Boundary" a "")
(setq e1 (entlast))
(command "_pedit" e1 "_C" "")
(setq ar (vlax-curve-getarea e1))
(command "-ERASE" e1 "")
(setq ptx (getpoint "\n select point "))
(setq Text (strcat "s.n. = " (rtos ar 2 2) " mq"))
(command "-text" ptx "0.15" "0" Text)
)
(vl-load-com) (princ)

zak26

  • Newt
  • Posts: 33
Re: Insert text to center
« Reply #1 on: July 09, 2021, 10:29:10 AM »
Maybe like this.
Code: [Select]
(defun C:AP2 ( / a e1 ar ptx Text)
   (vl-load-com)
   (setvar "cmdecho" 0)
   (command "_undo" "_begin")
   (print)
   (setq a (getpoint "\nSelect an Internal Point: "))
   (command "_.Boundary" a "")
   (setq e1 (entlast))
;;;   (command "_.pedit" e1 "_C" "") ;;; I donīt think you need this
   (setq ar (vlax-curve-getarea e1))
   (command "_.ERASE" e1 "")
   (setq ptx (getpoint "\n select point "))
   (setq Text (strcat "s.n. = " (rtos ar 2 2) " mq"))
   (command "_.text" "j" "mc" ptx "0.15" "0" Text)
   (command "_undo" "_end")
   (princ)
)

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: Insert text to center
« Reply #2 on: July 10, 2021, 08:42:03 PM »
There is a geom centre snap

Code: [Select]
(setq obj (vlax-ename->vla-object (entlast))) ; do after bpoly or boundary
(setq ptx (osnap (vlax-curve-getStartPoint obj) "gcen"))
A man who never made a mistake never made anything

carmi

  • Newt
  • Posts: 27
Re: Insert text to center
« Reply #3 on: July 13, 2021, 03:17:27 AM »
thank to all,
i simply add this line:

Code: [Select]
(command "_.text" "j" "mc" ptx "0.15" "0" Text)
Now, how can change the text who insert, in a new layer named "Text_area" with yellow color?

Thank you very much

zak26

  • Newt
  • Posts: 33
Re: Insert text to center
« Reply #4 on: July 13, 2021, 10:26:06 AM »
Insert this line before you make the text
Code: [Select]
(command "_.layer" "n" "Text_area" "c" "2" "Text_area" "l" "Continuous" "Text_area" "s" "Text_area" "")