Revit becomes slow after apply automatic join

Revit becomes slow after apply automatic join

mm1452
Enthusiast Enthusiast
993 Views
3 Replies
Message 1 of 4

Revit becomes slow after apply automatic join

mm1452
Enthusiast
Enthusiast

Hi,

 

When I use the automatic join external tool, other built in Revit tools becomes slow when starting the command like when I press "vv" Revit takes a lot of time to show the visibilty window. I think there is a something wrong in my code.

 

        public void joinSelection(ElementSet wallsFloors)
        {
            using (Transaction t = new Transaction(doc, "Join All Walls/Floors"))
            {
                t.Start();
                foreach (Element e1 in wallsFloors)
                {
                
                    foreach (Element e2 in wallsFloors)
                    {
                        try
                        {
                            if (!(JoinGeometryUtils.AreElementsJoined(doc, e1, e2)))
                            {
                                JoinGeometryUtils.JoinGeometry(doc, e1, e2);
                            }
                        }
                        catch (Exception)
                        {

                        }

                    }

                }
                t.Commit();
            }
        }

Kindly explain the reason and advise what shoud I do to make revit quick as usual.

 

Thanks in advance.

0 Likes
994 Views
3 Replies
Replies (3)
Message 2 of 4

arnostlobel
Alumni
Alumni

mm1452:

 

it greatly depends on when your joinSelection routine is executed. For example if it is executed as part of your external command, then it cannot possibly have any influence on Revit performance outside th econtext of your command. However, if it is executed, say, during an Idling event, than naturally aone potentially slow process like yours could slow down Revit between commands.

 

That being said, I do not see anything seriously wrong with your code, beside a few rather minor things:

  1. you should test whether e1 equals e2 before you test whether they are joined  (not doing so could have a consequence)
  2. you should test result of transaction.commit
  3. you should not catch all exceptions - you should only catch exceptions you expect and can recover from
Arnošt Löbel
0 Likes
Message 3 of 4

mm1452
Enthusiast
Enthusiast
Dear Arnošt,

joinSelection routine is executed as part of your external command, I'm sure it is the main reason of the model slowness because I have make two tests:
1) I have deleted all the elements in the model >> result= the model became very good
2) Creating new elements (which are more complicated the deleted ones) >> result= the model still very good
3) Applying the automaticJoin external command on the new elements >> result= the model became very slow.

note:
at the three above stages, any external command had a very good performance.. but the built in commands became very slow at stage 3

hope you solve this puzzle 😞
0 Likes
Message 4 of 4

arnostlobel
Alumni
Alumni
mm1452: Unfortunately, I won't be able to help, for I am as puzzled as your are over this problem. On the surface there should be absolutely no performance degradation after your command finishes no matter what the command does. I mean, does within reason, of course, which your command does. You start a transaction, you apply changes to the model, and you close the transaction. The model regenerates; done; everything's like new. Naturally, if your changes made the model very complex and huge, view refreshing could be slow, but there should be no effect on starting commands. Unless... there are other software in play. I can imagine add-ins trying to work with your updated model during Idling events that will follow when your command ends. I know there's a lot of add-ins that do pretty heavy stuff in their Idling event handlers. Such add-ins can make Revit appear very slow for very long time. That's all I have 😞 I could use a few more details, however. I wonder if the slowness ever ceases. Or is Revit slow for the rest of the session after your command? (I mean, like even one hour or so.) Also, does anything change - performance wise - if you undo your command from the undo menu? Thank you Arno?t
Arnošt Löbel
0 Likes