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: 

Revit API help with 2 sequential transactions

4 REPLIES 4
Reply
Message 1 of 5
chrisishere
566 Views, 4 Replies

Revit API help with 2 sequential transactions

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
4 REPLIES 4
Message 2 of 5
jeremytammik
in reply to: chrisishere

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

Message 3 of 5

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?
Message 4 of 5

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
in reply to: chrisishere

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

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