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

Maintain space between line and text

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
377-83869076
596 Views, 9 Replies

Maintain space between line and text

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

 

text size 2.72

need gap 1.38

9 REPLIES 9
Message 2 of 10
Kent1Cooper
in reply to: 377-83869076

TEXTMASK has an Offset option, in which you can specify that distance as a proportion of the Text height.

Kent Cooper, AIA
Message 3 of 10
Kent1Cooper
in reply to: 377-83869076

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

Kent Cooper, AIA
Message 4 of 10
377-83869076
in reply to: Kent1Cooper

Its ll really going to increase my workflow and very happy to say thank u so much for ur help..........Smiley Happy

 

Alwys keep in touch thank u once again bro...!!Smiley Very Happy

Message 5 of 10
377-83869076
in reply to: Kent1Cooper

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
Message 6 of 10
Kent1Cooper
in reply to: 377-83869076


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

Kent Cooper, AIA
Message 7 of 10
pbejse
in reply to: 377-83869076


@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.... Smiley Happy 

Message 8 of 10
377-83869076
in reply to: 377-83869076

It's work thx kent
Message 9 of 10
Kent1Cooper
in reply to: 377-83869076


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

Kent Cooper, AIA
Message 10 of 10
pbejse
in reply to: Kent1Cooper

 

Regarding "Mark as solution", back at you Kent Smiley Happy 

 


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


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

Post to forums  

Autodesk Design & Make Report

”Boost