.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Table Text Style

6 REPLIES 6
Reply
Message 1 of 7
cadcamm99
1958 Views, 6 Replies

Table Text Style

How do you set the text style for cells in a table?  I used to be able to set the title row, head row and data row text style in vba. In vb.net I tried using <tablestyle>.SetTextStyle but it is asking me for an ID.

6 REPLIES 6
Message 2 of 7
caddzone
in reply to: cadcamm99

Have you taken the time to become familiar with the managed API using

the materials available through Autodesk's web site?

 

In the managed world, objects in drawings are repesented by ObjectIds,

rather than by their user-friendly names. Hence, you have to find the

ObjectId of the table style you want to apply, by looking it up in the table

style dictionary.

 

Sorry, if I sound like I think you're asking for a loaded question, but

understading the basics of the managed API, such as what ObjectIds

are and how they're used, is a prerequisite.

 



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 3 of 7
Hallex
in reply to: cadcamm99

Try this code snippet

 

              TextStyleTable tt = (TextStyleTable)tr.GetObject(db.TextStyleTableId, OpenMode.ForRead, false);

                        if (!(tt.Has(txstylename))) return;

                        ObjectId txtid = tt[txstylename];

                        

 then apply this txtid to your code

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 4 of 7
cadcamm99
in reply to: caddzone

This is a piece of code I have in my program. I just wasn't sure if this is what it was asking for.

 

'Check if text style exists
Dim acTextStyleTable As TextStyleTable = acLayerTextTrans.GetObject(MyDrawingDb.TextStyleTableId, _
                                                                                                    OpenMode.ForRead)


For Each acTextStyleObjId As ObjectId In acTextStyleTable
      Dim acTextStyleTableRec As TextStyleTableRecord
      acTextStyleTableRec = acLayerTextTrans.GetObject(acTextStyleObjId, OpenMode.ForRead)

       If acTextStyleTableRec.Name = strTableTextStyle Then
            TableTextStyleFound = True
       End If

next

Message 5 of 7
caddzone
in reply to: cadcamm99

You don't have to search the text style table manually, because the Has()

method tells you if an entry exists, and the indexer or Item() method will get

it if it does, so most of that code is pointless and wasteful.

 

The other thing is a basic programming mistake, which is that you

continue looking at items in the table even after you've found the

one you're after. Are you familiar with the Exit For statement?

 

See hallex's reply - that's all you need.



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 6 of 7
cadcamm99
in reply to: caddzone

Thanks for you help. It is greatly appreciated.

Message 7 of 7

Life saver once again!


"Very funny, Scotty. Now beam down my clothes.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost