Hi Sirs,
I just want to know if is it possible to zoom-in to a selected element in a linked document (Floor Plans in particular) using dynamo or python script?
thank you in advance.
Hi Sirs,
I just want to know if is it possible to zoom-in to a selected element in a linked document (Floor Plans in particular) using dynamo or python script?
thank you in advance.
At the moment, we cannot because we can not access to UIDocument linked file, if in Document curent can use method ShowElement
Requires a few packages but possible… I didn’t have a Zoom-to-Fit node available but you can find a Python script for that on the forum search.
If you need to maintain the range of the view you’ll have to change the script to set the section, zoom in, then reset the section box to whatever your original bounds were.
@chuongmep , Thank you for the information bro ^^…
@Robert_Younger , Thank you for the information also… i think this graph is similar to “BX” key shorcut where it will take you to 3D view and zoom it to the selected object?
Hello,
an example with ZoomAndCenterRectangle() method
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
from Autodesk.Revit.UI.Selection import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
uiviews = uidoc.GetOpenUIViews()
view = doc.ActiveView
uiview = [x for x in uiviews if x.ViewId == view.Id][0]
TaskDialog.Show("Selection", "Select Link element")
reflnk = uidoc.Selection.PickObject(ObjectType.LinkedElement, "Select Link element")
lnkinst = doc.GetElement(reflnk)
tfLnk = lnkinst.GetTotalTransform()
doclnk = lnkinst.GetLinkDocument()
elemInLink = doclnk.GetElement(reflnk.LinkedElementId)
bbx = elemInLink.get_BoundingBox(None)
pt1 = XYZ(bbx.Min.X, bbx.Min.Y, 0)
pt2 = XYZ(bbx.Max.X, bbx.Max.Y, 0)
uiview.ZoomAndCenterRectangle(tfLnk.OfPoint(pt2), tfLnk.OfPoint(pt1))
OUT = lnkinst, elemInLink
Hi, @c.poupin,
This is an awesome script… it really works in the Floor Plan View mode…
But the script behaves differently when it is used on the Drawing Sheet View where the Floor Plan view is inserted… is it possible to map the element bounding box location with respect to the drawing sheet coordinates?
thank you very much for the sample code bro ^^… So much needs to be learned
I haven’t tried it but I think it depends on the position of the viewport and maybe the scale
Hi there!
I was using this piece of code, and it works perfectly.
Only found 2 problems when it comes to:
Is there a way to solve it?
Many thanks in advance.
I’m resolved the first problem with view3D here, for the second I don’t have any reason, why I need to do that with zoom in background. you can reference. kudo for @c.poupin with sample code.
Hi,
here is the fixed Python code for 3DViews
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
from Autodesk.Revit.UI.Selection import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
uiviews = uidoc.GetOpenUIViews()
view = doc.ActiveView
uiview = next((x for x in uiviews if x.ViewId == view.Id), None)
TaskDialog.Show("Selection", "Select Link element")
reflnk = uidoc.Selection.PickObject(ObjectType.LinkedElement, "Select Link element")
lnkinst = doc.GetElement(reflnk)
tfLnk = lnkinst.GetTotalTransform()
doclnk = lnkinst.GetLinkDocument()
elemInLink = doclnk.GetElement(reflnk.LinkedElementId)
bbx = elemInLink.get_BoundingBox(None)
# fix values for 3d view
pt1 = XYZ(bbx.Min.X, bbx.Min.Y, bbx.Min.Z)
pt2 = XYZ(bbx.Max.X, bbx.Max.Y, bbx.Max.Z)
uiview.ZoomAndCenterRectangle(tfLnk.OfPoint(pt2), tfLnk.OfPoint(pt1))
OUT = lnkinst, elemInLink
For 3d Views in background, I think it’s preferable to set ViewOrientation3D
property with eyePosition