using tabs in a macro

using tabs in a macro

gbG5A5W
Enthusiast Enthusiast
241 Views
13 Replies
Message 1 of 14

using tabs in a macro

gbG5A5W
Enthusiast
Enthusiast

I'm trying to create a text, using a button with a macro in the toolpalette. The text-part works:

 

_.-Mtext \h;2;w;200;Mytext;;

 

Now I want to use tabs between the text:

 

Mytext -TAB- Mytext -TAB- Mytext

 

Using the tab-button in the Tool properties the cursor jumps to the next line. AutoCAD suggests ^I, but that creates 3 spaces instead of a tab. Using the columns-option is difficult, because the number of lines is not always the same. How do I get this working?

0 Likes
Accepted solutions (1)
242 Views
13 Replies
Replies (13)
Message 2 of 14

ВeekeeCZ
Consultant
Consultant

I've tried... don't see any issues. 

Use LIST command to export the MTEXT content to the commandline then copy-paste the exported text with tabs included to the tool definition.

 

_.-Mtext \h;2;w;200;Mytext MyText;;  (where space is a tab)

 

0 Likes
Message 3 of 14

Kent1Cooper
Consultant
Consultant

@gbG5A5W wrote:

.... I want to use tabs between the text:

Mytext -TAB- Mytext -TAB- Mytext

....


You can see by looking at the entity data that a Tab is represented by "\t" in Mext.  Use something like this for the content:

(strcat "MytextA" "\t" "MytextB" "\t" "MytextC")

Those "Mytext..." parts can be variables containing Text string content if you need it that way.

They must be lower-case t's -- "\T" will not work.

Kent Cooper, AIA
0 Likes
Message 4 of 14

gbG5A5W
Enthusiast
Enthusiast

Tried this. There's no tabs, but spaces instead

0 Likes
Message 5 of 14

gbG5A5W
Enthusiast
Enthusiast

The "strcat" suggests you are using it in a LISP, right? I'd rather use it in a macro

0 Likes
Message 6 of 14

gbG5A5W
Enthusiast
Enthusiast

In addition: the text after the list-command has also spaces instead of tabs already

0 Likes
Message 7 of 14

Kent1Cooper
Consultant
Consultant

@gbG5A5W wrote:

The "strcat" suggests you are using it in a LISP, right? I'd rather use it in a macro


Many AutoLisp functions will work in macros [I haven't tested this one, but try it].

Kent Cooper, AIA
0 Likes
Message 8 of 14

Kent1Cooper
Consultant
Consultant

@gbG5A5W wrote:

.... the list-command has also spaces instead of tabs ....


For the "whole story," use this on an Mtext object containing tabs:

(cdr (assoc 1 (entget (car (entsel "\nSelect Mtext to see its content: ")))))

It's in entity data that you see how it "really" stores the information.

You can also see the tabs in the "TextString" property of the Mtext converted to a VLA object:

(vla-get-TextString (vlax-ename->vla-object (car (entsel))))

Kent Cooper, AIA
0 Likes
Message 9 of 14

Sea-Haven
Mentor
Mentor

This was a simple test of a's then space b's then  tab and 'c's in a mtext. The entget returns as suggested by Kent. (1 . "aaaa bbb\tccc")

 

There is no problem using lisp in pop or toolbar menu's, (strcat "MytextA" "\t" "MytextB" "\t" "MytextC") simple to test in your tool palette.

 

(command "Mtext" pause pause (strcat "MytextA" "\t" "MytextB" "\t" "MytextC") "")

SeaHaven_0-1756773099976.png

 

0 Likes
Message 10 of 14

gbG5A5W
Enthusiast
Enthusiast

Using LISP-code in a macro is new to me, I'll give it a try. Thnx everyone for the help.

0 Likes
Message 11 of 14

komondormrex
Mentor
Mentor

@Sea-Haven wrote:

There is no problem using lisp in pop or toolbar menu's... 

(command "Mtext" pause pause (strcat "MytextA" "\t" "MytextB" "\t" "MytextC") "")

 


have you tried it as ts wants it to? 

0 Likes
Message 12 of 14

gbG5A5W
Enthusiast
Enthusiast

Ans is it just the case of copying 

(command "Mtext" pause pause (strcat "MytextA" "\t" "MytextB" "\t" "MytextC") "")

in the command string of the tool palette properties? In that case I can't seem to get it to work.

0 Likes
Message 13 of 14

ВeekeeCZ
Consultant
Consultant
Accepted solution

_.-Mtext \h;2;w;200;-;;(setpropertyvalue (entlast) "Contents" (strcat "MytextA" (chr 9) "MytextB" (chr 9) "MytextC"))(princ)

 

eekeeCZ_0-1756805201795.png

 

 

0 Likes
Message 14 of 14

gbG5A5W
Enthusiast
Enthusiast

Thnx, that works

0 Likes