找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 962|回复: 3

[求助]:块属性问题求教

[复制链接]
发表于 2005-11-25 09:28:36 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
怎么读取图档同块的属性,并修改该块的属性
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2005-11-25 13:22:18 | 显示全部楼层
GetAttributes 方法
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-11-25 14:30:29 | 显示全部楼层
GetAttributes 方法 是读取属性值,我想读取属性并修改该属性值,改这么办? 请斑主指教,谢谢

另外请问 怎样移动选择集?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2005-12-2 19:24:57 | 显示全部楼层
简单

AutoCAD自带的VBA帮助里关于“快属性编辑”一句经典的话:
[' Note: There is no SetAttributes. Once you have the variant array, you have the objects.
(翻译:'注意:没有SetAttributae这个方法; 你一旦拥有了属性Variant数组,你有拥有了这个对象。)] 意思很简单:当你通过GetAttribute获取了块的属性(比如赋给Dim varAttributes As Variant它了,
),那么,varAttributes这个变量就能代表“块属性”这个对象,你可以对它进行操作,就能编辑块的属性值。这个做法在VBA的对象里很少见。

现在借花献佛,把Autocad自带的例子给你看看。

================================================
================================================
================================================


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 & "  Tag: " & varAttributes(I).TagString & _
                        "   Value: " & varAttributes(I).textString & "    "
    Next
    MsgBox "The attributes for blockReference " & blockRefObj.name & " are: " & strAttributes, , "GetAttributes Example"
   
    ' Change the value of the attribute
    ' Note: There is no SetAttributes. Once you have the variant array, you have the objects.[/COLOR]
    ' 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 & "  Tag: " & varAttributes(I).TagString & _
                        "   Value: " & varAttributes(I).textString & "    "
    Next      '''////这个循环就在修改属性值!你要的在这儿。。。。
[/COLOR]
    MsgBox "The attributes for blockReference " & blockRefObj.name & " are: " & strAttributes, , "GetAttributes Example"
   
End Sub



================================================
================================================
================================================.

师父就在身边:AutoCAD帮助-开发人员文档,是个好东东。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-28 21:28 , Processed in 0.210716 second(s), 37 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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