This one is from my working code
See if that helps
{code}
Public Function AddHatch(ByVal dbObjIds As ObjectIdCollection) As ObjectId
Dim doc As Document = AcadApp.DocumentManager.MdiActiveDocument
Dim docklock As DocumentLock = doc.LockDocument()
Dim db As Database = HostApplicationServices.WorkingDatabase()
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor()
Dim pHatch As New Hatch
Using tr As Transaction = db.TransactionManager.StartTransaction
Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
'Append newly created hatch to database
btr.AppendEntity(pHatch)
tr.AddNewlyCreatedDBObject(pHatch, True)
'Set hatch plane, normal, elevation
Dim norm As Vector3d = New Vector3d(0.0, 0.0, 1.0)
pHatch.Normal = norm
pHatch.Elevation = 0.0
'Set hatch layer to "0"
pHatch.Layer = "0"
'Set hatch color to 252
pHatch.ColorIndex = 252
'Set hatch scale to 2
pHatch.PatternScale = 2.0
'Set hatch angle to 45 deg
pHatch.PatternAngle = Math.PI / 4
'Set hatch pattern to EARTH predefined type
pHatch.SetHatchPattern(HatchPatternType.PreDefined, "EARTH")
'Set Associativity
pHatch.Associative = False 'optional?
'Append an external contour loop to hatch boundary
pHatch.AppendLoop(HatchLoopTypes.External, dbObjIds)
'Elaborate hatch contour
pHatch.EvaluateHatch(True)
'Commit transaction
tr.Commit()
End Using
docklock.Dispose()
Return pHatch.ObjectId
End Function
{code}
~'J'~
_____________________________________
C6309D9E0751D165D0934D0621DFF27919