Message 1 of 15
Add Hatch No Error but Desn't Show
Not applicable
10-25-2011
09:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Guys,
I need to add a hatch fill polyline area but leave the text island out.
What I did is put put Polyline ID and Text island ID into an ObjectIDCollection. The code doesn't throw any error but I can't see the hatch.
Public Function AutoCADAddHatch(ByRef newAddedHatch As Hatch, ByRef HatchElementIDs As ObjectIdCollection, ByVal HatchColour As Autodesk.AutoCAD.Colors.Color, _
ByVal HatchLayerName As String, Optional ByVal PatternName As String = "SOLID", Optional ByRef strError As String = "") As Boolean
Dim db As Database = acApp.DocumentManager.MdiActiveDocument.Database
Try
Using objTrans As Transaction = db.TransactionManager.StartTransaction
Dim objBT As BlockTable = db.BlockTableId.GetObject(OpenMode.ForWrite)
Dim objNewBTR As New BlockTableRecord
objNewBTR.Name = "ZoneHatch"
objBT.Add(objNewBTR)
newAddedHatch = New Hatch
objNewBTR.AppendEntity(newAddedHatch)
objTrans.AddNewlyCreatedDBObject(newAddedHatch, True)
newAddedHatch.SetDatabaseDefaults()
newAddedHatch.SetHatchPattern(HatchPatternType.PreDefined, PatternName)
Dim objTextIDs As New ObjectIdCollection
objTextIDs.Add(HatchElementIDs(1))
newAddedHatch.AppendLoop(HatchLoopTypes.TextIsland, objTextIDs)
Dim objPolyIDs As New ObjectIdCollection
objPolyIDs.Add(HatchElementIDs(0))
newAddedHatch.AppendLoop(HatchLoopTypes.Outermost, objPolyIDs)
newAddedHatch.Color = HatchColour
newAddedHatch.Layer = HatchLayerName
newAddedHatch.Associative = True
newAddedHatch.EvaluateHatch(True)
objTrans.Commit()
End Using
Catch sysex As SystemException
strError = sysex.Message
MError.StorePlanLogError(sysex, sysex.Message, _
CallingProcedure:=STR_MODULE_NAME & "." & "AutoCADAddHatch")
Catch ex As Exception
strError = ex.Message
MError.StorePlanLogError(ex, ex.Message, _
CallingProcedure:=STR_MODULE_NAME & "." & "AutoCADAddHatch")
End Try
End FunctionAny ideas?
Thanks very much