hello all
able to zoom element element in activedoc by this:
UIApp.ActiveUIDocument.ShowElements(element);
can anyone suggest how to do same with linked element?
Got element inlinked doc and their position also.
Just wanted to zoom.
it is also ok if only can zoom to that specific area.
Solved! Go to Solution.
Solved by prasannamurumkar. Go to Solution.
Below code is working fine for zooming element in linked doc.
api used is ZoomAndCenterRectangle.
ElementId oEid = new ElementId(intElementId);
// selectionIds.Add(oEid);
// UIApp.ActiveUIDocument.ShowElements(oEid);
// UIApp.ActiveUIDocument.get
Element element = revitME.GetElement(oEid);
LocationPoint lc = element.Location as LocationPoint;
Transform transform1 = RvtLinkm.GetTransform();
XYZ newLocation2 = transform1.OfPoint(lc.Point);
BoundingBoxXYZ boundingBoxGeyer = element.get_BoundingBox(RevitDoc.ActiveView);
UIView uiView = null;
IList<UIView> uiviews = UIApp.ActiveUIDocument.GetOpenUIViews();
Autodesk.Revit.DB.View view = RevitDoc.ActiveView;
foreach (UIView uv in uiviews)
{
if (uv.ViewId.Equals(view.Id))
{
uiView = uv;
break;
}
}
uiView.ZoomAndCenterRectangle(new XYZ(newLocation2.X - 4, newLocation2.Y - 4, newLocation2.Z - 4), new XYZ(newLocation2.X+4, newLocation2.Y+4, newLocation2.Z+4));
Thank you for sharing your solution.
It leaves some question open, though.
Here is my cleanup:
void ZoomToLinkedElement(
UIDocument uidoc,
RevitLinkInstance link,
ElementId id )
{
Document doc = uidoc.Document;
View view = doc.ActiveView;
// Determine active UIView to use
UIView uiView = uidoc
.GetOpenUIViews()
.FirstOrDefault<UIView>( uv
=> uv.ViewId.Equals( view.Id ) );
Element e = doc.GetElement( id );
LocationPoint lp = e.Location as LocationPoint;
Transform transform1 = link.GetTransform();
XYZ newLocation2 = transform1.OfPoint( lp.Point );
BoundingBoxXYZ bb = e.get_BoundingBox( doc.ActiveView );
uiView.ZoomAndCenterRectangle(
new XYZ( newLocation2.X - 4, newLocation2.Y - 4, newLocation2.Z - 4 ),
new XYZ( newLocation2.X + 4, newLocation2.Y + 4, newLocation2.Z + 4 ) );
}
Questions:
Thank you for clarifying!
You use the active UI doc, the link instance, revitME and RevitDoc.
Which is which?
And what document does the element id belong to?
hi,
Actually just wanted to show how
ZoomAndCenterRectangle
api used.
Answers to questions
1.yes got the active document,linked document.
2.location got is not correct as element used is from linked document so transform is applied to get its right position in active document.
3.bounding box can delete as it is used for other purpose (Not for this ZoomAnd CentreRectangle api)
revitMe is linked Document of mechanical equipment.
revit Doc is active Document.
element id belong to revitMe.(linked document)
rvtlink instancc is revit link document instance got from below:
RevitLinkInstance RvtLink = null;
FilteredElementCollector oRevitLinksM = new FilteredElementCollector(revitDocument).OfCategory(BuiltInCategory.OST_RvtLinks).WhereElementIsNotElementType();
foreach (Element element in oRevitLinks.ToElements())
{
if (element.Name.ToString().Contains("ME"))
{
RvtLinkm = element as RevitLinkInstance;
}
}
Can't find what you're looking for? Ask the community or share your knowledge.