UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
ViewFamilyType viewFamilyType = (from v in new FilteredElementCollector(doc).
OfClass(typeof(ViewFamilyType)).
Cast<ViewFamilyType>()
where v.ViewFamily == ViewFamily.ThreeDimensional
select v).First();
Element element= null;
Reference refElemLinked = uidoc.Selection.PickObject(ObjectType.LinkedElement, "Выделите элемент из прикрепленного документа!");
foreach (Document linkedDoc in uiapp.Application.Documents)
{
element = linkedDoc.GetElement(refElemLinked.LinkedElementId);
}
BoundingBoxXYZ boundingBox = element.get_BoundingBox(null);
using (Transaction t = new Transaction(doc, "Create view"))
{
t.Start();
View3D view = View3D.CreateIsometric(doc, viewFamilyType.Id);
view.Name = " Section Box";
t.SetName("Create view " + view.Name);
try
{
view.SetSectionBox(boundingBox);
}
catch (Exception)
{
throw;
}
t.Commit();
uidoc.ActiveView = view;
}