试一试,我使用了CopyObjects方法,Bryco在之前的帖子中在这个论坛的某个地方展示了这个方法,搜索一下它;J#039~
- Sub MakeBlock()
- Dim blockObj As AcadBlock
- Dim PatternType As Long
- Dim bAssociativity As Boolean
- Dim Radius As Double
- Radius = 1#
- Dim insertionPnt(0 To 2) As Double
- insertionPnt(0) = 0
- insertionPnt(1) = 0
- insertionPnt(2) = 0
- ' Define the block
- Set blockObj = ThisDrawing.Blocks.Add(insertionPnt, "CircleBlock")
-
- With ThisDrawing.ModelSpace
- ' Define the hatch
- PatternType = 0
- bAssociativity = True
- HatchPattern = "SOLID"
- ' Create the associative Hatch object in model space
- Set hatchobj = .AddHatch(PatternType, HatchPattern, bAssociativity)
- hatchobj.PatternScale = 1
- Dim outerLoop(0) As AcadEntity
- ' Create the outer boundary for the hatch. (a circle)
- Set outerLoop(0) = .AddCircle(insertionPnt, Radius)
- ' Append the outerboundary to the hatch object, and display the hatch
- hatchobj.AppendOuterLoop (outerLoop)
- hatchobj.Evaluate
- 'Add Point
- Dim pointObj As AcadPoint
- Set pointObj = .AddPoint(insertionPnt)
-
- End With
-
- ' The array of primary objects to be copied
- Dim objCollection(0 To 1) As Object
- Dim idPairs 'optional
- ' fill array
- Set objCollection(0) = hatchobj
- Set objCollection(1) = pointObj
- ' etc, etc
- ' copy objects to block
- ThisDrawing.CopyObjects objCollection, blockObj, idPairs
-
- End Sub
|