Clicky

Hi All.

In AUTOCAD I have over 200 mtext boxes in a dwg.  The box has been split up so that each box has 4 lines of information (1 over the other).

What I want is a code that will automatically update ONLY THE TOP LINE of text in each multi text box and make it grey(Colour 8) whilst leaving everything else unchanged.  Is this possible.

For example each box looks like this


xx
  xxxx
  xxxx
  xxxx


where each x represents text

asked 10/18/2011 11:21

saunaG's gravatar image

saunaG ♦♦


17 Answers:
Would it be possible to upload a sample file (with fictitious values) and do the color change for one of them?
link

answered

ssaqibh's gravatar image

ssaqibh

This code will convert all MText in the modelspace which have more than 1 lines of text.
1:
2:
3:
4:
5:
6:
7:
8:
9:
Sub grey1stline()
For Each ent In ThisDrawing.ModelSpace
If ent.ObjectName = "AcDbMText" Then
lin1len = InStr(ent.TextString, "P")
If lin1len > 0 Then ent.TextString = "{C8;" & Left(ent.TextString, lin1len - 1) & "}" & Right(ent.TextString, Len(ent.TextString) - lin1len + 1)
ent.Update
End If
Next ent
End Sub
link

answered 2011-10-18 at 08:47:24

ssaqibh's gravatar image

ssaqibh

How do I run this code.

I am a newbie at any type of coding in autocad. Is this LISP, VBA etc. What steps must I take to run it?

Cheers,

link

answered 2011-10-18 at 10:48:51

saunaG's gravatar image

saunaG

This is VBA

In Autocad press Alt-F11
Insert > module
paste the code in this pane
Close the VBA window
Make sure your drawing file is open in autocad
Press Alt-F8 and then click Run
link

answered 2011-10-18 at 13:00:27

ssaqibh's gravatar image

ssaqibh

Thank you very much. This code works except for the fact that it is changing all the text grey, instead of just the top line?
link

answered 2011-10-18 at 13:03:40

saunaG's gravatar image

saunaG

It it helps each top lines contains only 4 characters of text
link

answered 2011-10-18 at 13:08:55

saunaG's gravatar image

saunaG

Can you delete everything except a few of the Mtext's and then upload the file?
link

answered 2011-10-18 at 13:11:42

ssaqibh's gravatar image

ssaqibh

Sorry 2 characters min, 4 characters max depending on my data
link

answered 2011-10-18 at 13:12:13

saunaG's gravatar image

saunaG

Here is a small screenshot of my block. This system told me it cannot accept dwg format 2011 civil 3d
As you see the top line of text is a code whereas the rest is reference data.  I need to only convert the top line (3L or 15K etc) to the colour grey whereas the remaining text can remain the colour it is.


Dont worry about the block boarder.
link

answered 2011-10-18 at 13:12:48

saunaG's gravatar image

saunaG

take a list of a few of the mtexts and paste it here
link

answered 2011-10-18 at 13:36:35

ssaqibh's gravatar image

ssaqibh


1)
11Q
750
0.3
367


2)
11R
405
0.3
367

3)

24AM
25,951
10
359


Here are a few examples.  

Also, note that the top line could range beween (1-25)(A-AF) i.e. example (3) 24AM.  This text line is the only one I need changed for all mtext boxes.

Cheers.
link

answered 2011-10-18 at 13:58:21

saunaG's gravatar image

saunaG

No, This is not what I am looking for.

Enter the LIST command from the command line and then select a few mtext objects and then press enter.

You would get a list of entity details which I would like you to copy and then paste here.

It should look something like this


                  MTEXT     Layer: "0"
                            Space: Model space
                   Handle = 14b
             Style = "Standard"
        Annotative: No
Location:        X=  32.7931  Y=  39.1991  Z=   0.0000
Width:              5.1674
Normal:          X=   0.0000  Y=   0.0000  Z=   1.0000
Rotation:                0
Text height:        0.2000
Line spacing:    Multiple (1.000000x =    0.3333)
Attachment:      TopLeft
Flow direction:  ByStyle
Contents:        {\C8;abcd}\Pabdf\Pfas\Pfsadf
link

answered 2011-10-19 at 06:13:26

ssaqibh's gravatar image

ssaqibh

1)

 MTEXT     Layer: "0"
                            Space: Model space
                   Color: 7 (white)    Linetype: "BYLAYER"
                   Handle = 2f149
             Style = "Standard"
        Annotative: No
Location:        X=611225.0000  Y=4933174.0281  Z= 360.0000
Width:             32.0000
Normal:          X=   0.0000  Y=   0.0000  Z=   1.0000
Rotation:                0
Text height:        5.0000
Line spacing:    Multiple (1.000000x =    8.3333)
Attachment:      MiddleCenter
Flow direction:  ByStyle
Contents:        \pxql;{\fTimes New Roman
TUR|b0|i0|c0|p18;2L\P\pqr;14,240\P12.79\P327.6}

               
2)


   MTEXT     Layer: "RESERVE BLOCK TONNAGES"
                            Space: Model space
                   Color: 7 (white)    Linetype: "BYLAYER"
                   Handle = 2f146



 MTEXT     Layer: "RESERVE BLOCK TONNAGES"
                            Space: Model space
                   Color: 7 (white)    Linetype: "BYLAYER"
                   Handle = 2f3bd
             Style = "Standard"
        Annotative: No
Location:        X=612425.0000  Y=4931824.0281  Z= 360.0000
Width:             32.0000
Normal:          X=   0.0000  Y=   0.0000  Z=   1.0000
Rotation:                0
Text height:        5.0000
Line spacing:    Multiple (1.000000x =    8.3333)
Attachment:      MiddleCenter
Flow direction:  ByStyle
Contents:        \pxql;{\fTimes New Roman
TUR|b0|i0|c0|p18;29AJ\P\pqr;17,227\P12\P343}



3)

    MTEXT     Layer: "RESERVE BLOCK TONNAGES"
                            Space: Model space
                   Color: 7 (white)    Linetype: "BYLAYER"
                   Handle = 2f353
             Style = "Standard"
        Annotative: No
Location:        X=611925.0000  Y=4932124.0281  Z= 360.0000
Width:             32.0000
Normal:          X=   0.0000  Y=   0.0000  Z=   1.0000
Rotation:                0
Text height:        5.0000
Line spacing:    Multiple (1.000000x =    8.3333)
Attachment:      MiddleCenter
Flow direction:  ByStyle
Contents:        \pxql;{\fTimes New Roman
TUR|b0|i0|c0|p18;23Z\P\pqr;3,906\P9\P345}
link

answered 2011-10-19 at 08:50:00

saunaG's gravatar image

saunaG

Was that the information you needed?
link

answered 2011-10-19 at 08:58:41

saunaG's gravatar image

saunaG

Yes precisely. But I am having problem deciphering it. It has a few codes which have not been explained in the help files which is why it is taking me time to handle it.
link

answered 2011-10-20 at 06:21:29

ssaqibh's gravatar image

ssaqibh

I shall continue to work on this but you might like to request community support to invite more experts to try to help you out.
link

answered 2011-10-20 at 06:28:55

ssaqibh's gravatar image

ssaqibh

Hi I am still struggling to get the codes straight. I have come up with a code which will do the desired but there are problems. To overcome the problems I recommend that you download a lisp file which I have found and run that file (only with the color option selected) before running my code.


The file can be found at

https://sites.google.com/site/cadabyss/Home/autolisp/StripMtextv5-0b.lsp?attredirects=0



My code is

Sub grey1stline()
For Each ent In ThisDrawing.ModelSpace
If ent.ObjectName = "AcDbMText" Then
    txtarr = Split(ent.TextString, "\P")
    If UBound(txtarr) > -1 Then
        lin1arr = Split(txtarr(0), ";")
        For i = 0 To UBound(lin1arr)
            If Left(lin1arr(i), 1) <> "\" And Left(lin1arr(i), 1) <> "{" Then
            lin1arr(i) = "{\C8;" & lin1arr(i) & "}"
            End If
        Next i
        txtarr(0) = Join(lin1arr, ";")
        ent.TextString = Join(txtarr, "\P")
        ent.Update
    End If
End If
Next ent
End Sub
link

answered 2011-10-20 at 08:08:18

ssaqibh's gravatar image

ssaqibh

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×6
×12
×83
×1

Asked: 10/18/2011 11:21

Seen: 433 times

Last updated: 10/26/2011 09:18