明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1224|回复: 3

求助

[复制链接]
发表于 2004-5-3 21:13:00 | 显示全部楼层 |阅读模式
Dim inspoint(0 To 2) As Double
inspoint(0) = 0
inspoint(1) = 0
inspoint(2) = 0
ThisDrawing.ModelSpace.InsertBlock inspoint, "c:\program files\acad2000\tch14\sys\abcd.dwg", 1, 1, 1, 0 我想修改块abcd.dwg的属性,请问如何做?先谢谢了
发表于 2004-5-4 08:59:00 | 显示全部楼层

Signature

RetVal = object.GetAttributes()

Object

MSITStore:D:\Program%20Files\AutoCAD%202005\help\acadauto.chm::/idh_blockref_object.htm" target="_blank" >BlockRef, MSITStore:D:\Program%20Files\AutoCAD%202005\help\acadauto.chm::/idh_externalreference_object.htm" target="_blank" >ExternalReference, MSITStore:D:\Program%20Files\AutoCAD%202005\help\acadauto.chm::/idh_minsertblock_object.htm" target="_blank" >MInsertBlock
The object or objects this method applies to.

RetVal

Variant (array of AttributeReference objects)
The array of MSITStore:D:\Program%20Files\AutoCAD%202005\help\acadauto.chm::/idh_attributeref_object.htm" target="_blank" >AttributeReference objects.

Remarks

This method returns an array of editable attribute references attached to the block reference.

You can only return the constant attributes for an external reference. To find the constant attributes of an external reference or block reference, use the MSITStore:D:\Program%20Files\AutoCAD%202005\help\acadauto.chm::/idh_getconstantattributes.htm" target="_blank" >GetConstantAttributes method. [WEB]http://www.mjtd.com/object/acad2004/idh_getattributes.htm[/WEB]

 楼主| 发表于 2004-5-4 11:53:00 | 显示全部楼层
我还不懂,能不能给个例子
发表于 2004-5-4 20:53:00 | 显示全部楼层
上面的是帮助里的解释,下面的是帮助里的例子:

<RE class=Code>Sub Example_GetAttributes()
    ' This example creates a block. It then adds attributes to that
    ' block. The block is then inserted into the drawing to create
    ' a block reference.
   
    ' 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, "TESTBLOCK")
   
    ' Define the attribute definition
    Dim attributeObj As AcadAttribute
    Dim height As Double
    Dim mode As Long
    Dim prompt As String
    Dim insertionPoint(0 To 2) As Double
    Dim tag As String
    Dim value As String
    height = 1#
    mode = acAttributeModeVerify
    prompt = "Attribute Prompt"
    insertionPoint(0) = 5#: insertionPoint(1) = 5#: insertionPoint(2) = 0
    tag = "Attribute Tag"
    value = "Attribute Value"
   
    ' Create the attribute definition object in model space
    Set attributeObj = blockObj.AddAttribute(height, mode, prompt, insertionPoint, tag, value)
   
   
    ' Insert the block
    Dim blockRefObj As AcadBlockReference
    insertionPnt(0) = 2#: insertionPnt(1) = 2#: insertionPnt(2) = 0
    Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, "TESTBLOCK", 1#, 1#, 1#, 0)
    ZoomAll
   
    ' Get the attributes for the block reference
    Dim varAttributes As Variant
    varAttributes = blockRefObj.GetAttributes
   
    ' Move the attribute tags and values into a string to be displayed in a Msgbox
    Dim strAttributes As String
    Dim I As Integer
    For I = LBound(varAttributes) To UBound(varAttributes)
        strAttributes = strAttributes &amp; "  Tag: " &amp; varAttributes(I).TagString &amp; _
                        "   Value: " &amp; varAttributes(I).textString &amp; "    "
    Next
    MsgBox "The attributes for blockReference " &amp; blockRefObj.name &amp; " are: " &amp; strAttributes, , "GetAttributes Example"
   
    ' Change the value of the attribute
    ' Note: There is no SetAttributes. Once you have the variant array, you have the objects.
    ' Changing them changes the objects in the drawing.
    varAttributes(0).textString = "NEW VALUE!"
   
    ' Get the attributes
    Dim newvarAttributes As Variant
    newvarAttributes = blockRefObj.GetAttributes
   
    ' Again, display the tags and values
    strAttributes = ""
    For I = LBound(varAttributes) To UBound(varAttributes)
        strAttributes = strAttributes &amp; "  Tag: " &amp; varAttributes(I).TagString &amp; _
                        "   Value: " &amp; varAttributes(I).textString &amp; "    "
    Next
    MsgBox "The attributes for blockReference " &amp; blockRefObj.name &amp; " are: " &amp; strAttributes, , "GetAttributes Example"
   
End Sub</PRE>
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-28 06:36 , Processed in 0.161034 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表