Hi,
I'm afraid this is going to require a little reading as its a fairly unique set of events i need to describe, but i hope someone has seen this and can help!
I am inserting blocks that contain an AMPartRef into a drawing using .NET, when the blocks are inserted before the BOM has been viewed, all the blocks are inserted and the Items appear in the BOM as they would if you used the standard Insert command from CAD.
However if the BOM has been opened and viewed one of 2 things seems to happen
To provide more information what i have found is that if the first instance of the block is added using the AutoCAD Insert command, the insert routine i wrote in .NET always functions correctly and the parts are added to the BOM (Using the Block Definition created when manually inserted)
This has leads me to believe that the issue may be with the creation of the Block definition the code for which i have provided below. (A check for if the block definition already exists is done else where)
private ObjectId InsertBlockDefinition(string fileName) { Document openDrawing = Core.Application.DocumentManager.MdiActiveDocument; ObjectId newBlockID = ObjectId.Null; if (openDrawing != null && CheckFileExists(fileName) == true) { Transaction currentTransaction = openDrawing.TransactionManager.StartTransaction(); using (currentTransaction) { using (openDrawing.LockDocument()) { Database openDrawingDatabase = openDrawing.Database; using (openDrawingDatabase) { Database newBlockDatabase = null; //Declare a new drawing database to read the block being inserted into using (newBlockDatabase = new Database(false, true)) { try { //Read the content of the drawing from its location into the database newBlockDatabase.ReadDwgFile(fileName, System.IO.FileShare.Read, true, ""); newBlockDatabase.CloseInput(true); newBlockID = openDrawingDatabase.Insert(SymbolUtilityServices.RepairSymbolName(SymbolUtilityServices.GetBlockNameFromInsertPathName(fileName),false), newBlockDatabase,false); } catch (System.Exception ex) { System.Windows.MessageBox.Show("File " + fileName + " Read Only, Unable to Insert" + System.Environment.NewLine + "Message: " + ex.Message); } currentTransaction.Commit(); } } } } } return newBlockID; }
So guess there are a couple of questions
Any help is greatfully recieved, even just confirmation that Inserting the Block Definintion cant be done this way when an AMPartRef is involved!
Thanks