.NET

Reply
Mentor
Amremad
Posts: 217
Registered: ‎08-24-2010
Message 1 of 3 (278 Views)
Accepted Solution

Editing Block Attributes Values

278 Views, 2 Replies
04-02-2013 06:05 AM

hi all

in this code

 Private Function MYSelectionSet(Type As MyType, Name As String) As SelectionSet
        Dim acSelFtr As SelectionFilter
        If Type = MyType.Block Then
            acSelFtr = New SelectionFilter({New TypedValue(DxfCode.BlockName, Name)})
        Else
            acSelFtr = New SelectionFilter({New TypedValue(DxfCode.Start, Name)})
        End If
        MYSelectionSet = Ed.GetSelection(acSelFtr).Value
    End Function
    <CommandMethod("tst")> _
    Public Sub testing()

        Dim MySel As SelectionSet = MYSelectionSet(MyType.Block, "AMR.LEVEL")
        Dim Tr As Transaction = Application.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction()
        If MySel IsNot Nothing Then
            For Each BlKID In MySel.GetObjectIds()
                Dim BlkRef As BlockReference = Tr.GetObject(BlKID, OpenMode.ForWrite)
            
' What can i write here to access for BlkRef Attributes

Next End If Tr.Commit() End Sub

 i need to access BlkRef Attributes (read & write) values

 

 

Once you have in instance of a BlockReference class, you can just loop through its AttributeCollecction property. If you examined the BlockReference class in Object Browser, it would have been fairly obvious.

 

Code would be like:

 

For Each objId As ObjectId in BlkRef.AttributeCollection

  Dim attRef As Attributereference=Tr.GetObject(objId, OpenMode.ForWrite)

  Select Case attRef.Tag.ToUpper()

      Case "AAA"

          attRef="XXX"

      Case "BBB"

          attRef="YYY"

    ...

  End Select

Next

*Expert Elite*
norman.yuan
Posts: 1,063
Registered: ‎04-27-2009
Message 2 of 3 (268 Views)

Re: Editing Block Attributes Values

04-02-2013 06:46 AM in reply to: Amremad

Once you have in instance of a BlockReference class, you can just loop through its AttributeCollecction property. If you examined the BlockReference class in Object Browser, it would have been fairly obvious.

 

Code would be like:

 

For Each objId As ObjectId in BlkRef.AttributeCollection

  Dim attRef As Attributereference=Tr.GetObject(objId, OpenMode.ForWrite)

  Select Case attRef.Tag.ToUpper()

      Case "AAA"

          attRef="XXX"

      Case "BBB"

          attRef="YYY"

    ...

  End Select

Next

Mentor
santoshr0114
Posts: 188
Registered: ‎03-21-2012
Message 3 of 3 (239 Views)

Re: Editing Block Attributes Values

04-02-2013 09:28 PM in reply to: Amremad

amremad_world

 

You can refer the below link to update block atrributes

http://through-the-interface.typepad.com/through_the_interface/2007/07/updating-a-spec.html

Regards
Santosh
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.