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: 

[help] Handle warning before commit

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Anonymous
2234 Views, 9 Replies

[help] Handle warning before commit

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,  

 

 

Tags (1)
9 REPLIES 9
Message 2 of 10
MarryTookMyCoffe
in reply to: Anonymous

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
Message 3 of 10
Anonymous
in reply to: MarryTookMyCoffe

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 

Message 4 of 10
MarryTookMyCoffe
in reply to: Anonymous

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
Message 5 of 10
Anonymous
in reply to: MarryTookMyCoffe

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 🙂 

Message 6 of 10
Anonymous
in reply to: MarryTookMyCoffe

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?

Message 7 of 10
MarryTookMyCoffe
in reply to: Anonymous

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
Message 8 of 10
Anonymous
in reply to: MarryTookMyCoffe

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?

Message 9 of 10
MarryTookMyCoffe
in reply to: Anonymous

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
Message 10 of 10
Anonymous
in reply to: MarryTookMyCoffe

I tried, but it doesn't work 😞

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report