Trouble finding the file name of a view from a viewport

Trouble finding the file name of a view from a viewport

jfranzR9VWK
Participant Participant
255 Vistas
5 Respuestas
Mensaje 1 de 6

Trouble finding the file name of a view from a viewport

jfranzR9VWK
Participant
Participant

I am trying to find the name of a view from its viewport object. I have tried going through parameters of the viewport as well as getting the element from the elementId from the ViewId from the Viewport itself. Both return the view name rather than the file name. Viewport.Name doesn't return what I am looking for either. To be precise, if a view shows up in the file browser with the name "Floor Plan 01", is it possible to get the value "Floor Plan 01". I need it so that I can filter something based on the name of the view in the project browser.

0 Me gusta
Soluciones aceptadas (1)
256 Vistas
5 Respuestas
Respuestas (5)
Mensaje 2 de 6

RLY_15
Advisor
Advisor

I'm not sure I understand the question: isn't the name as-displayed in the Project Browser the View Name? I haven't seen it referred to as a File Name.

0 Me gusta
Mensaje 3 de 6

jfranzR9VWK
Participant
Participant

The main thing I'm trying to do is to filter a viewport by whether or not it is a legend. If I have access to the text in the "View" field in the properties that is quite easy. Is there another way to tell if the item in a viewport is a Legend or something else? I can't figure out how to filter it if the Legend prefix is excluded from the View Name field.

0 Me gusta
Mensaje 4 de 6

RLY_15
Advisor
Advisor
Solución aceptada

Given the ViewID that you retrieved from the Viewport, get the ViewType from the View:

 

https://www.revitapidocs.com/2019/76bee86d-3c34-7ee1-4349-cd7abcbf3d78.htm

0 Me gusta
Mensaje 5 de 6

jfranzR9VWK
Participant
Participant

Just curious, is there a better way to go from a ViewId to a View than using Document.GetElement then casting the element back to a view?

Thanks for all the help.

0 Me gusta
Mensaje 6 de 6

RLY_15
Advisor
Advisor

Frankly? I don't know, and hope someone more active in the API forum responds. My knowledgebase is limited primarily to the Dynamo side of things.

0 Me gusta