https://www.cnblogs.com/twofly/p/5093876.html【1.pdf】点击下载此文件
''' <summary>
''' 图案填充
''' </summary>
''' <param name="db">图形数据库</param>
''' <param name="loopTypes"></param>
''' <param name="patternName">图案名称</param>
''' <param name="scale">填充比例</param>
''' <param name="degree">旋转角度</param>
''' <param name="entid">边界图形的ObjectId</param>
''' <returns></returns>
<System.Runtime.CompilerServices.Extension> _
Public Shared Function HatchEnity(db As Database, loopTypes As List(Of HatchLoopTypes), patternName As String, scale As Double, degree As Double, ParamArray entid As ObjectId()) As ObjectId
' 一个方法只能传递一个可变参数 且需要放在最后
Dim hatchId As ObjectId = ObjectId.Null
Using trans As Transaction = db.TransactionManager.StartTransaction()
' 声明一个图案填充对象
Dim hatch As New Hatch()
' 设置填充比例
hatch.PatternScale = scale
' 设置填充类型和图案名称
hatch.SetHatchPattern(HatchPatternType.PreDefined, "ANGLE")
' 加入图形数据库
Dim bt As BlockTable = CType(trans.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
Dim btr As BlockTableRecord = CType(trans.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
hatchId = btr.AppendEntity(hatch)
trans.AddNewlyCreatedDBObject(hatch, True)
' 设置填充角度
hatch.PatternAngle = degree
' 设置关联
hatch.Associative = True
' 设置边界图形和填充方式
Dim obIds As New ObjectIdCollection()
' 依次添加图形填充样式
Dim i As Integer = 0
While i < entid.Length
obIds.Clear()
obIds.Add(entid(i))
hatch.AppendLoop(loopTypes(i), obIds)
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
' 计算填充并显示
hatch.EvaluateHatch(True)
' 提交事务
trans.Commit()
End Using
Return hatchId
End Function