silenceboy 发表于 2007-6-21 12:08:00

如何修改块的属性

<p></p><p>在程序中自定义属性块后,如何获取并修改块的属性值呢?</p><p>不是块参照</p><p>谢谢</p>

GJY 发表于 2007-6-21 12:39:00

<pre class="Code">Sub Example_Blockttribute()
    ' This example creates an MLeader object and gets and sets values for
    ' the block attribute type.

    Dim points(0 To 5) As Double

    points(0) = 0: points(1) = 4: points(2) = 0
    points(3) = 1.5: points(4) = 5: points(5) = 0

    Dim i As Long

    Dim oML As AcadMLeader
    Set oML = ThisDrawing.ModelSpace.AddMLeader(points, i)
   
    oML.ContentType = acBlockContent
    oML.ContentBlockType = acBlockBox

    Dim sBlock As String

    sBlock = oML.ContentBlockName

    Dim o As AcadEntity
    For Each o In ThisDrawing.Blocks(sBlock)
      If o.ObjectName = "AcDbAttributeDefinition" Then
            Call oML.SetBlockAttributeValue(o.ObjectID, "123")
            MsgBox oML.GetBlockAttributeValue(o.ObjectID)
      End If
    Next o
    Update
    ZoomExtents

End Sub
</pre><p class="body">&nbsp; </p>

silenceboy 发表于 2007-6-22 16:01:00

<p>能不能给个简单的例子,我是在CAD2004下的。</p><p>上面的例子看不懂。</p>
页: [1]
查看完整版本: 如何修改块的属性