I can create and add the block reference programatically sucessfully.
Now i am not creating, but only adding a block reference with the existing block reference by refering it with its blockname. The problem is when i try to add an existing block reference to new locaiton to the same drawing file where the block is present.
Check the code, i am not not creating a block reference.
The Block Name created is "Dummy", I am trying to add the same block in different location.
I cannot stop the execution in between as i have added the output source to AutoCAD Application. If i stop then AutoCAD also closes.
>> I cannot stop the execution in between as i have added the output source to AutoCAD Application
Maybe I don't understand that, ... Just set a breakpoint at the first line within your command-code for "ADD_Block". It has to stop at the breakpoint. If VS does not you have any other problem (additionally to the block-insert).
And one sentence to this line:
By default it returns an ObjectID from the BlockTableRecord with the name <blockName>. But it's critical as it returns the FIRST occurence of a BlockTableRecord for this name. Imagine you have created a blockdefinition (so a BlockTableRecord is created) .... then you do a _PURGE ==> the BlockTableRecord is not removed from the database, it exists there as long as the drawing is not closed, the BlockTableRecord is just marked as deletet.
The result is: the next time you create a BlockTableRecord with the same name you got two BlockTableRecords each pointing to the same blockname, but the first one has the property .IsErased = TRUE and the new one has this set to FALSE.
With your code you just search for the first BlockTableRecord for name "blockName" and then you use it for insert ... EVEN IF IT's ERASED in the meantime ..... ever checked for the property .IsErased? If not ..,. do it
Hope that is clear to understand!
-. alfred -