Thanks so much for your help....got it to work!!! Because I'm so new at this...sometimes I'll use the snippets from Jerry's book first; after which, I customize it from there. I'm going need to create a new layer before adding my blocks..so I also added that into the code below and now it works just like I need it.
Setting the color of the object used to create the block before creating the block is what I needed to do.
Thanks to all for your help!!!
Proctor
<CommandMethod("addcircle")> _
Public Sub AddNewBTRB()
Dim myDwg As Document
Dim myBT As BlockTable
Dim myBTR As BlockTableRecord
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument()
Dim ed As Editor = doc.Editor
'add new layer here:
Dim curdb As Database = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database
Using docLock As DocumentLock = ed.Document.LockDocument()
Using trans As Transaction = ed.Document.TransactionManager.StartTransaction()
Dim lt As LayerTable = CType(trans.GetObject(curdb.LayerTableId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite), LayerTable)
Dim x As New LayerTableRecord
myLayerName = "6 PER FT"
With x
.Name = myLayerName
.IsOff = False
.IsFrozen = False
.IsLocked = False
lt.Add(x)
trans.AddNewlyCreatedDBObject(x, True)
End With
myDwg = Application.DocumentManager.MdiActiveDocument
'Open the database for Write
myBT = myDwg.Database.BlockTableId.GetObject(Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)
'Add a new BlockTableRecord
myBTR = New BlockTableRecord
myBTR.Name = "CircleBlock"
Dim CenterPoint As New Geometry.Point3d(0, 0, 0)
Dim myCircle As New DatabaseServices.Circle(CenterPoint, New Geometry.Vector3d(0, 0, 1), 1.5)
myCircle.Color = Colors.Color.FromRgb(200, 0, 200)
'Draw to the Block
myBTR.AppendEntity(myCircle)
myBT.Add(myBTR)
'Commit the Transaction
trans.AddNewlyCreatedDBObject(myBTR, True)
trans.Commit()
End Using
End Using
End Sub
<CommandMethod("insertcircle")> _
Public Sub InsertBlockB()
Dim myTransMan As DatabaseServices.TransactionManager
Dim myTrans As DatabaseServices.Transaction
Dim myDwg As Document
Dim myBT As BlockTable
Dim myBTR As BlockTableRecord
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument()
Dim ed As Editor = doc.Editor
myDwg = Application.DocumentManager.MdiActiveDocument
myTransMan = myDwg.TransactionManager
myTrans = myTransMan.StartTransaction
'Open the database for Write
myBT = myDwg.Database.BlockTableId.GetObject(Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead)
myBTR = myBT(BlockTableRecord.ModelSpace).GetObject(Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)
'Insert the Block
Dim myBlockRef As New DatabaseServices.BlockReference( _
New Geometry.Point3d(2, 3, 0), myBT("CircleBlock"))
myBlockRef.Rotation = 45 * Math.PI / 180
myBlockRef.Layer = myLayerName
myBTR.AppendEntity(myBlockRef)
'Commit the Transaction
myTrans.AddNewlyCreatedDBObject(myBlockRef, True)
myTrans.Commit()
'Dispose of the Transaction Objects
myTrans.Dispose()
myTransMan.Dispose()
End Sub