by Fenton Webb
After sweating over some Hatch creation code, I thought I better share with you guys how I solved it.
Here’s what I wanted Hatched:
The way I made it work was, to first get all of the boundary geometry as Polylines using the Editor.TraceBoundary function.
This gave me an array of 3 Polylines, shown in red e.g.
Next, I add the polylines to the Database (temporarily) so that the Hatch object can process them (outside of any Transaction) – sorry VB
dim loopObjectIds = new ObjectIdCollection()
Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
' add the loop objects to the dwg
For Each polyline As Polyline In loopObjects
Using curSpace As BlockTableRecord = db.CurrentSpaceId.Open(OpenMode.ForWrite)
' make sure to close the polyline
Now append each polyline obtained by the trace as a separate loop e.g.
For Each objectId In loopObjectIds
Dim ids = New ObjectIdCollection()
Also, here are the different results obtained by setting the Hatch.HatchStyle to:
HatchStyle.Ignore results in this:
HatchStyle.Outer results in this:
results in this:
For the record, I could have used the appendLoop function which takes a Curve2dCollection, however I didn’t on this occasion because I didn’t know that we have equivalent .NET functions to these C++ versions…