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!
@Aaron.Lu wrote:
May I suggest you just get the callout (rather than the reference) and set its CropRegion?
Can you be more specific or provide some sample code? I need to modify the CropRegion of the ReferenceCallout only, not the original View. If I get the View of the ReferenceCallout then I'd be changing that View instead of the sketch of the ReferenceCallout. I don't see a way to do this at all.
Here's some API Wish List items that would be great:
The ViewSection.CreateCallout method should also allow for a sketched CropRegion by adding:
public static View CreateCallout( Document document, ElementId parentViewId, ElementId viewFamilyTypeId, ViewCropRegionShapeManager cropRegionShape )
Allow ReferenceViews to be a View. Add IsReference Property to the View Class to allow for checking against it being a View or ViewReference.
The ViewSection.CreateReferenceCallout method would then create a View and we could have the option for creating with a sketched CropRegion:
public static View CreateReferenceCallout( Document document, ElementId parentViewId, ElementId viewIdToReference, ViewCropRegionShapeManager cropRegionShape )
I'm not sure if this was ever logged as a request to the development team. It looks like you were waiting on me to respond, but I just caught that as I was reviewing my older posts.
So, to answer you question and get this processed as a request:
@Aaron.Lu wrote:
1. API to check whether it is a reference callout or not
2. API to modify crop region of callout
More details are in my previous post.
Thanks!
Hi Anthony,
Does not look like this was logged last year.
Since this May, we have introduced Revit Idea Station in the effort to better track customers' wishes, to make it visible to all of us and help organize wishes.
Would you like to post it there?
http://forums.autodesk.com/t5/revit-ideas/idb-p/302/label-name/api/tab/most-recent
There is a category "API" you can choose. You can get votes from the community. The both product and support team is monitoring there.
Once you posted there, you may choose to put the link here so that others who happen to come here can easily find the idea post.
I submitted this to the Ideas Board: https://forums.autodesk.com/t5/revit-ideas/setcropregionshape-of-reference-callout/idi-p/6716303
I was able to determine if a view IsReference by checking the (int)BuiltInParameter.VIEWER_IS_REFERENCE. When the Parameter is 1 (one), the Callout IS a reference.
Can't find what you're looking for? Ask the community or share your knowledge.