Arnaud
Arnaud

Reputation: 467

How can I activate (display) a view using Revit API?

I am trying to activate a view using Revit API. What I want to do exactly is to prompt the user to select some walls, but when the user is asked that, he can't switch views to select more walls (everything is greyed out at that point). So the view I want to activate (by that I mean, I want this view to be actually shown on screen) already exist, and I can access its Id.

I have seen threads about creating, browsing, filtering views, but nothing on activating it... It's a Floor Plan view.

So far I can access its associated ViewPlan object, and associated parameters (name, Id, ..).

Is it possible to do ?

Thanks a lot !

Arnaud.

Upvotes: 4

Views: 5406

Answers (3)

Paolo
Paolo

Reputation: 1

ActiveView has only a get accessor, what Mostafa suggests will not work. I have used the RequestViewChange() method with a modal dialog and have not had problems so far.

Upvotes: 0

Mostafa Tarek Yassien
Mostafa Tarek Yassien

Reputation: 532

I think the solution to your problem may be:

commandData.Application.ActiveUIDocument.ActiveView = View;

The ActiveView is a property and it has {get and set} options.

Upvotes: 2

Matt
Matt

Reputation: 1096

I think the most preferred way is the UIDocument.RequestViewChange() method. The tricky part about this is that unless you've designed your application to be modeless with external events or idling, it may not actually happen until later when control returns back to Revit from your addin. (There's also setting the UIDocument.ActiveView property - not positive if this has different constraints).

The other way that I have done it historically is through the use of the UIDocument.ShowElements() command. The trick here is that you don't have control of the exact view - but if you can figure out the elements that appear only in that view, you can generally make it happen (even if you have to do a separate query to get a bunch of elements that are only in the given floorplan view).

Good Luck!

Upvotes: 5

Related Questions