Refresh projectbrowser (after renaming sheetnumber)

Refresh projectbrowser (after renaming sheetnumber)

c_hanschen
Advocate Advocate
4,423 Views
21 Replies
Message 1 of 22

Refresh projectbrowser (after renaming sheetnumber)

c_hanschen
Advocate
Advocate

Hello,

 

After renaming SheetNumber with Revit API, the project browser still shows the old name.

When selecting the Sheet, the new SheetNumber is shown in the properties panel, but not in the projectbrowser.

When remaing 100 sheets with Revit API, I only need to edit 1 manually for all sheets te be show properly in de projectbrowser.

 

HOW TO REFRESH THE PROJECTBROWSER BY REVIT API?

 

I have tried Class 'BrowserOrganization', but is seems only to be able to read stuff, not to change the browserorganisation.

 

please help.

 

greetings from the Netherlands,

Chris Hanschen, LKSVDD architecten BV. (Hengelo)

0 Likes
Accepted solutions (2)
4,424 Views
21 Replies
Replies (21)
Message 2 of 22

matthew_taylor
Advisor
Advisor

I have seen the same issue and am curious to see if anybody has resolved it.


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?
0 Likes
Message 3 of 22

c_hanschen
Advocate
Advocate

Hello Matthew,

 

My Topic has a red arrow saying: "This topic has been escalated"

 

do you know wat that meens?

 

I am from holland, so English is not my motherlanquage, but when i translate is, it means that it is in someway out of control.

Why? when 1000 people responded, I would understand, but now i do not have a clue.

 

Chris

0 Likes
Message 4 of 22

matthew_taylor
Advisor
Advisor

Hi Chris,

This forum is monitored by Autodesk employees. Perhaps 'escalated' means that this bug has been reported to the Revit API developers?

 

-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?
0 Likes
Message 5 of 22

mikako_harada
Community Manager
Community Manager

Hi Chris, 

 

I'm afraid there is no UI related API like refresh browser.  Sorry.  

 

You may want to add this to Idea Station for Revit so that you can get votes from other community members:  

 

http://forums.autodesk.com/t5/revit-ideas/idb-p/302/tab/most-recent 

 

 


Mikako Harada
Developer Technical Services
0 Likes
Message 6 of 22

matthew_taylor
Advisor
Advisor
I wonder if there is a postable command that would refresh it?

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?
0 Likes
Message 7 of 22

matthew_taylor
Advisor
Advisor
Accepted solution

So, postcommand can be the workaround.

Workflow:

  1. Close project browser.
  2. Run rename sheet macro (that includes a postable command for the project browser).

Sheet number is accurately renamed.

 

I've found another way to do this, without user input.

  1. Get project browser view element.
  2. Start transaction.
  3. Hide sheet (the one you want to rename) in the project browser using .HideElements.
  4. Rename the sheet.
  5. Unhide the sheet using .UnhideElements.
  6. Commit transaction.
'Note the hardcoded element Id. You'll need to fix that - it was just for testing.
   Dim projBrowser As DB.View = TryCast(doc.GetElement(New DB.ElementId(258)), DB.View)
        Dim sheet As DB.ViewSheet = 'your sheet
        Using trans As New DB.Transaction(doc, "Rename Sheet")
            trans.Start()
            projBrowser.HideElements(New List(Of DB.ElementId) From {sheet.Id})

            sheet.SheetNumber = "New Sheet Number"
            projBrowser.UnhideElements(New List(Of DB.ElementId) From {sheet.Id})

            trans.Commit()
        End Using

 

I found that wrapping the unhide in a separate transaction caused a few issues, so I'd recommend against that.

Also, the Revit 'undo' stack didn't always behave like you'd expect it. So do some testing!

 

Let me know if you get it sorted.

 

-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 8 of 22

c_hanschen
Advocate
Advocate

That sounds hopeful..!!!

 

As you describe it, the project browser is a view, type of Autodesk.revit.db.view. 

 

How to get that view?

I Tried this with the standard Autodesk 'Simple Project' in Revit 2017:

 

Dim MyElementCollectorVIEWS As FilteredElementCollector = New FilteredElementCollector(MyDoc)
MyElementCollectorVIEWS.OfCategory(BuiltInCategory.OST_Views)

Dim temp As String = "*"
For Each MyView As Autodesk.Revit.DB.View In MyElementCollectorVIEWS
temp = temp & vbCrLf & MyView.Name
Next
temp = temp & vbCrLf & "*"

 

 

but it returns these views:

*
Level 1
North
East
West
Site
Architectural Reflected Ceiling Plan
Architectural Elevation
Architectural Section
South
Building Section
Level 2
Longitudinal Section
Kitchen
From Yard
Living Room
Stair Section
Approach
Section Perspective
Typ. Wall Section
Typical Wall Roof Connection
Typical Floor Wall Connection
Typical Foundation Detail
Main Stair Detail
Solar Analysis
Approach
From Yard
{3D}
E,S,D - Highlight Learning Content
Architectural Plan
Plan - Highlight Learning Content
Site Plan
Highlight Learning Content
3D View
Kitchen
Living Room
Section Perspective
*

 

I can't find the project browser view like this.

i also tried to get it from browserorganisation, but there is no 'GetProjectBrowser' or something like that.

 

can you help me out?

0 Likes
Message 9 of 22

matthew_taylor
Advisor
Advisor

 

This should do it (tested in 2016):

        Dim projectBrowser As DB.View = New DB.FilteredElementCollector(doc).OfClass(GetType(DB.View)).Cast(Of DB.View).Where(Function(v) v.ViewType = DB.ViewType.ProjectBrowser).FirstOrDefault

 

 

-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 10 of 22

c_hanschen
Advocate
Advocate

In Holland (The Netherlands) we would say: "Dat werkt als een tierelier..!!"

It means: "It's work perfectly fine...!!"

 

Thanks a lot..!!!!!

 

 

0 Likes
Message 11 of 22

matthew_taylor
Advisor
Advisor

No problem - glad you got it working!

I've had this issue myself in the past, so I'm sure I'll use the solution at some point. 🙂


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?
0 Likes
Message 12 of 22

Anonymous
Not applicable

A simpler solution is to hide the entire project browser, rename sheets as required then show the project browser again - it works for me anyway.

 

DockablePaneId dpId = DockablePanes.BuiltInDockablePanes.ProjectBrowser;
DockablePane pB = new DockablePane(dpId);
pB.Hide();

// rename here

pB.Show();

 

Message 13 of 22

Dale.Bartlett
Collaborator
Collaborator

Thanks Chris, this solved yet another mystery. Works perfectly. Dale




______________
Yes, I'm Satoshi.
0 Likes
Message 14 of 22

deyannWXBAT
Participant
Participant

You guys are cool! It works like a charmmm!

0 Likes
Message 15 of 22

davidd
Contributor
Contributor

Awesome Chris Thanks a lot!

0 Likes
Message 16 of 22

Sean_Page
Collaborator
Collaborator
Accepted solution

Thought I would share that you can shorten then even further by just using the Show() method without having to hide it first. This is enough to cause the browser refresh.

 

using (Transaction transaction = new Transaction(doc);
{
transaction.Start("Renumber Sheets");

sheet.SheetNumber = newSheetNumber;

transaction.Commit();
}

DockablePaneId dpId = DockablePanes.BuiltInDockablePanes.ProjectBrowser;
DockablePane dP = new DockablePane(dpId);
dP.Show();

 

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
Message 17 of 22

revitpeon
Enthusiast
Enthusiast

If you'll excuse a really basic question-- when I see code like this, how to I use it in Dynamo?  I've just been using prebuilt nodes up until now.

0 Likes
Message 18 of 22

Sean_Page
Collaborator
Collaborator

A question like this would probably be more applicable to the Dynamo forums https://forum.dynamobim.com/, but I think this code has to be used outside of an active transaction which will make utilizing it in Dynamo more challenging. Are you not seeing the changes happen in your model?

Sean Page, AIA, NCARB, LEED AP
Partner, Computational Designer, Architect
0 Likes
Message 19 of 22

matthew_taylor
Advisor
Advisor

The simple answer is to use something like https://forums.autodesk.com/t5/forums/replypage/board-id/160/message-id/41275

...and make a Python code block. But it's never that simple... 😉  Once you run into a Python/Dynamo issue, @Sean_Page is right on the money. 


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?
0 Likes
Message 20 of 22

michael-coffey
Advocate
Advocate

I can't believe in Revit 2022 I still have this issue.