.NET

.NET

Reply
Active Contributor
30 Posts
0 Kudos
Registered: ‎04-04-2006
Post 1 of 10

syntax for setting a table cell type to blockcell

385 Views, 9 Replies
08-19-2010 07:12 AM

I have tried: 

Table.SetCellType(0, 0, TableCellType.BlockCell)

 

result:

 

Warning 1 'Public Overridable Sub SetCellType(row As Integer, col As Integer, type As Autodesk.AutoCAD.DatabaseServices.TableCellType)' is obsolete: 'Use Cell functionality instead.'

 

Then i tried:

 

Tbl.Cells(0, 0).CellType(TableCellType.BlockCell)

 

result:

 

Error 1 Property access must assign to the property or use its value.

 

Then I tried:

 

Table.Cells(0,0).CellType = TableCellType.BlockCell

 

result:

 

Error 1 Property 'CellType' is 'ReadOnly'. 

 

Can anyone elighten me?

 

 

Valued Contributor
91 Posts
1 Kudo
Registered: ‎08-22-2013
Post 2 of 10

Re: syntax for setting a table cell type to blockcell

08-22-2013 01:24 AM in reply to: pstarkey
i met this warning too, did u find the way?
Active Contributor
30 Posts
0 Kudos
Registered: ‎04-04-2006
Post 3 of 10

Re: syntax for setting a table cell type to blockcell

08-22-2013 05:26 AM in reply to: pstarkey

No

ADN Support Specialist
352 Posts
27 Kudos
Registered: ‎07-24-2007
Post 4 of 10

Re: syntax for setting a table cell type to blockcell

09-09-2013 11:40 AM in reply to: pstarkey

would you mind posting a small sample app so I can see what you need to acheive, then I'll fix it for you





Fenton Webb

Developer Technical Services

Autodesk Developer Network


Distinguished Contributor
212 Posts
6 Kudos
Registered: ‎10-03-2003
Post 5 of 10

Re: syntax for setting a table cell type to blockcell

09-13-2013 01:55 PM in reply to: fenton.webb

 

Here's a quick example, not the same message but the same error with the set margins.

 

<CommandMethod("cadTable")> Public Sub cadTable()
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim dwgScale As Integer = db.Dimscale
Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim ppr As PromptPointResult = ed.GetPoint("Pick upper left insertion point: ")
If ppr.Status = PromptStatus.OK Then
Dim colHeadNames As New Specialized.StringCollection()
colHeadNames.Add("ABC")
colHeadNames.Add("DEF")
colHeadNames.Add("GHI")
colHeadNames.Add("JKL")
colHeadNames.Add("MNO")
Dim colCount As Integer = colHeadNames.Count - 1
Dim tb As New Autodesk.AutoCAD.DatabaseServices.Table()
tb.TableStyle = db.Tablestyle
tb.SetSize(2, colHeadNames.Count)
tb.Height = 0.125
tb.Columns(0).Width = 0.5 * dwgScale
tb.Columns(1).Width = 0.5 * dwgScale
tb.Columns(2).Width = 1.5625 * dwgScale
tb.Columns(3).Width = 2.0 * dwgScale
tb.Columns(4).Width = 1.4375 * dwgScale
tb.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 256)
tb.Position = ppr.Value
tb.Cells(0, 0).TextString = "EXAMPLE"
tb.Height = 0.125
tb.SetMargin(0, 0, CellMargins.Top, 0.0625 * dwgScale)
tb.SetMargin(0, 0, CellMargins.Bottom, 0.0625 * dwgScale)
tb.Cells(0, 0).TextHeight = 0.15625 * dwgScale
For i As Integer = 0 To colCount
tb.SetMargin(1, i, CellMargins.Top, 0.0625 * dwgScale)
tb.SetMargin(1, i, CellMargins.Bottom, 0.0625 * dwgScale)
tb.Cells(1, i).Alignment = CellAlignment.TopCenter
tb.Cells(1, i).TextString = colHeadNames(i)
tb.Cells(1, i).TextHeight = 0.09375 * dwgScale
Next
tb.BreakEnabled = True
tb.BreakFlowDirection = TableBreakFlowDirection.Right
tb.BreakOptions = TableBreakOptions.AllowManualHeights
tb.BreakOptions = TableBreakOptions.EnableBreaking
tb.BreakOptions = TableBreakOptions.RepeatTopLabels
tb.SetBreakSpacing(0.09375 * dwgScale)
Using doclok As DocumentLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument
Using t As Transaction = db.TransactionManager.StartTransaction()
Dim bt As BlockTable = CType(t.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
Dim btr As BlockTableRecord = CType(t.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
tb.GenerateLayout()
Dim TblId As ObjectId
TblId = btr.AppendEntity(tb)
t.AddNewlyCreatedDBObject(tb, True)
t.Commit()
End Using
End Using
End If
End Sub

Valued Mentor
388 Posts
30 Kudos
Registered: ‎03-31-2005
Post 6 of 10

Re: syntax for setting a table cell type to blockcell

01-14-2015 08:35 AM in reply to: Mikko

Was this answered?  I am looking for table.settextheight and I get the warning

 

Warning 2 'Autodesk.AutoCAD.DatabaseServices.Table.SetTextHeight(double, int)' is obsolete: '"Use Cell functionality instead."' 

Mentor
256 Posts
44 Kudos
Registered: ‎07-20-2011
Post 7 of 10

Re: syntax for setting a table cell type to blockcell

01-16-2015 06:22 AM in reply to: fieldguy
Try this:
myTable.Cells[rowNr, colNr].TextHeight = 2.5;
use rowNr=colNr=-1 to set all Cells

Mentor
256 Posts
44 Kudos
Registered: ‎07-20-2011
Post 8 of 10

Re: syntax for setting a table cell type to blockcell

01-16-2015 06:25 AM in reply to: SENL1362

and for the Cell Type would this work for you?
DataTypeParameter cellDataType = new DataTypeParameter();
cellDataType.DataType = DataType.XXXX;
cellDataType.UnitType = UnitType.Unitless;
myTable.Cells[-1, -1].DataType = cellDataType;

Valued Mentor
388 Posts
30 Kudos
Registered: ‎03-31-2005
Post 9 of 10

Re: syntax for setting a table cell type to blockcell

01-16-2015 07:28 AM in reply to: SENL1362

Thanks SENL1362.  I found some stuff from fixo (ty for sharing oleg, andrey bushman, jeff h, and others).  Quite a bit of this is in the swamp.

 

from fixo:

acdb.DataTypeParameter dtp = new acdb.DataTypeParameter();
dtp.DataType = acdb.DataType.Double;
dtp.UnitType = acdb.UnitType.Distance;

if this column is the 1 i want to change to 6 decimal places

mytable.Cells[i, j].Contents[0].DataType = dtp;
mytable.Cells[i, j].Contents[0].Value = drilltable.Rows[i].ItemArray[j];
mytable.Cells[i, j].Contents[0].DataFormat = "%lu2%pr6%";                 <--- how intuitive!  Is this documented somewhere?

 

Here are some links:

http://www.acadnetwork.com/index.php?topic=150.0

https://sites.google.com/site/acadhowtodo/net/styles/table-styles

http://www.theswamp.org/index.php?topic=42867.msg480949#msg480949

 

I wasted some time formatting numeric strings in a datatable / datagridview beforehand that were totally ignored - it's like autocad finds a number and insists on changing it. 

 

Mentor
256 Posts
44 Kudos
Registered: ‎07-20-2011
Post 10 of 10

Re: syntax for setting a table cell type to blockcell

01-16-2015 07:30 AM in reply to: fieldguy
probably MTEXT syntax
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!