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

Insert text string inside a line

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
147 Views, 3 Replies

Insert text string inside a line

Hello friends
I used to have a simple routine to insert a text string inside a line and it brakes line on both sides from the text. I lost it and now need it on my new task.
Could you share it, hope somebody have it/
it looks like ----xxxx--- ,or insert text on the top of line with distance depending of scale.
thanks in advance
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Hi
Give that a try

~'J'~

[code]
(defun C:il (/ ang dis ent gap hgt ll ln lnobj maxp minp
osm p1 p2 pt ss txt txtobj ur)
(setq osm (getvar "osmode"))
(setvar "cmdecho" 0)
(vl-load-com)
(setq txt (getstring T "\n Enter text: ")
hgt (getreal "\n Enter text height: ")
)
(setq gap (/ hgt 2))
(setvar "osmode" 512)
(while (setq pt (getpoint "\n Specify the text insertion point (Enter to Exit): "))
(setq ss (ssget "C" pt pt (list (cons 0 "LINE"))))
(if (= 1 (sslength ss))
(progn
(setq lnobj (vlax-ename->vla-object (setq ln (ssname ss 0)))
ang (vla-get-angle lnobj)
)
(if (and (> ang (* 0.5 pi))
(< ang (* 1.5 pi)))
(setq ang (+ ang pi))
)
(setq ent (entmakex
(list
(cons 0 "TEXT")
(cons 100 "AcDbSymbolTableRecord")
(cons 100 "AcDbTextTableRecord")
(cons 1 txt);text string
(cons 7 "Standard");text style
(cons 8 "0")
(cons 10 pt)
(cons 11 pt)
(cons 40 hgt);text height
(cons 41 0.8);text width
(cons 50 0.0);horizontal
(cons 51 0.0);oblique angle
(cons 71 0); alignment flag
(cons 72 1); alignment flag
(cons 73 2)))); alignment flag
(setq txtobj (vlax-ename->vla-object ent))
(vla-getboundingbox txtobj 'minp 'maxp)
(setq ll (vlax-safearray->list minp)
ur (vlax-safearray->list maxp)
dis (+ (/ (abs (- (car ll)(car ur))) 2)(/ (getvar "dimtxt") 2))
)
(setq p1 (polar pt ang dis)
p2 (polar pt (+ ang pi) dis)
)
(setvar "osmode" 0)
(command "_.break" ln p1 p2)
(setvar "osmode" 512)
(vla-put-rotation txtobj ang)
)
)
)
(setvar "cmdecho" 1)
(setvar "osmode" osm)
(princ)
)
(princ "\n *** Start command with IL ")
(princ)
[/code]
Message 3 of 4
Anonymous
in reply to: Anonymous

Good morning Fatty,
Thank you very much.
It works good, even more.
Simple and nice.
Thank you again
Regards
Message 4 of 4
Anonymous
in reply to: Anonymous

Glad if that helps
Cheers 🙂

~'J'~

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

Post to forums  

Autodesk Design & Make Report

”Boost