suwei0072000 发表于 2003-3-30 17:16:00

插入图块出错[求助]

本帖最后由 作者 于 2003-3-30 17:16:04 编辑

您好:
我想将图形组意图快的形式插入,但试了几次都报错
现写了一个简化的代码(画个圆然后以图块形式插入)
Public leoblock As AcadBlock
   
Public Sub leopump()
    Dim leocircle As AcadCircle
    Dim centerp(0 To 2) As Double
    Dim leoblockref As AcadBlockReference
    Dim insertp
'画圆
    centerp(0) = 0
    centerp(1) = 0
    centerp(2) = 0
    Set leocircle = leoblock.AddCircle(centerp, 10)
   
'图形生成
    ThisDrawing.Regen acActiveViewport

'插入图块
    insertp = ThisDrawing.Utility.GetPoint(, "输入插入点:")
    Set leoblockref = ThisDrawing.ModelSpace.InsertBlock_
                                 (insertp, "leopump", 1, 1, 1, 0)
End Sub
始终抱错,找了一小时也查不出

china-hz 发表于 2003-3-31 08:40:00

看看sample

Sub Example_InsertBlock()
    ' This example creates a block containing a circle.
    ' It then inserts the block.

    ' Create the block
    Dim blockObj As AcadBlock
    Dim insertionPnt(0 To 2) As Double
    insertionPnt(0) = 0#: insertionPnt(1) = 0#: insertionPnt(2) = 0#
    Set blockObj = ThisDrawing.Blocks.Add(insertionPnt, "CircleBlock")
   
    ' Add a circle to the block
    Dim circleObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 0: center(1) = 0: center(2) = 0
    radius = 1
    Set circleObj = blockObj.AddCircle(center, radius)
   
    ' Insert the block
    Dim blockRefObj As AcadBlockReference
    insertionPnt(0) = 2#: insertionPnt(1) = 2#: insertionPnt(2) = 0
    Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, "CircleBlock", 1#, 1#, 1#, 0)
   
    ZoomAll
   
End Sub
页: [1]
查看完整版本: 插入图块出错[求助]