sgrya1 发表于 2007-2-13 02:07:36

将阴影区域添加到块。

有人可以解释一下我哪里错了。
我可以在模型空间中创建一个圆形阴影区域,但我现在想直接对块执行相同的绘图。
一件奇怪的事情是,要做到这一点,由于某种原因,circleObj 需要是一个数组圆圈Obj(0 To 0) 作为 AcadEntity,否则它不会附加舱口。
这是我到目前为止编写的用于写入块的代码:我收到一个编译错误,说无法在我显示的位置分配给数组。有没有解决这个问题的方法。为什么它需要是一个数组?
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
jonesy: 添加代码标签
**** Hidden Message *****

Arizona 发表于 2007-2-13 06:17:11

你把circleObj定义为哪里或什么?

Kerry 发表于 2007-2-13 17:55:16

变量“中心”的定义是什么...?

Arizona 发表于 2007-2-13 19:09:33

只是为了澄清,块是非图形的,而块引用是您在绘图中实际看到的。
所以定义和插入块引用是这样的(对不起,这是漫长的一天:
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
页: [1]
查看完整版本: 将阴影区域添加到块。