Revit 2015: SetCropRegionShape of Reference Callout
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to create a reference callout of an existing View and have the reference callout match the CurveLoop of the Parent CurveLoop. So far I've successfully created the reference callout:
Document doc = this.ActiveUIDocument.Document; View callout = doc.GetElement(new ElementId(1231121)) as View; View view = doc.ActiveView; ViewCropRegionShapeManager crop = callout.GetCropRegionShapeManager(); CurveLoop cropLoop = crop.GetCropRegionShape(); using (Transaction trans = new Transaction(doc)) { trans.Start("Copy Callout"); ViewSection.CreateReferenceCallout(doc, view.Id, callout.Id, new XYZ(0, 0, 0), new XYZ(100, 100, 0)); trans.Commit(); }
The first thing I problem I ran into is the ViewSection.CreateReferenceCallout returns a Void Element which makes it difficult to then track down the reference callout I just created. So I had to then find all the reference callouts for "callout":
ICollection<ElementId> viewCallouts = view.GetReferenceCallouts();
Now I loop through each ElementId in viewCallouts to change their CropRegion:
using (Transaction trans = new Transaction(doc)) { trans.Start("Edit Callout"); foreach (ElementId eid in viewCallouts) { Element e = doc.GetElement(eid); if(e.Name == callout.ViewName) { ViewSection v = doc.GetElement(eid) as ViewSection; //Result: NULL View v = doc.GetElement(eid) as View; //Result: NULL //ViewCropRegionShapeManager vCrop = v.GetCropRegionShapeManager(); //vCrop.SetCropRegionShape(cropLoop); } } trans.Commit(); }
Why can't these ReferenceCallouts be cast as a View or ViewSection t modify their CropRegion? What CAN they be cast as so I can change their CropRegion?
Thanks!
Anthony Tiefenbach
BIM Manager
HuntonBrady Architects
BIM Manager
HuntonBrady Architects
Link copied