Is there a way to update current view during Dynamo's routine execution?

I’m trying to develop an interface using python and windows forms to enable the user to navigate between objects in a file.

Basically, I’ve managed to do everything except the main point itself: zooming the object.

I’ve found out a way of doing so using Document.SendCommand and then using the zoom command with the coordinates of the object. But there’s a problem: the command only appears to be sent when the application is closed and dynamo stops running.

I believe it isn’t a common problem among the community since dynamo isn’t really supposed to be used in such way, but not being able to update the view during the run is becoming an unavoidable problem for me and I’d be glad if anyone could help with ideas! Thanks a lot!

The Arkance Systems Node Library contains nodes to zoom to objects or to a view. I’ve used it to create multiple screenshots in a loop, so it works while running.

Maybe you can loop a transaction in Python to force finishing the code inside the transaction. Don’t know if that really works, but you can try.


You can use the Autodesk.AutoCAD.GraphicsSystem View.ZoomWindow() method.
See also here (C# but adaptable to python)


My initial idea was to use the arkance systems node this way you mentioned, but I don’t know how to access this library’s nodes via python.

I’ve tried it a few times, added the reference to it but didn’t find the right way to import it directly and/or access its nodes - and didn’t find any example online. Is there any trick or something i’m missing?

If you have any idea about how to access it via python it’d be so helpful!!

Thanks for your answer!!
This post is very complete and I’ll surely give a try to some of the approaches! If any of them do work, I’ll come back to share it!

1 Like

It worked in the first attempt (must be a miracle hahaha)!!

And, in fact, there’s no need to call a transaction as we are using the editor. Here comes the code of the method I used and a video of it in practice:

def ZoomToDevice(objectHandle):
    scaleFactor = 1.5
    pl = DA.DocumentExtensions.ObjectByHandle(currentDoc, objectHandle)
    geometry = DA.PolylineExtensions.GetGeometry(pl)
    boundingBox = DSGeometry.BoundingBox.ByGeometry(geometry)
    maxPoint = boundingBox.MaxPoint
    minPoint = boundingBox.MinPoint
    max2d = Point2d(maxPoint.X, maxPoint.Y)
    min2d = Point2d(minPoint.X, minPoint.Y)
    center = Point2d(min2d.X+(max2d.X-min2d.X)/2, min2d.Y+(max2d.Y-min2d.Y)/2)
    view = ViewTableRecord()
    view.CenterPoint = center
    view.Height = (maxPoint.Y - min2d.Y) * scaleFactor
    view.Width = (max2d.X - min2d.X) * scaleFactor
    return 0

Thanks a lot for the help! I’m so glad it’s finally working!