.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Editing Block Attributes Values

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Amremad
652 Views, 2 Replies

Editing Block Attributes Values

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

 

 

2 REPLIES 2
Message 2 of 3
norman.yuan
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

Message 3 of 3
santoshr0114
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost