Hi guys am new to this site
I need to know how to set gap between line and text by lisp and also i attached reference file plz give ur idea to do that........Thank You
text size 2.72
need gap 1.38
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
TEXTMASK has an Offset option, in which you can specify that distance as a proportion of the Text height.
Welcome to the Forums, by the way! The code below, as a bare-bones starting point, seems to work in limited testing for orthogonally-oriented Text [with rotation angles of 0 or multiples of 90 degrees] such as your example, with selection of the Line [or other Trimmable object] inside the extent of the Text.
If it does what you want, as far as it goes, it can be enhanced/expanded to do any of these things that you might want:
Restrict object selection to an actual Text object and something Trimmable;
Proceed only if appropriate things are selected for both;
Work as expected with non-orthogonal Text;
Work with Mtext and/or Attribute definitions as well as plain Text;
Offer the option to specify the gap as a proportion of the Text height, rather than an absolute value;
Suppress command echoing so you don't "see" the Rectangle and Trim and Erase commands going by on the Command: prompt line;
Remember your gap value and offer it as a default on subsequent use;
Allow Trimming of more than one object "behind" the same Text object;
Allow selection of the object(s) to be trimmed at location(s) outside the Text;
Put it all in an overall Undo begin/end wrapper, so that U afterwards will back up through all of it at once, instead of in several steps;
Probably a few other little things.
(defun C:TEXTGAP (/ txt lin gap minpt maxpt box cut)
(setq
txt (car (entsel "\nSelect Text object: "))
lin (entsel "\nSelect Line or other object to Trim, within extent of Text: ")
gap (getdist "\nGap distance between Text and end of trimmed object: ")
); setq
(vla-getboundingbox (vlax-ename->vla-object txt) 'minpt 'maxpt)
(command "_.rectang" "_none" (vlax-safearray->list minpt) "_none" (vlax-safearray->list maxpt))
(setq box (entlast))
(vla-offset (vlax-ename->vla-object box) gap)
(setq cut (entlast))
(command "_.trim" cut "" (cadr lin) "" "_.erase" box cut "")
); defun
Its ll really going to increase my workflow and very happy to say thank u so much for ur help..........
Alwys keep in touch thank u once again bro...!!
@377-83869076 wrote:
hi kent i hav problem on abv given code was work perfectly in 2008 but in 2011 autocad said
Gap distance between Text and end of trimmed object: 1.38
; error: no function definition: VLAX-ENAME->VLA-OBJECT
so please find solution for what happened here...
Thank U
Try doing
(vl-load-com)
first. Maybe there was something in your 2008 setup that did that for you, and not in your 2011 setup.
@377-83869076 wrote:
hi kent i hav problem on abv given code was work perfectly in 2008 but in 2011 autocad said
Gap distance between Text and end of trimmed object: 1.38
; error: no function definition: VLAX-ENAME->VLA-OBJECT
so please find solution for what happened here...
Thank U
Please add (vl-load-com) as the last line of the code
..... (command "_.trim" cut "" (cadr lin) "" "_.erase" box cut "")
); defun
(vl-load-com);<----right there
EDIT: oops, did not see Kents' post there....
@377-83869076 wrote:
It's work thx kent
You're welcome. Something in the setup here runs that for me automatically, so I never need to include it in code when I test things, and I often forget that many people need to have that added. The more reminders I get, the more likely it is that I'll remember the next time....
Regarding "Mark as solution", back at you Kent
@Kent1Cooper wrote:
You're welcome, but I couldn't take all the Accept-As-Solution credit for it, since I just tweaked Kents code <added one line really>. So I have marked the original routine message also as [at least a part of] the Solution [we Expert Elites wield the awesome power to do that, even in threads we didn't initiate].