.NET

Reply
Distinguished Contributor
cadcamm99
Posts: 152
Registered: ‎04-12-2005
Message 1 of 7 (734 Views)

Table Text Style

734 Views, 6 Replies
08-05-2010 01:03 PM

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.

Valued Mentor
caddzone
Posts: 305
Registered: ‎01-26-2005
Message 2 of 7 (728 Views)

Re: Table Text Style

08-05-2010 01:12 PM 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


*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 3 of 7 (725 Views)

Re: Table Text Style

08-05-2010 01:33 PM 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
Distinguished Contributor
cadcamm99
Posts: 152
Registered: ‎04-12-2005
Message 4 of 7 (723 Views)

Re: Table Text Style

08-05-2010 01:34 PM 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

Valued Mentor
caddzone
Posts: 305
Registered: ‎01-26-2005
Message 5 of 7 (713 Views)

Re: Table Text Style

08-05-2010 03:20 PM 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


Distinguished Contributor
cadcamm99
Posts: 152
Registered: ‎04-12-2005
Message 6 of 7 (697 Views)

Re: Table Text Style

08-06-2010 07:26 AM in reply to: caddzone

Thanks for you help. It is greatly appreciated.

Distinguished Contributor
area51visitor
Posts: 116
Registered: ‎03-05-2011
Message 7 of 7 (210 Views)

Re: Table Text Style

04-03-2013 10:39 PM in reply to: cadcamm99

Life saver once again!

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

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 to get help installing your software.

Ask the Community