Revit API help with 2 sequential transactions

Revit API help with 2 sequential transactions

Anonymous
Not applicable
878 Views
4 Replies
Message 1 of 5

Revit API help with 2 sequential transactions

Anonymous
Not applicable
Currently, I made a tool to rename view numbers (“Detail Number”) on a sheet based on their location on the sheet. Where this is breaking is the transactions. Im trying to do two transactions sequentially in Revit Python Shell. I also did this originally in dynamo, and that had a similar fail , so I know its something to do with transactions. Transaction #1: Add a suffix (“-x”) to each detail number to ensure the new numbers won’t conflict (1 will be 1-x, 4 will be 4-x, etc) Transaction #2: Change detail numbers with calculated new number based on viewport location (1-x will be 3, 4-x will be 2, etc) Better visual explanation here: https://www.docdroid.net/EP1K9Di/161115-viewport-diagram-.pdf.html Attached is the python file, but essentially what im trying to do is: # <---- Make unique numbers t = Transaction(doc, 'Rename Detail Numbers') t.Start() for i, viewport in enumerate(viewports): setParam(viewport, "Detail Number",getParam(viewport,"Detail Number")+"x") t.Commit() # <---- Do the thang t2 = Transaction(doc, 'Rename Detail Numbers') t2.Start() for i, viewport in enumerate(viewports): setParam(viewport, "Detail Number",detailViewNumberData[i]) t2.Commit() Attached is py file
0 Likes
879 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk

dear chris,

 

please research this topic in depth and give it a nice deep ponder:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.33

 

the behaviour you describe indicates (well, hints at, very subtly) a need for regeneration.

 

cheers,

 

jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 5

matthew_taylor
Advisor
Advisor
Hi Chris,
To follow up on Jeremy's very insightful suggestion, check out transactionGroups and assimilate.

Cheers,

-Matt

Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
0 Likes
Message 4 of 5

jeremytammik
Autodesk
Autodesk

Thank you Matt, fully concur.

 

I added more background info in my answer to the same question on StackOverflow:

 

http://stackoverflow.com/questions/40728351/2-sequential-transactions-setting-detail-number-revit-ap...

 

Cheers, 

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 5

jeremytammik
Autodesk
Autodesk

More was said on this issue in the StackOverflow thread, plus a completely different underlying problem was unearthed.

 

I summarised the entire discussion on The Building Coder:

 

http://thebuildingcoder.typepad.com/blog/2016/12/need-for-regen-and-parameter-display-name-confusion...

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes