Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

[help] Handle warning before commit

Anonymous

[help] Handle warning before commit

Anonymous
Not applicable

Follow this topic : 

https://thebuildingcoder.typepad.com/blog/2014/05/on-handling-warnings-and-failures.html

We just can dismiss warning when we committed transaction,we want  some of warnings to process with commit , and some of warning to cancel.  But to save time ,we dont allow revit regenerate document many times  so we commit transaction of the end of process. 

Can I dismiss warning before I commit transaction,  

 

 

0 Likes
Reply
Accepted solutions (1)
2,279 Views
9 Replies
Replies (9)

MarryTookMyCoffe
Collaborator
Collaborator

not in the way you thing, but I thing you can do a subtransaction in transaction to catch warring of part that are important for you to progress further in  your app.
https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/Revit-API/files/GUID-...

http://www.revitapidocs.com/2015/801e5f17-cab0-044d-835c-a39592374f89.htm

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug

Anonymous
Not applicable

Thank mary so much ,

But i have some trouble , try catch my code but i didnt get any message from catch but my sub transaction return rollback. Please help me, how do we know why subtransaction rollback 

0 Likes

MarryTookMyCoffe
Collaborator
Collaborator
Accepted solution

I never tested it in full, but maybe when subtranasction end or roll back, the main transaction get warring or errors to a failuresPreprocessor class:
https://help.autodesk.com/view/RVT/2015/ENU/?guid=GUID-52A45CC1-3BB4-48B4-BFC7-F6F8666C2AA4

 

unfortunately revit api was made for small macros.

It is possible that you will need to make many transaction, many times there is just no easy way out in Revit API.
what exactly you try to do? some times it is easier to catch invalid parameters before transaction.

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug

Anonymous
Not applicable

Thank marry so much, 

I found reason why because my model has too many warning so they always return rollback, I solve all warning and they return committed , everything now is fine. Thank you for your help. Have a good day 🙂 

0 Likes

Anonymous
Not applicable

One more thing, to improve performance of code I use this syntax:

Snippet

[Regeneration(RegenerationOption.Manual)]

 

but the document still regenerates when I commits transaction. Do you have any solution to limit number of times the document regenerates?

0 Likes

MarryTookMyCoffe
Collaborator
Collaborator

commit always will regenerate document there is nothing you can do about it.
the

[Regeneration(RegenerationOption.Manual)]

is thing from past(I thing before 2013 or something like that) when we could make it automatic. There is not much you can do about optimization, my suggest is to use:
if you create many object

document.Create.NewFamilyInstances2 - I thing it work a little faster than making all element with document.Create.NewFamilyInstances.

 

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug

Anonymous
Not applicable

One more question, I dont know why I cannot get failure handle  when transaction return rollback , i can not get list of element  cause error. Do you have any idea?

0 Likes

MarryTookMyCoffe
Collaborator
Collaborator

I thing that answer is here:
http://www.revitapidocs.com/2016/d99de9ee-168e-a114-1255-0cea9f317efb.htm

you can add handling option to a roll back

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug

Anonymous
Not applicable

I tried, but it doesn't work 😞

0 Likes