TheSwamp

Code Red => .NET => Topic started by: T.Willey on May 27, 2021, 12:29:09 AM

Title: Program created table crashes AutoCAD when reading later (workaround, FYI)
Post by: T.Willey on May 27, 2021, 12:29:09 AM
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.
Title: Re: Program created table crashes AutoCAD when reading later (workaround, FYI)
Post by: It's Alive! on May 28, 2021, 07:50:09 PM
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.
Title: Re: Program created table crashes AutoCAD when reading later (workaround, FYI)
Post by: T.Willey on May 29, 2021, 12:57:38 AM
Thanks, Daniel.  I'll look into it on Monday, and test.
Title: Re: Program created table crashes AutoCAD when reading later (workaround, FYI)
Post by: T.Willey on June 02, 2021, 03:50:07 PM
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.
Title: Re: Program created table crashes AutoCAD when reading later (workaround, FYI)
Post by: It's Alive! on June 02, 2021, 06:44:08 PM
Ah,  yeah tables can be finicky. I just remember doing the same thing once, but I solved it by playing with the cell content.