Regenerate during creation of DetailCurve

Regenerate during creation of DetailCurve

bastien.marandLK9X3
Explorer Explorer
1,269 Views
5 Replies
Message 1 of 6

Regenerate during creation of DetailCurve

bastien.marandLK9X3
Explorer
Explorer

Hi everyone,

 

I'm am new in the  Revit API sphere and I am currently looking for some help. I have an issue with a creation of a DetailCurve. The issue is the following : When I start my plug-in it create several DetailCurve and it's okay there is no problem but after I try the same action but it regenrate my model between each creation. That took a very longue time so.

Here is my creation : 

DetailCurve ligneDeDetail = MesDonnees.docHote.Create.NewDetailCurve(vue, lienGaineApp);

vue is the view where I want to create my DetailCurve and lienGaineApp is a Line.

Does someone have encoutered this issue  ?

 

Thank you all for your help

0 Likes
Accepted solutions (2)
1,270 Views
5 Replies
Replies (5)
Message 2 of 6

RPTHOMAS108
Mentor
Mentor

That is the way I would create a detail line, it is the only way I'm familiar with.

 

Perhaps however more context is required. How many lines you are creating and how often?

0 Likes
Message 3 of 6

bastien.marandLK9X3
Explorer
Explorer

Hi,

 

Thank you for your reply.

The problem is not the numerous of line I want to create because I used this command earlier in my code and it worked fine. The problem is that when I start the plug-in in Revit, the software regenerate the model between each creation of a line.

In the model there are approximatively 50 lines to create in the whole model.

There is two part in my plug-in :

FIRST PART : Draw a line between space and object (as plumbing fixtures for example)

SECOND PART : Update of the lines (deletion of previous lines and creation of the new lines)

The first part is okay but the second takes to many times because of regeneration.

 

Thank you for your help

0 Likes
Message 4 of 6

RPTHOMAS108
Mentor
Mentor
Accepted solution

There used to be two Regeneration options applied via attributes to the interface implementation

RegenerationOption.Automatic

RegenerationOption.Manual

 

Now there is only the Manual option and the RevitAPI.chm states this about it:

 

"The API framework will not regenerate after every model level change. Instead, you may use the regeneration APIs to force update of the document after a group of changes. SuspendUpdating blocks are unnecessary and should not be used. Performance of multiple modifications of the Revit document should be faster than RegenerationOption.Automatic. Because this mode suspends all updates to the document, your application should not read data from the document after it has been modified until the document has been regenerated, or it runs the risk of accessing stale data. This mode will be only option in a future release."

 

It would seem from the description that your command should not regenerate after each line added removed however noted elsewhere is that Regenerate is called upon transaction commit.

 

I think this section of chm needs to be rewritten because Automatic was removed long ago and people may wonder what a SuspendUpdating block is.

 

"The API framework will not regenerate after every model level change. Instead, you may use the regeneration APIs to force update of the document after a group of changes." 

 

Not sure this statement above is completely true either since it is noted elsewhere that Regenerate is called upon transaction commit.

 

You should commit transaction after all lines added and removed, should only get one regeneration then I assume. Could also add logic to see if anything unchanged could remain, to cut down on adding and removing all lines.

 

Adding and removing may also bulk up the size of your file. It has been noted to me in the past (especially with workshared model) that some database records will remain until compact model option is used.

0 Likes
Message 5 of 6

bastien.marandLK9X3
Explorer
Explorer

Oh ok, I'm gonna try something with a " big" transaction to see if this is the thing. I come back to you the fastest I can because I am on an other work right now. 

 

Thank you for your help

0 Likes
Message 6 of 6

bastien.marandLK9X3
Explorer
Explorer
Accepted solution

Hi there,

 

I told you that I will be back later because I have lots of work to do but not in relation with programing, so I am here. Sorry for the time I took.

So here is the thing. I tried many ideas but nothing works. So I tried to restart from scratch. I improve my code by deleting some lines and replacing my Transaction and it seems to work. I think the problem came from my "Transaction" as you said. I put a global transaction (outside a foreach not inside) and this is a lot faster than before .

Thank you again for your time

See you around

 

 

0 Likes