.NET

Reply
Valued Contributor
e.g.
Posts: 65
Registered: ‎07-23-2008
Message 1 of 6 (541 Views)

Modify a selected attribute value in a block

541 Views, 5 Replies
02-23-2011 09:17 AM

Hello,

 

I am trying to modify an attribute value in a block which I can select it on screen. The question is: when selecting the block, if the entity I pick is an attribute part of the block, can I get the attribute's tag? What I am trying to do is to update a revision block, changing one particular value but the attribute's tag it is not the same it can be different from drawing to drawing.

 

Thanks for your suggestions.

 

E.G.

*Expert Elite*
norman.yuan
Posts: 946
Registered: ‎04-27-2009
Message 2 of 6 (526 Views)

Re: Modify a selected attribute value in a block

02-23-2011 10:34 AM in reply to: e.g.

You can use Editor.GetNestedEntity() to allow user to directly pick an AttributeReference inside a BlockReference. Then update the Attributereference

 

Distinguished Contributor
Irvin
Posts: 112
Registered: ‎04-22-2009
Message 3 of 6 (504 Views)

Re: Modify a selected attribute value in a block

02-24-2011 12:52 AM in reply to: e.g.

Yuan,

 

About the getnestedentity()

 

My situation:

 

I'm standing in paperspace. This has one vp.

 

Can i use the above method to select an entity in the vp wich i've not opend. So i need to select an entity(drawn in modelspace) while standing in paperspace. I need the to get xrecord information so i can automate my annotation.

 

Hope you understand my problem.

 

Otherwise please let me know.

 

Kind regard,

 

Irvin

Valued Contributor
e.g.
Posts: 65
Registered: ‎07-23-2008
Message 4 of 6 (487 Views)

Re: Modify a selected attribute value in a block

02-24-2011 06:59 AM in reply to: norman.yuan

Thanks Norman,

 

it solved my problem.

 

E.G.

Valued Mentor
KerryBrown
Posts: 263
Registered: ‎11-29-2008
Message 5 of 6 (471 Views)

Re: Modify a selected attribute value in a block

02-24-2011 12:02 PM in reply to: e.g.
How ?
//-------------------------------------------------------

class keyThumper<T> : Lazy<T>;      another  Swamper

Valued Contributor
e.g.
Posts: 65
Registered: ‎07-23-2008
Message 6 of 6 (462 Views)

Re: Modify a selected attribute value in a block

02-24-2011 12:17 PM in reply to: KerryBrown

Here is the sample code(might need some adjusment): whatever text I have in the clipboard I'll paste it into attribute:

    <CommandMethod("44")> _
    Public Sub UpdateAttributeValue()


        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim ed As Editor = doc.Editor
        Dim rs As PromptNestedEntityResult = ed.GetNestedEntity(vbLf & "Select attribute: ")
        Dim sTemp As String = String.Empty
        sTemp = My.Computer.Clipboard.GetText

        If sTemp = String.Empty Then
            MsgBox("There is no text in clipboard. Please copy some..")
            Return
        End If

        If rs.Status = PromptStatus.OK Then
            Dim oid As ObjectId = rs.ObjectId

            Using tr As Transaction = doc.TransactionManager.StartTransaction()

                Dim ent As Entity = DirectCast(tr.GetObject(oid, OpenMode.ForRead), Entity)

                If TypeOf ent Is AttributeReference Then
                    Dim attref As AttributeReference = DirectCast(ent, AttributeReference)
                    attref.UpgradeOpen()
                    attref.TextString = sTemp
                End If


                tr.Commit()

            End Using
        End If

    End Sub

 E.G.

You are not logged in.

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

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

Ask the Community