.NET

Reply
Distinguished Contributor
SRSDS
Posts: 243
Registered: ‎04-15-2011
Message 1 of 4 (151 Views)

Transaction not needed?

151 Views, 3 Replies
05-20-2013 10:59 AM

Just curious about this. Why would the following code not require a transaction?

Essentially filtering and erasing objects.

 

            Dim psr As PromptSelectionResult = ed.SelectAll(filter)
            If psr.Status = PromptStatus.OK Then
                Dim idarray As ObjectId() = psr.Value.GetObjectIds()
                For Each ObjID In idarray
                    Dim Ent As Entity = ObjID.GetObject(OpenMode.ForWrite)
                    If TypeOf Ent Is Polyline Then
                        Ent.Erase()
                    End If
                Next
            End If

 

 

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 2 of 4 (133 Views)

Re: Transaction not needed?

05-20-2013 02:19 PM in reply to: SRSDS

SRSDS wrote:

Just curious about this. Why would the following code not require a transaction?

Essentially filtering and erasing objects.

 

            Dim psr As PromptSelectionResult = ed.SelectAll(filter)
            If psr.Status = PromptStatus.OK Then
                Dim idarray As ObjectId() = psr.Value.GetObjectIds()
                For Each ObjID In idarray
                    Dim Ent As Entity = ObjID.GetObject(OpenMode.ForWrite)
                    If TypeOf Ent Is Polyline Then
                        Ent.Erase()
                    End If
                Next
            End If

 

 


The code does require a transaction. If it doesn't fail, it is because there is an active transaction in the document you're running it in.

 

The ObjectId.GetObject() method simply calls the GetObject() method of the active Transaction returned by the TransactionManager's TopTransaction property, and if there is no active transaction, it will fail.

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 3 of 4 (129 Views)

Re: Transaction not needed?

05-20-2013 02:21 PM in reply to: SRSDS
Take a look at this page for more
http://spiderinnet1.typepad.com/blog/2012/04/open-direct-or-use-transaction-to-getobject-in-autocad-...
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Distinguished Contributor
SRSDS
Posts: 243
Registered: ‎04-15-2011
Message 4 of 4 (94 Views)

Re: Transaction not needed?

05-22-2013 04:11 AM in reply to: Hallex

Thankyou both. I did have an open transaction in a parent routine. I didn't realise that it was being used.

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