Show/Hide Analytical model categories in view

Show/Hide Analytical model categories in view

jorge.bslu
Advocate Advocate
2,022 Views
10 Replies
Message 1 of 11

Show/Hide Analytical model categories in view

jorge.bslu
Advocate
Advocate

Hi,

Is there any way to show/hide analytical model categories in a given view?

In short: any way to check/uncheck the following checkbox ?

 

jorgebslu_0-1669907418024.png

BTW, when that option is checked and I programmatically show elements (Categories), they are finally visible in the view, but the corresponding checkboxes in the UI-TreeView are not checked.

I am using the following code to display a category:

var categories = document.Settings.Categories;
foreach (Category category in categories)
{
    if (category.CategoryType == CategoryType.AnalyticalModel
        && category.get_AllowsVisibilityControl(view))
    {
        category.set_Visible(view, true);
    }    
}

BR

Accepted solutions (2)
2,023 Views
10 Replies
Replies (10)
Message 2 of 11

RPTHOMAS108
Mentor
Mentor

You can find analytical categories via Category.CategoryType I don't believe there is a global control in the API.

 

View.SetCategoryHidden is another way, I wonder if it differs at all from Category.Visible or is just an alternative pointing to the same code. Interesting that you say the UI isn't updated since that would be confusing to the user and presumably is a bug i.e. how can it be visible but still hidden according to the UI.

Message 3 of 11

jorge.bslu
Advocate
Advocate

I also tried: View.SetCategoryHidden but it also didn't work ;(

 

Message 4 of 11

jeremy_tammik
Alumni
Alumni

I searched the existing posts here in this forum for "Analytical model categories in view".

  

Guess what I found?

  

https://forums.autodesk.com/t5/revit-api-forum/hide-level-heads-and-elevation-markers/m-p/11128915

  

One of the code snippets contains the comment:

  

                    // Disable Analytical Model category Graphic Override
                    foreach (Category cat in doc.Settings.Categories)
                    {

  

Does that help?

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 5 of 11

jorge.bslu
Advocate
Advocate

Unfortunately nope ... that code hides analytical categories, but what I actually need is to show analytical model categories through the API. That should be performed without any transaction in my case.

Message 6 of 11

RPTHOMAS108
Mentor
Mentor

You would need a transaction to make changes to the view (even if you were using temporary hide isolate etc. I believe) i.e. it stores the status of such in the document.

 

You can't avoid using a transaction to change the visibility in a view.

Message 7 of 11

jorge.bslu
Advocate
Advocate

Okay, thanks.

I was planning to:

  1. Show analytical elements in current view in order to
  2. Select analytical elements to be exported to our plugin
  3. Restore the visualization as it was before step 1 (by hiding those elements)

Maybe there is some kind of temporary representation I can set up instead of changing the view.

Plugin just reads Revit elements and therefore I did not want to create any transaction to prevent the user gets prompted to save changes when no "actual changes" occurred.

There are probably some conceptual errors in my thoughts about transactions & commits.

Thanks for the help

Message 8 of 11

RPTHOMAS108
Mentor
Mentor
Accepted solution

You can either use temporary hide/isolate or apply a template to the view temporarily, but I believe it will still be needing a transaction. The main purpose of temporary view modes is to enable the user to do something that doesn't affect the view long term.

 

View.IsolateCategoryTemporary
View.IsolateElementsTemporary
View.EnableTemporaryViewPropertiesMode (for applying templates)

To restore
View.DisableTemporaryViewMode

 

That seems like the most appropriate workflow.

 

Personally, speaking if I open Revit run something to pick a few elements and close the file then I know the answer I'm giving to the save dialogue. If I have the file open a while, then my choices may be different but either way I'm given a choice and deciding what to do with it. Besides the average Revit user is probably opening Revit in the morning closing it in the afternoon and working on a handful of the same models with it all day (so you kind of have to think what the probability is that they just open a document for one purpose).

 

Message 9 of 11

aignatovich
Advisor
Advisor
Accepted solution

Hi, you can turn on/off this checkbox using this property: https://www.revitapidocs.com/2023/beb3a24e-1d39-ed13-6a05-c7a8c3d5d4cc.htm

 

To show/hide categories in the view, it's better to use SetCategoryHidden, HideCategoryTemporary/HideCategoriesTemporary or IsolateCategoryTemporary/IsolateCategoriesTemporary as Thomas mentioned. You can also convert temporary isolation to permanent if you are using "...Temporary" methods

Message 10 of 11

jorge.bslu
Advocate
Advocate

Hi @aignatovich 

Thank you very much. I did not realized about that property 🙈 .....

I will give it a try to your recommendations and thank you once again.

Message 11 of 11

jorge.bslu
Advocate
Advocate
Thank you very much for your explanations and help !