- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All!
I know this question has been asked a hundred times and I have read all of the treads on the subject, but I cannot seem to find any code that actualy works as intended (or at least as I intend) 🙂
I am trying to pull a block "BlockA" from a seperate drawing file ("BlockFile") to insert into my current drawing file. The "BlockFile" drawing contains multiple other blocks; i.e. BlockA, BlockB, BlockC, etc...
I have pieced togeter the code below based on many threads covering this topic. The code is working with three exceptions:
1) When I use the "BlockFile.dwg" as the blockFile variable and try to pull BlockA into my current file, I get an eSelfReference error, even though the drawing I am trying to insert BlockA into is completely empty.
2) If I change the blockName variable to say... "BlockAb" then It pulls in the entire contents of the external drawing file (BlockFile), adds a new blockinsertion called "BlockAb" that contains the entire contents of the "BlockFile.dwg" and maintains the original "BlockA".
3) If I create a seperate drawing that only contains "BlockA" and change the name of the blockFile variable in the code to point to "BlockA" rather than "BlockFile", then "BlockA" is inserted as expected. This works great, but is not desired as I don't want to have thousands of individual files on the server for each of my blocks.
Am I doing something wrong???
Dim blockFile As String = "C:\BlockFile.dwg" Dim blockName As String = "BlockA" Dim db As Database = HostApplicationServices.WorkingDatabase Dim extDB As New Database(False, True) extDB.ReadDwgFile(blockFile, IO.FileShare.Read, True, "") Try Dim id As ObjectId = db.Insert(blockName, extDB, True) Catch ex As Autodesk.AutoCAD.Runtime.Exception MsgBox(ex.Message & vbCr & ex.StackTrace) Finally extDB.CloseInput(True) extDB.Dispose() End Try
TIA!
Solved! Go to Solution.