Posts: 212
Registered: ‎08-24-2010
Message 1 of 3 (255 Views)
Accepted Solution

Editing Block Attributes Values

255 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)})
            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*
Posts: 959
Registered: ‎04-27-2009
Message 2 of 3 (245 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"


      Case "BBB"



  End Select


Posts: 161
Registered: ‎03-21-2012
Message 3 of 3 (216 Views)

Re: Editing Block Attributes Values

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



You can refer the below link to update block atrributes



You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

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 to get help installing your software.

Ask the Community