Running dynamo code by visual studio

Hello !!
i am stuck somewhere in my student project.
I created topography surface using Revit API in visual studio by programming language C#. The problem is its lost somewhere in view because of its high coordinates. I need to make a zoom of topography in the view. I did it somehow by small script in dynamo which i am attaching.
Now, what i want to ask is, as i have done everything in visual studio, should i also do this zooming in visual studio or stay with my dynamo code but run this dynamo code somehow in visual studio. It will be great if someone could share the lines of doing this small task in visual studio.
So here is my dynamo code and after running this script i just type ZE in revit and i can see my topography

You cannot run Dynamo graphs directly from VS, but if your question is more about how to do the equivalent of ZE in C#, this may provide some guidance (I am writing the Python equivalent, but the general steps should be the same):

import clr
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument

uiviews = uidoc.GetOpenUIViews
for uiview in uiviews:
1 Like