Unwanted View Refresh

Unwanted View Refresh

floretti
Advocate Advocate
1,241 Views
8 Replies
Message 1 of 9

Unwanted View Refresh

floretti
Advocate
Advocate

Hi all, I created a script to do some controlled purges in the model but after I run it, it triggers a current view refresh which pretty much doubles the time to complete the task. The weird part is that if I use the UI to do the purge manually the refresh doesn't happen.

 

Any ideas why that happens and whether there is a way to programmatically stop the refresh? Thank you.

0 Likes
1,242 Views
8 Replies
Replies (8)
Message 2 of 9

jeremy_tammik
Alumni
Alumni

I am not aware of any method to programmatically stop the refresh.

 

What are the exact manual and API steps that you perform? Some difference might be causing it.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 9

floretti
Advocate
Advocate

Thanks, Jeremy. Via the API I'm collecting all families of a given list of categories. Then I'm collecting all FamilyInstances of those same categories and removing their Families from the Family list. I then call the Delete method.

 

Via the UI I open up the Purge dialog and under the same categories I used in the API I check the families which have no used Family Types and purge them.

 

The outcome is exactly the same (as far as I can see) but oddly the API is causing the view refresh whereas the UI is not.

0 Likes
Message 4 of 9

RPTHOMAS108
Mentor
Mentor

Is this refresh or model regeneration? 

 

If you know it is related to view refresh of active view have you tried setting the active view to something simple such as an empty legend? There are ways of forcing view refresh but I'm not aware of any ways of preventing it.

 

I wouldn't think purge command or other UI commands are the same as API access. For example with API access Revit doesn't know when you want to update a view, it can probably guess this isn't required during purge button. Having said that my experience is that often the view doesn't update until the external command completes.

0 Likes
Message 5 of 9

floretti
Advocate
Advocate

@RPTHOMAS108 Good question, it's actually showing a progress bar on the bottom left of the screen which says "Regenerating". I'm guessing it's not just a refresh then.

 

I tried your suggestion and closed all open views apart from a simple Legend view with some text in it but the regeneration still happened and it took just as long. I also tried using the UI and it was super quick, no regeneration required.

 

It's also looking like the regeneration happens once the command completes.

0 Likes
Message 6 of 9

RPTHOMAS108
Mentor
Mentor

Yes that sounds like model regeneration. Regeneration is set to Manual these days (there is no longer any automatic value for the attribute). So in theory regeneration should only occur if it is called (Document.Regenerate) or after a transaction has been committed.

 

Purge doesn't remove FamilyInstances, just the associated types where there are no instances i.e. things not used in model. Is this what you are aiming to replicate the behaviour of?

0 Likes
Message 7 of 9

floretti
Advocate
Advocate

The goal is to eliminate only the families where none of the types are in use.

 

It's working ok, I'm collecting all families (of some specific given categories) then collecting all FamilyInstances, getting to each FamilyInstance Family (I hope that made sense) and subtracting those from the first collector, leaving me with the unused families which I can then delete.

0 Likes
Message 8 of 9

RPTHOMAS108
Mentor
Mentor

Your methodology makes perfect sense to me. Removing unused is a common task especially before model issue.

 

There is an alternative approach which I favour:

The Building Coder: Purge Unused using Performance Adviser (typepad.com)

 

 

Message 9 of 9

floretti
Advocate
Advocate

Thanks for sharing, Thomas. I've been through some of the links and content in there (there's enough to keep me busy for hours). I might need to digest all that later.

 

I still don't get why the purge is not triggering the regeneration via the UI but it is via API. I can obviously live with that but it would definitely be nice to understand the reason and maybe come up with a solution if possible.

0 Likes