TheSwamp

Code Red => .NET => Topic started by: csharpbird on November 17, 2011, 10:05:32 AM

Title: Why dynamic block cannot use Table's SetBlockTableRecordId method?
Post by: csharpbird on November 17, 2011, 10:05:32 AM
Table tb=new Table();
......
tb.SetBlockTableRecordId(i, 3, bt["Door"], true);

If "Door" block is normal,the table cell will get the block image.
If "Door" block is dynamic, AutoCAD will throw an exception.
Title: Re: Why dynamic block cannot use Table's SetBlockTableRecordId method?
Post by: kaefer on November 17, 2011, 10:38:02 AM
Table tb=new Table();
......
tb.SetBlockTableRecordId(i, 3, bt["Door"], true);

If "Door" block is normal,the table cell will get the block image.
If "Door" block is dynamic, AutoCAD will throw an exception.

What AutoCAD version? What error message? What about a complete code example to reproduce your observation? Did you read Kean's blog (http://through-the-interface.typepad.com/through_the_interface/2011/10/creating-a-legend-of-autocad-drawings-using-net.html) and did you try the syntax he uses, as follows?

Code: [Select]
                    // Insert the block as the contents of our cell
 
                    Cell cell = tb.Cells[row, col];
                    cell.Contents.InsertAt(0);
                    cell.Contents[0].BlockTableRecordId =
                       blockId;
Title: Re: Why dynamic block cannot use Table's SetBlockTableRecordId method?
Post by: csharpbird on November 17, 2011, 11:58:05 AM
I'm using AutoCAD 2008.
It seems that your code is not for this version.
Title: Re: Why dynamic block cannot use Table's SetBlockTableRecordId method?
Post by: kaefer on November 17, 2011, 12:25:04 PM
I'm using AutoCAD 2008.
It seems that your code is not for this version.

The Table API underwent a major restructuring with release 2010. I'd wager a guess that the kind of problem you observed might have had something to do with it, even when the dynamic block API had stabilized before that.