Rocker
Rocker

Reputation: 96

Hide elements in Sheets or Revit Document

I am Having a doubt in Revit API. I want to hide some elements in Sheets of the Revit document. But I need an Active view to hide that. view.HideElements(ids) If I take a view which is active and try to hide elements in it, I am getting exception TypeError: expected View, got SectionView. Is there any way to hide that ? or is there any way to make my SectionView as Active View?

Help me with this. Either in Python or Dynamo Script(Design Script) or C#

I am trying to hide elements in Sheets In Revit Architecture Software but if the sheet is in Active View I can hide easily by taking the active view. If I take Sheets from FilteredElementCollector and try to hide elements in that, It is not working.

Upvotes: 2

Views: 422

Answers (2)

Mostafa Tarek Yassien
Mostafa Tarek Yassien

Reputation: 532

Using Autodesk.Revit.UI.UIDocument

the UIDocument has a property named ActiveView which has a get and set options. Use the UIdocument to set the active view to the view you need and then make the changes you want.

and take care that setting the Active View Property requires a separate Transaction.

Refer to this https://www.revitapidocs.com/2024/b6adb74b-39af-9213-c37b-f54db76b75a3.htm

Upvotes: 1

Rocker
Rocker

Reputation: 96

Found The Way in Python

TransactionManager.Instance.EnsureInTransaction(document)
TransactionManager.Instance.ForceCloseTransaction()

uiDocument.RequestViewChange(view) 

RequestViewChange is the Revit API method which can change the view of the UI-Document. Sometimes document won't allow to change the view while a transaction is going on so I force closed the Transaction.

Upvotes: 1

Related Questions