将阴影区域添加到块。
有人能解释一下我在哪里吗;我做错了我可以在模型空间中创建圆形阴影区域,但现在我想直接对块进行相同的绘制
一件奇怪的事情是,出于某种原因,circleObj需要是数组circleObj(0到0),否则它就不会';t附加图案填充
这是代码I';到目前为止,我一直在写一个块:我得到一个编译错误,说can';t分配给位置i#039处的数组;已显示。有解决方法吗。为什么它需要是一个数组
Sub MakeBlock()
Dim blockObj As AcadBlock
Dim PatternType As Long
Dim bAssociativity As Boolean
Dim insertionPnt(0 To 2) As Double
insertionPnt(0) = 0
insertionPnt(1) = 0
insertionPnt(2) = 0
With AcadDoc
' Define the block
Set blockObj = .Blocks.Add(insertionPnt, "CircleBlock")
' Define the hatch
PatternType = 0
bAssociativity = True
HatchPattern = "SOLID"
' Create the associative Hatch object in model space
Set hatchObj = blockObj.AddHatch(PatternType, HatchPattern, bAssociativity)
hatchObj.PatternScale = 1
' Create the outer boundary for the hatch. (a circle)
Set circleObj = blockObj.AddCircle(Center, radius) '<=============I get the error on this line
' Append the outerboundary to the hatch object, and display the hatch
hatchObj.AppendOuterLoop (circleObj)
hatchObj.Evaluate
'Add Point
Dim pointObj As AcadPoint
Set pointObj = blockObj.AddPoint(insertionPnt)
End With
End Sub琼斯:添加了代码标记
您将circleObj定义为什么? 什么';s变量#039;中心#039;定义为。。。?
同上';半径#039; 只是为了澄清,块是非图形的,而块参照是您在图形中实际看到的
因此,定义和插入块引用应该是这样的(很抱歉,这一天太长了:
Dim NewBlkName As String
Dim InsertPt(0 To 2) As Double
Dim xScale As Double
Dim yScale As Double
Dim zScale As Double
Dim Rot As Double
Dim objNewBlk As AcadBlockReference
InsertPt(0) = something 'x coord
InsertPt(1) = something 'y coord
InsertPt(2) = something 'z coord
xscale = some value
yscale = some value
zscale = some value
Rot = some angle
NewBlkName = "Some name and path to a drawing"
Set objNewBlk = ThisDrawing.ModelSpace.InsertBlock(InsertPt, NewBlkName, xScale, yScale, zScale, Rot)
HTH it#039;这是一个两步过程
1)dim oCircle作为acadcircle,然后添加tp块
2)dim varLoop(0)作为acadentity
设置varLoop(0)=oCircle 试一试,我使用了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
页:
[1]