Author Topic: Program created table crashes AutoCAD when reading later (workaround, FYI)  (Read 217 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5247
I created a table, where not all the cells were populated.  It has 10 columns.  If someone added new items to the table, when I came back and read the table it would crash acad without being able to be caught.  This could be because some cells were block cells and others were plain text cells.   The workaround I came up with was to go into all cells and just set the value to an empty string (even ones I would change later in the code to block cells).  It took awhile to find the issue (maybe because this it the first dotNet program I've done in awhile).

Just wanted to share this here in case someone runs into the same issue.  Maybe it won't take them as long to see the solution.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 7059
  • AKA Daniel
you might be able to just iterate the cells and delete the content array, in ARX its deleteContent(int nRow,  int nCol);
table edit usually will create the content array. setting as an empty string might cause issues if someone wants to add a block to the cell.
Retired

T.Willey

  • Needs a day job
  • Posts: 5247
Thanks, Daniel.  I'll look into it on Monday, and test.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5247
Deleting the contents does not work (as written in the code below).  I have to fill out some information, so I need to set certain properties of the cell.
Code: [Select]
// set defaults for each cell
Cell c;
for (int i = 0; i < tbl.Rows.Count; i++) {
for (int j = 0; j < tbl.Columns.Count; j++) {
c = tbl.Cells[i, j];
c.DeleteContent();
c.TextStyleId = styid;
c.TextHeight = _txht;
c.Alignment = CellAlignment.MiddleCenter;
c.Borders.Horizontal.Margin = 0.03;
// c.Value = "";
}
}

I tested adding a block to the table with the original code, and no issues were had.  Thanks for the idea though, Daniel.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 7059
  • AKA Daniel
Ah,  yeah tables can be finicky. I just remember doing the same thing once, but I solved it by playing with the cell content.
Retired