[CommandMethod(ns, "xcmd", CommandFlags.Modal)]
public void CreateXmlTemplate() {
PromptEntityOptions peo = new PromptEntityOptions("Select table");
PromptEntityResult result = ed.GetEntity(peo);
if (result.Status == PromptStatus.OK) {
using (Transaction t = db.TransactionManager.StartTransaction()) {
Table table = (Table)t.GetObject(result.ObjectId, OpenMode.ForRead);
for (int i = 0; i < table.NumRows; i++) {
ed.WriteMessage(string.Format("\nRow: {0} RowType: {1}", i, table.RowType(i).ToString()));
}
}
}
}
Command: netload
Command: xcmd
Select table:
Row: 0 RowType: TitleRow
Row: 1 RowType: HeaderRow
Row: 2 RowType: DataRow
Row: 3 RowType: DataRow
Row: 4 RowType: DataRow
Row: 5 RowType: DataRow
Row: 6 RowType: DataRow
Indicates the row immediately following the title row.
Definition from the enum rowtype for a headerQuoteIndicates the row immediately following the title row.
[CommandMethod(ns, "xcmd", CommandFlags.Modal)]
public void CreateXmlTemplate() {
PromptEntityOptions peo = new PromptEntityOptions("Select table");
PromptEntityResult result = ed.GetEntity(peo);
if (result.Status == PromptStatus.OK) {
using (Transaction t = db.TransactionManager.StartTransaction()) {
Table table = (Table)t.GetObject(result.ObjectId, OpenMode.ForRead);
for (int i = 0; i < table.NumRows; i++) {
ed.WriteMessage(string.Format("\nRow: {0} RowType: {1}", i, table.GetCellStyle(i, 0)));
}
}
//XElement xml = TableTemplateCreate(result.ObjectId);
}
}
then all works correctly. but I don't want to force users through a properties window to change value of style for cells. ((( [CommandMethod( "tableRows")]
public void CreateXmlTemplate()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
PromptEntityOptions peo = new PromptEntityOptions("Select table");
PromptEntityResult result = ed.GetEntity(peo);
if (result.Status == PromptStatus.OK)
{
using (Transaction t = db.TransactionManager.StartTransaction())
{
Table table = (Table)t.GetObject(result.ObjectId, OpenMode.ForWrite);
for (int i = 0; i < table.Rows.Count; i++)
{
table.Rows[i].Style = "Header";[color=red]This will change Row Style to Header[/color]
ed.WriteMessage("\nRow: RowType:" + table.Rows[i].Style);[color=red]This will be empty if cell style is Row/Colum[/color]
}
t.Commit();
}
}
}
Okay maybe this will get you a little furtherCode: [Select]...
table.[color=red]Rows[i].Style[/color]
...
"Table" class not exists "Rows" property (ObjectARX 2009).
Use Table.Cells[row, column].HorizontalLine.Margin instead. | Double HorizontalCellMargin { get set; } |
Use Cell functionality instead. | Boolean IsHeaderSuppressed { get set; } |
Use Cell functionality instead. | Boolean IsTitleSuppressed { get set; } |
Use Table.Columns.Count instead. | Int32 NumColumns { get set; } |
Use Table.Rows.Count instead. | Int32 NumRows { get set; } |
Use Table.Cells[row, column].VerticalLine.Margin instead. | Double VerticalCellMargin { get set; } |
... | ... |
you do realise that between 17.2 and 18.0 a major API rewrite of the Table class took place?
you do realise that between 17.2 and 18.0 a major API rewrite of the Table class took place?
Both these versions for ObjectARX 2009?
< ... >
s/r/d/, Thorsten
OK, I have to ask ..
what is s/r/d
...
db.ObjectAppended += new ObjectEventHandler(db_ObjectAppended);//db -> Database
...
void db_ObjectAppended(object sender, ObjectEventArgs e)
{
if (e.DBObject is Table)
{
Table table = (Table)e.DBObject; table.UpgradeOpen();
for (int i = 0; i < table.NumRows; i++)
{
for (int k = 0; k < table.NumColumns; k++)
{
string style = string.Empty;
switch (i)
{
case 0:
if (table.GetCellStyle(i,k) == "") style = "_Title";
break;
case 1:
if (table.GetCellStyle(i, k) == "") style = "_Header";
break;
default:
if (table.GetCellStyle(i, k) == "") style = "_Data";
break;
}
if (style != string.Empty) table.SetCellStyle(i, k, style);
}
}
ed.WriteMessage("\nNew Table object to Database was added");
}
}
...
[CommandMethod(ns, "xcmd", CommandFlags.Modal)]
public void CreateXmlTemplate()
{
PromptEntityOptions peo = new PromptEntityOptions("Select table");
PromptEntityResult result = ed.GetEntity(peo);
if (result.Status == PromptStatus.OK)
{
using (Transaction t = db.TransactionManager.StartTransaction())
{
Table table = (Table)t.GetObject(result.ObjectId, OpenMode.ForWrite);
for (int i = 0; i < table.NumRows; i++)
{
ed.WriteMessage(string.Format("\nRow: {0} RowType: {1}", i, table.GetCellStyle(i,0)));
}
}
}
}
...
I have made so:
(http://habreffect.ru/files/dc5/46ff8bf88/20.10.png)
did you try table.GetCellStyle(r,-1)?For what?
That works as in your picture, albeit with blue squiggles, since it should be table.Cells.[r,-1].Style now.I haven't understood you.
did you try table.GetCellStyle(r,-1)?For what?
let peo = new PromptEntityOptions("Select table")
let result = ed.GetEntity peo
if result.Status = PromptStatus.OK then
use tr = doc.TransactionManager.StartTransaction()
let table = tr.GetObject(result.ObjectId, OpenMode.ForWrite) :?> Table
for r = 0 to table.NumRows - 1 do
ed.WriteMessage("\nRow: {0} RowType: {1} ", r, table.GetCellStyle(r,-1))
tr.Commit()
Cheers, Thorsten
To get the Row Style as formulated in your original question.Code: [Select]table.GetCellStyle(r,[color=red]-1[/color])?