Jump to content

Tabbing text in a script file


DansCAD

Recommended Posts

Hi guys and girls,

 

I am new to this and have a (hopefully) simple question. I have a script file that creates mtext and writes a list of items like this:

 

Name - description

OtherName - Description

 

What I want is for it to be neatly tabbed out so that the dashes line up vertically, however I cannot find a command to insert a {TAB} into the text.

 

An example of my script is

 

-Mtext

96000,24000

S

HEAD1

J

TL

120000,14000

\H0.75x;\C2

\H1.333333333x;\C4\LUPPER ROOF FRAMING\l\H0.75x;\C2 (1:100)\P

UL.1 - 90x63 LVL and 100x75x10 Galintel Angle

UL.2 - 90x45 LVL and 100x75x10 Galintel Angle

 

and i want to insert tab as shown:

 

UL.2 {TAB}- 90x45 LVL and 100x75x10 Galintel Angle

 

Is there a way to do what i want?

 

Thanks

 

Dan

Link to comment
Share on other sites

Thanks steven,

 

I will give it a go - at least I will be able to use other characters. :)

 

Cheers

 

Dan

Link to comment
Share on other sites

Thanks BigAl,

 

What you have written there looks more like a LISP routine or something. the "\t" unfortunately doesn't work in an AutoCAD LT14 script.

 

Cheers,

 

Dan

Link to comment
Share on other sites

Hey DansCAD, welcome to the forum.

 

With the limitation of LT, maybe another option is to create two distinct text object per line, and create the alignment manually that way...

Link to comment
Share on other sites

Thanks YZ,

 

I have thought about creating the titles in one Mtext and then the descriptions in another with a preset offset. It all comes down to the preference of the other guys, as they'll be using it more than me.

 

Cheers

 

Dan

Link to comment
Share on other sites

Just maybe a way around it.

Make your script in notepad.

Add the tabs at required locations.

Copy and paste the 1st half of the mtext set up colour ht etc.

Copy and paste the re-mainder which has tabs in it to the mtext the tabs should remain.

Tested with normal Autocad and works.

Link to comment
Share on other sites

Thanks Al,

 

I gather you mean manual copy/paste from the script? The purpose of the exercise is to have a singe click operation which inserts the tabs - I don't want to be opening scripts to copy text - it kinda defeats the purpose!

 

I tried having tabs in the script file and running the script file but it just reads it as an extra space.

 

I understand understand why this is even a problem... Why can't CAD just read the unicode format properly??? :reallymad:

Link to comment
Share on other sites

If BIGAL's solution works and you can add tabs in Notepad that successfully translate in to AutoCAD format how you want them, then perhaps there is a way to programmatically do that using a third party software like a batch file that opens notepad, then opens AutoCAD?... But yeah, it seems like AutoCAD is not playing this game for you.

Link to comment
Share on other sites

Hmmm... yeah that could work. I have written batch scripts that are called by Word before and they work ok. They are harder to implement than a standard cad macro.

 

If I get a chance I might give it a try and see how it goes. I will update this thread as to how it goes. (It might be a while until I get around to it though...)

Link to comment
Share on other sites

Word has VBA inside it so maybe you can control commands to Autocad, as a start search for excel controlling Autocad you will find examples and the code should be the same.

Link to comment
Share on other sites

Steven-g I googled the VBA to Autocad and had it say "hello" and draw some points from excel. Make sure if you try must add the Autocad libray type in excel VBA.

 

http://howtoautocad.com/excel-and-autocad-%E2%80%93-a-match-made-in-heaven-again/

 

Does it work with LT ? If so opens up a pandoras box of power, a little clumsy but useable. Copy/paste or enter corner pt then do 20 questions and object appears.

Link to comment
Share on other sites

That's a shame, it fails on the very first line, It is possibly calling the vba module used in Autocad, and this is not available to LT. I use excel vba to to create scripts for Autocad but saving on the copy / paste (or creating a named ????.scr file to run from a macro) would have saved a few steps. I really do need to get my web site running (it's so close)

 

EDIT - this is a quote from the link, it does need the VBA option of full Autocad, this library isn't available to LT users

If you’ve done any programming before, you will know that you can have variables, and variables can have different types. These types can be simple, or can be more complex things known as objects. AutoCAD® has its own type library containing all the object types that we are likely to need. This is very useful to load into our application. To do this, go to Tools>References in the VBA window, and look for an option called AutoCAD® 2010 Type Library, or whatever version of AutoCAD® you are using. This has now made available some extra types that weren’t available before.
Link to comment
Share on other sites

Another more interesting if you have the non commercial version of excel it will not let you pick the libraries, finds them but greyed out.

 

Works now did something wrong yesterday.

 

acax20enu.tlb is the file it looks for this is the english version, others like acax20ita.tlb I would guess to be Italian.

Edited by BIGAL
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...