Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Revit 2015: SetCropRegionShape of Reference Callout

6 REPLIES 6
Reply
Message 1 of 7
atiefenbach
789 Views, 6 Replies

Revit 2015: SetCropRegionShape of Reference Callout

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
6 REPLIES 6
Message 2 of 7
Aaron.Lu
in reply to: atiefenbach

Dear, Reference Callout is just a reference, which is an Element and can't be casted to View,
May I suggest you just get the callout (rather than the reference) and set its CropRegion?


Aaron Lu
Developer Technical Services
Autodesk Developer Network
Message 3 of 7
atiefenbach
in reply to: Aaron.Lu


@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
)

 

 

Anthony Tiefenbach
BIM Manager
HuntonBrady Architects
Message 4 of 7
Aaron.Lu
in reply to: atiefenbach

Dear, unfortunately, I found there is no API to change the crop region of callout now.
and thanks for your suggestion,
I can log the request to dev team, since the internal code may not be the same as we expected, so I will let them decide new interfaces, but first I want to confirm that what you want are:
1. API to check whether it is a reference callout or not
2. API to modify crop region of callout



Aaron Lu
Developer Technical Services
Autodesk Developer Network
Message 5 of 7
atiefenbach
in reply to: Aaron.Lu

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


  1. Yes! (In my previous post I suggested adding a IsReference Property to the View Class to determine if a View is a reference or not)
  2. I want to be able to utilize the ViewCropRegionShapeManager to assign a sketched CropRegion to a ReferenceCallout
  3. I want the CreateCallout and CreateReferenceCallout Methods to return a View Class)

More details are in my previous post.

 

Thanks!

Anthony Tiefenbach
BIM Manager
HuntonBrady Architects
Message 6 of 7
mikako_harada
in reply to: atiefenbach

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.  


Mikako Harada
Developer Technical Services
Message 7 of 7
atiefenbach
in reply to: mikako_harada

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.

Anthony Tiefenbach
BIM Manager
HuntonBrady Architects

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report