Is it possible to insert a block to the BlockTableRecord without actually inserting the block into the drawing?
In my application, before there's any user interaction, I run some checks. One of them is to add my blocks to the BlockTableRecord if they're not already there. Everything I've seen online, wants the block position (3D coordinate) as part of the process of setting it up, and therefore the block is inserted at the same time it's added to the block table.
I've pared down my VB code just to keep it simple for the purposes of this example, of course I'll be doing error checking etc.
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.ApplicationServices
Imports System.IO
Public Class Class2
<CommandMethod("AddtoBT")> _
Public Sub InsertFromFileCommand()
Dim FileNameLoc As String = "C:\TEMP\CIRCLESQUARE.DWG"
Dim FileName As String = "CIRCLESQUARE"
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Using xDb As New Database(False, True)
xDb.ReadDwgFile(FileNameLoc, FileShare.Read, True, Nothing)
Using tr As Transaction = doc.TransactionManager.StartTransaction()
Dim id As ObjectId = db.Insert(FileName, xDb, True)
Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
'I'D LIKE TO SKIP THIS STEP WHERE THE POINT3D IS REQUIRED
Dim p3d As Point3d = New Point3d(0, 0, 0)
Dim insert As New BlockReference(p3d, id)
btr.AppendEntity(insert)
insert.SetDatabaseDefaults()
tr.AddNewlyCreatedDBObject(insert, True)
tr.Commit()
End Using
End Using
End Sub
End Class
Again, I'm still new to coding, so sorry for the n00b question.
George