乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: SuperNim143

[编程交流] .中的NET Update块属性

[复制链接]

44

主题

3166

帖子

2803

银币

中流砥柱

Rank: 25

铜币
557
发表于 2022-7-6 20:12:15 | 显示全部楼层
您好,我试图编辑块引用中的属性,但我认为您的程序工作正常,但从未更改我的私有属性。你知道为什么吗?
 
回复

使用道具 举报

1

主题

6

帖子

5

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 20:19:39 | 显示全部楼层
回复

使用道具 举报

1

主题

6

帖子

5

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 20:24:09 | 显示全部楼层
I feel like I'm close, but something is still missing.
I have made a modification to factor layout into it.
I have been able to confirm that it is now iterating through the correct block and does pull in that attribute, however, it still does not recognize the tag as equal to the attTag that is passed in. I'm attaching a quick screen shot of the issue I have with my output. If you look at the attribute names you can see that it creates a new attribute with an identical name.
 
  1. Private Sub UpdateBlockAttribute(acBlkRef As BlockReference, attTag As String, textValue As String, Optional modelSpace As Boolean = True)       Dim acBlkTable As BlockTable = Nothing       Dim acBlkDef As BlockTableRecord = Nothing       Dim acCurLyr As ObjectId       Dim acAttRef As DatabaseServices.AttributeReference = Nothing       Dim attFound As Boolean = False       Dim acSpaceID As ObjectId       Dim layoutDict As DBDictionary       Dim dictEntry As DictionaryEntry       Dim layout As Layout       Dim layoutID As ObjectId       Try           layoutDict = acTrans.GetObject(acdb.LayoutDictionaryId, OpenMode.ForRead, False)           'If modelSpace = False Then           'acSpaceID = acBlkTable(BlockTableRecord.PaperSpace)           'Else           'acSpaceID = acBlkTable(BlockTableRecord.ModelSpace)           ' End If           ' acBlkDef = DirectCast(acTrans.GetObject(acSpaceID, OpenMode.ForRead), BlockTableRecord)           If (layoutDict  Nothing) Then               For Each dictEntry In layoutDict                   layoutID = dictEntry.Value                   layout = acTrans.GetObject(layoutID, OpenMode.ForRead)                   acBlkTable = acTrans.GetObject(acdb.BlockTableId, OpenMode.ForRead)                   acBlkDef = DirectCast(acBlkTable(acBlkRef.Name).GetObject(OpenMode.ForRead), BlockTableRecord)                   Dim acLyrTbl As LayerTable = acTrans.GetObject(acdb.LayerTableId, OpenMode.ForRead)                   acCurLyr = acdb.Clayer                   If acLyrTbl.Has("0") Then                       acdb.Clayer = acLyrTbl("0")                   End If                   For Each acEntId In acBlkDef                       Dim acEnt As Entity = acTrans.GetObject(acEntId, OpenMode.ForRead)                       If Not IsNothing(acEnt) Then                           If acEnt.GetType.ToString = "Autodesk.AutoCAD.DatabaseServices.AttributeDefinition" Then                               Dim acAttDef As AttributeDefinition = DirectCast(acEnt, AttributeDefinition)                               If Not IsNothing(acAttDef) And Not acAttDef.Constant Then                                                                       acAttRef = New AttributeReference                                   acAttRef.SetAttributeFromBlock(acAttDef, DirectCast(acTrans.GetObject(acBlkRef.ObjectId, OpenMode.ForRead), BlockReference).BlockTransform)                                   If acAttDef.Tag.ToString = attTag Or acAttRef.Tag.ToString = attTag.ToString Then                                       attFound = True                                       Exit For                                   End If                           End If                       End If                       End If                   Next                   If attFound = True Then                       Exit For                   End If               Next           End If           DirectCast(acTrans.GetObject(acBlkRef.ObjectId, OpenMode.ForRead), BlockReference).AttributeCollection.AppendAttribute(acAttRef)           'IF THE ATTRIBUTE DOES NOT EXIST, ADD A NEW ONE...           If Not attFound Then               acAttRef.Tag = attTag               acAttRef.Justify = AttachmentPoint.MiddleCenter               acTrans.AddNewlyCreatedDBObject(acAttRef, True)               acAttRef.UpgradeOpen()           End If           acAttRef.TextString = textValue           acAttRef.DowngradeOpen()           'acBlkDef.SynchronizeAttributes()           acdb.Clayer = acCurLyr       Catch ex As Exception           MsgBox("Update Block Attribute: " & ex.Message & acAttRef.BlockName.ToString & " - " & acAttRef.Tag.ToString)       End Try   End Sub
 
paperspace blocks.docx
回复

使用道具 举报

0

主题

1

帖子

1

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-6 20:28:47 | 显示全部楼层
Hi, i try to edit the attributes in a Block reference, but i think your program work goog, but never change my private attributes. You know why?
         
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-4 14:56 , Processed in 0.357916 second(s), 58 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表