.NET

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

Editing Block Attributes Values

264 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

 

 

*Expert Elite*
norman.yuan
Posts: 987
Registered: ‎04-27-2009
Message 2 of 3 (254 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: 162
Registered: ‎03-21-2012
Message 3 of 3 (225 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
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.