Jason,
Try this.....For VB.Net 2005.......
[code]
Private Shared Sub Hatch(ByVal obj As AcadDB.ObjectId)
Dim db As AcadDB.Database = AcadApp.DocumentManager.MdiActiveDocument.Database
Dim tm As AcadDB.TransactionManager = db.TransactionManager
Dim NewID As AcadDB.ObjectId = AcadDB.ObjectId.Null
Using myT As AcadDB.Transaction = tm.StartTransaction()
Try
Using table As AcadDB.BlockTable = TryCast(myT.GetObject(db.BlockTableId, AcadDB.OpenMode.ForRead, False), AcadDB.BlockTable)
Using record As AcadDB.BlockTableRecord = TryCast(myT.GetObject(table(AcadDB.BlockTableRecord.ModelSpace), AcadDB.OpenMode.ForWrite, False), AcadDB.BlockTableRecord)
Dim o As AcadDB.Entity = DirectCast(myT.GetObject(obj, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead, False), AcadDB.Entity)
Dim h As New AcadDB.Hatch()
h.SetDatabaseDefaults()
h.Layer = o.Layer
o.Dispose()
h.HatchStyle = Autodesk.AutoCAD.DatabaseServices.HatchStyle.Normal
h.SetHatchPattern(Autodesk.AutoCAD.DatabaseServices.HatchPatternType.PreDefined, "ANSI31")
Dim oID As AcadDB.ObjectId = record.AppendEntity(h)
If oID.IsValid Then
NewID = oID
h.Associative = True
myT.AddNewlyCreatedDBObject(h, True)
myT.Commit()
Else
myT.Abort()
End If
End Using
End Using
Catch ex As Exception
myT.Abort()
End Try
End Using
If NewID <> AcadDB.ObjectId.Null Then
Using myT As AcadDB.Transaction = tm.StartTransaction()
Try
Dim h As AcadDB.Hatch = DirectCast(myT.GetObject(NewID, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite, False), AcadDB.Hatch)
Dim mylist As New AcadDB.ObjectIdCollection(New AcadDB.ObjectId() {obj})
h.AppendLoop(AcadDB.HatchLoopTypes.Default, mylist)
h.EvaluateHatch(False)
h.Dispose()
myT.Commit()
Catch ex As Exception
myT.Abort()
End Try
End Using
End If
tm.Dispose()
db.Dispose()
End Sub
[/code]
Start Transaction
Step 1. Create the hatch object
Step 2. Setup how the hatch will look
Step 3. Add it to the Block Table record
Step 4. Now, assign the associativity
Step 5. Let the transaction know of the new object and commit
End Transaction
Start Transaction
Step 6. Open the hatch object and append the loops
Step 7. Evaluate
Step 8. Commit
End Transaction
Hope this is what you are looking for. I found this info out from trial and error and also reading the ObjectARX 2006 documentation on "AcDbHatch::setAssociative Function".
Good Luck,
C