Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UIDoc.SaveAndClose() Close is not allowed when there is any open sub-transation

5 REPLIES 5
Reply
Message 1 of 6
david.rock
718 Views, 5 Replies

UIDoc.SaveAndClose() Close is not allowed when there is any open sub-transation

Hello,

 

I am trying to open a family and close the old family however I am reciving the message Close is not allowed when there is any open sub-transation, transation or transation group.

 

My code is something like this:

 

        Dim activeDoc As Document = commandData.Application.ActiveUIDocument.Document
        Dim oldUIDoc As UIDocument = commandData.Application.ActiveUIDocument
       Dim strNextFile As String = "c:\aa.rfa"

         Dim NewUIDoc As UIDocument = commandData.Application.OpenAndActivateDocument(strNextFile)
         Try
               oldUIDoc.SaveAndClose()
          Catch ex As Exception
             MsgBox(ex.Message)
         End Try

 

How do I close any open transactions and is OpenAndActivateDocument creating the ofending transation?

Any ideas?

Thanks

David Rock

5 REPLIES 5
Message 2 of 6

try setting the active document to be the new family opened. 

Message 3 of 6

Hello,

 

Thanks very much for the surgestion.

 

I tried to set the active document to the new family by setting the active view to one in the new family. But was still getting the same exception. "Close is not allowed when there is any open sub-transation, transation or transation group".

 

I tried to move the close to before the OpenAndActivateDocument however I then get the problem the active document cannot be closed.

 

Any other ideas?

 

Kind Regards

David Rock

 

 

 

 

Message 4 of 6
EShulok
in reply to: david.rock

Do you have something like this above your class definition:

<Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Automatic)>

 

If so, you need to change it from Automatic to Manual and handle transactions yourself.  When it is set to Automatic, Revit starts a transaction for you prior to calling your code and then commits the transaction if your code exits successfully.  For information on handling transactions, see: http://wikihelp.autodesk.com/Revit/enu/2012/Help/API_Dev_Guide/0135-Advanced135/0142-Transact142

 

Hope that helps,

Elizabeth Shulok

Structural Integrators, LLC

Message 5 of 6
david.rock
in reply to: EShulok

Thanks very much for the idea.

 

But my code already uses Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual

 

Kind Regards

David Rock

Message 6 of 6
EShulok
in reply to: david.rock

If you comment out the SaveAndClose method, does your code open and activate aa.rfa?  I'm wondering if the call to open that file is failing so that the document you are attempting to close is still the active document (which would give you the same message that you are getting about having an open transaction).

 

Elizabeth

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


Rail Community