Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Member
caseys
Posts: 4
Registered: ‎07-10-2009
Message 1 of 11 (787 Views)

Text under dimension line

787 Views, 10 Replies
12-07-2009 04:53 AM
I had a lisp routine called "dlt.lsp" that would place text under the dimension line selected. Dummy me had to uninstall and reinstall my AutoCAD 2010 and deleted my saved lisp routines. Has any one ever heard of this routine and if so do you know where I can get it again?

Thanks in advance.

Casey
Distinguished Contributor
rogerio_brazil
Posts: 927
Registered: ‎08-20-2004
Message 2 of 11 (787 Views)

Re: Text under dimension line

12-07-2009 07:02 AM in reply to: caseys
An alternative. If you don't get it again.

Use "\X" to write text under dimension line.

See the folowing link:

http://www.spaug.org/Tip_Month02.Html
April's Tip of the Month
Classic Dimensioning Tip

Rogerio :smileyhappy:
Distinguished Contributor
cab2k
Posts: 463
Registered: ‎12-15-2003
Message 3 of 11 (787 Views)

Re: Text under dimension line

12-07-2009 07:24 AM in reply to: caseys
Here is an old one from me.
{code};; CAB 07.27.2005
(defun c:txt2dim (/ edim text etxt vla_dim)
(vl-load-com)
(while (or (initget 1)
(not (setq edim (entsel "\nSelect dimension: ")))
(/= (cdr (assoc 0 (entget (car edim)))) "DIMENSION")
)
(prompt "\n*** You must select a dimension. ***")
)
(while
(and (not (and (setq etxt (entsel "\nSelect text to add to override or enter to type: "))
(= (cdr (assoc 0 (entget (car etxt)))) "TEXT")
)
)
(or (initget 1)
(not (setq text (getstring t "\nType the text or ENTER to clear override: ")))
)
)
)
(if etxt
(setq text (vla-get-textstring (vlax-ename->vla-object (car etxt))))
)
(setq vla_dim (vlax-ename->vla-object (car edim)))
(cond
((and text (/= text ""))
(vla-put-textoverride vla_dim (strcat "<>\\X" text))
)
((and text (= text "")) ; clear the override
(vla-put-textoverride vla_dim text)
)
)
(princ)
){code}
*Expert Elite*
Kent1Cooper
Posts: 5,418
Registered: ‎09-13-2004
Message 4 of 11 (787 Views)

Re: Text under dimension line

12-07-2009 08:56 AM in reply to: caseys
It's not quite clear to me whether the OP is looking for an under-the-line *replacement* for existing dimension text content [which your routine seems to do if they don't choose to clear the override, though I didn't study it very deeply], or perhaps an *added* piece of text below, with existing dimension text to remain. If the latter, there are different possibilities.

If the existing text is the actual measurement, there could be an option built into a routine like this that would use:

(strcat "<>\\X" text)

as the text override.

And assuming the problem with angle brackets on the website interface hasn't changed, that code line should be:

(strcat "less-than-symbol greater-than-symbol \\X" text)

The less-than and greater-than symbols [angle brackets] stand for the actual measurement [in current units], when you want to add a prefix and/or suffix with a text override.

Or if there might already be an override, and they want to leave that and add something below, there could be an option that saves the current text and then imposes something like:

(strcat currenttext "\\X" text)

If they want to keep *whatever* is there, regardless of whether it's default or overridden, and add something below, it could do something like:

{code}
....
(setq currenttext (vla-get-textoverride vla_dim))
(if (= currenttext ""); for default measurement
(setq currenttext "less-than-symbol greater-than-symbol")
;;...[but actually use angle brackets]...
); end if
(vla-put-textoverride vla_dim (strcat currenttext "\\X" text))
....
{code}

--
Kent Cooper
Kent Cooper
Distinguished Contributor
cab2k
Posts: 463
Registered: ‎12-15-2003
Message 5 of 11 (787 Views)

Re: Text under dimension line

12-07-2009 10:23 AM in reply to: caseys
I was unaware of the format problem.
see revised here (Thanks Kent)
{code};; CAB 07.27.2005
(defun c:txt2dim (/ edim text etxt vla_dim)
(vl-load-com)
(while (or (initget 1)
(not (setq edim (entsel "\nSelect dimension: ")))
(/= (cdr (assoc 0 (entget (car edim)))) "DIMENSION")
)
(prompt "\n*** You must select a dimension. ***")
)
(while
(and (not (and (setq etxt (entsel "\nSelect text to add to override or enter to type: "))
(= (cdr (assoc 0 (entget (car etxt)))) "TEXT")
)
)
(or (initget 1)
(not (setq text (getstring t "\nType the text or ENTER to clear override: ")))
)
)
)
(if etxt
(setq text (vla-get-textstring (vlax-ename->vla-object (car etxt))))
)
(setq vla_dim (vlax-ename->vla-object (car edim)))
(cond
((and text (/= text ""))
(vla-put-textoverride vla_dim (strcat (chr 60)(chr 62) "\\X" text))
)
((and text (= text "")) ; clear the override
(vla-put-textoverride vla_dim text)
)
)
(princ)
){code}
Member
caseys
Posts: 4
Registered: ‎07-10-2009
Message 6 of 11 (787 Views)

Re: Text under dimension line

12-07-2009 10:33 AM in reply to: caseys
Thanks to all who have replied and now I am able to put the text under the dimension line. One of these days I am going to learn to write lisp routines.

Thanks again to everyone.
*Expert Elite*
Kent1Cooper
Posts: 5,418
Registered: ‎09-13-2004
Message 7 of 11 (787 Views)

Re: Text under dimension line

12-07-2009 11:00 AM in reply to: caseys
So what you sent before was actually better than it looked [on the website interface, anyway].... That paired-angle-bracket problem has been complained about often, but never fixed, which is bad news because it spoils code for not only the actual-measurement stand-in indication in dimension text overrides, but also for the common designator for default values in typical prompts for various (get....) Lisp functions.

In the latter case, I have sometimes used {*curly* brackets} in something I post here, though I stick with the angle brackets the code I use here. But that substitution is not an option do for this dimension override situation. Going to (chr 60) (chr 62) shouldn't be necessary, but at least it *can* be taken right into Lisp files without converting anything, unlike my "less-than-symbol greater-than-symbol" description.

Another way around the problem is to keep the angle brackets, but attach the code as a .lsp file, rather than put it directly in the body of a post.

--
Kent Cooper


CAB2k wrote...
I was unaware of the format problem.
....
Kent Cooper
Distinguished Contributor
cab2k
Posts: 463
Registered: ‎12-15-2003
Message 8 of 11 (787 Views)

Re: Text under dimension line

12-07-2009 11:18 AM in reply to: caseys
Too bad there is not a Help File to explain how to include code as well as a "Don't do this" list.

Thanks for the Heads Up. :smileyhappy:
*LE
Message 9 of 11 (787 Views)

Re: Text under dimension line

12-07-2009 01:28 PM in reply to: caseys
Alan,

They have this:
http://discussion.autodesk.com/forums/help.jspa

if that can be called better than nothing...

wrote in message news:6300679@discussion.autodesk.com...
Too bad there is not a Help File to explain how to include code as well as a
"Don't do this" list.

Thanks for the Heads Up. :smileyhappy:
*Expert Elite*
scot-65
Posts: 2,164
Registered: ‎12-11-2003
Message 10 of 11 (787 Views)

Re: Text under dimension line

12-07-2009 03:19 PM in reply to: caseys
Kent,
> That paired-angle-bracket problem has been complained about often, but never fixed, which is bad news...
>

Try using { code } before and after...

{code}
Scot-65
Dyslexia is a permanent physical disability that cannot be seen.
Introverts is proof that there is indeed intelligent life on this planet.
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.