Message 1 of 2
Crop view by Selected Elements

Not applicable
05-26-2015
05:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I found this macro that was made available on PuntoRevit where it crops a view by selecting Elements.
It works well and was what i was looking for, until i tried it on a view where i had rotated the crop region, this puts it out of whack and sets the crop box around the original location of the elements. I'm guessing it does not take into account that the view has been transformed. Unfortunately i do not have enough understanding of Transforms to amend this...altho i have tried...and failed.
So any assistance or advice would be appreciated.
This is the origin code for the macro...
public void CropViewBySelection() { UIDocument uidoc= this.ActiveUIDocument; Document doc= uidoc.Document; IList<Reference> refs= uidoc.Selection.PickObjects(ObjectType.Element,"Make a selection, click on finish when done"); View v = doc.ActiveView; List<XYZ> points = new List<XYZ>(); if(v.ViewType == ViewType.FloorPlan) { foreach(Reference r in refs) { BoundingBoxXYZ bb= doc.GetElement(r).get_BoundingBox(v); points.Add(bb.Min); points.Add(bb.Max); } BoundingBoxXYZ sb= new BoundingBoxXYZ(); sb.Min=new XYZ(points.Min(p=> p.X), points.Min(p=> p.Y), points.Min(p=> p.Z)); sb.Max=new XYZ(points.Max(p=> p.X), points.Max(p=> p.Y), points.Max(p=> p.Z)); try { using (Transaction t = new Transaction(doc,"Crop View By Selection")) { t.Start(); v.CropBoxActive=true; v.CropBox=sb; t.Commit(); } } catch (Exception ex) { TaskDialog.Show("Revit",ex.Message); return; } } }
Thanks in Advance,
Paul.