Try to Create a Callout for Area plan ViewType

Try to Create a Callout for Area plan ViewType

lav_panwarMA2AY
Contributor Contributor
723 Views
9 Replies
Message 1 of 10

Try to Create a Callout for Area plan ViewType

lav_panwarMA2AY
Contributor
Contributor

I am using ViewSection.CreateCallout() method and passing the document and my areaplan ElementId for parent view  and pass the viewFamilytypeId that is I am getting from my parent view and min and max point but I get exception " Non-Reference callouts are not allowed in parent views of this type". 

lav_panwarMA2AY_0-1727335816673.png

In the summary of this method so of viewtype are mention but Aeraplan is not mention so. Is there any way to create a callout for areaplan. it becasue to create a callout in revit using callout option. how to do that using API.

lav_panwarMA2AY_0-1727335956235.png

 

 

 

0 Likes
724 Views
9 Replies
Replies (9)
Message 2 of 10

jeremy_tammik
Alumni
Alumni

Please determine how to achieve what you need manually through the end user interface first. Is it possible at all? It may be more effective to address and solve this issue for the UI in the larger and more generic architectural forum:

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 10

lav_panwarMA2AY
Contributor
Contributor

Hello @jeremy_tammik I am try to create a callout using ViewSection.CreateCallout but my parent View and ViewFamilyType id has ViewType  and ViewFamily has Areaplan. 

0 Likes
Message 4 of 10

Michael_Coffey_G
Contributor
Contributor

Did you figure this out?  I'm also running into the same error.  

 

@jeremy_tammik Yes this is possible in the UI.  In an area plan, use View > Callout, pick two points.  A new area plan view is created that is cropped by the points picked.  

 

public void AreaPlanCallout()
{
	UIDocument uidoc = this.ActiveUIDocument;
	Document doc = uidoc.Document;
	
	// Select areas in UI then run macro
	List<Area> areas = GetAreasInSelection(uidoc, doc);

	using (Transaction t = new Transaction(doc, "Create Callouts"))
	{
		t.Start();
		
		foreach (var area in areas)
		{
			var box = area.get_BoundingBox(doc.ActiveView);
			var calloutPlan = ViewSection.CreateCallout(doc, doc.ActiveView.Id, doc.ActiveView.GetTypeId(), box.Min, box.Max);
		}
		
		t.Commit();
	}
}

List<Area> GetAreasInSelection(UIDocument uidoc, Document doc)
{
	var areas = new List<Area>();
	var selectionIds = uidoc.Selection.GetElementIds().ToList();
	foreach (var id in selectionIds) {
		var elem = doc.GetElement(id);
		if (elem is Area) {
			var area = elem as Area;
			areas.Add(area);
		}
	}
	return areas;
}

 

0 Likes
Message 5 of 10

Michael_Coffey_G
Contributor
Contributor

Btw, if you use this version for Rooms in a floor plan, it works fine:

public void RoomPlanCallout()
{
	UIDocument uidoc = this.ActiveUIDocument;
	Document doc = uidoc.Document;
	
	// Select rooms in UI then run macro
	List<Room> rooms = GetRoomsInSelection(uidoc, doc);

	using (Transaction t = new Transaction(doc, "Create Callouts"))
	{
		t.Start();
		
		foreach (var room in rooms)
		{
			var box = room.get_BoundingBox(doc.ActiveView);
			var calloutPlan = ViewSection.CreateCallout(doc, doc.ActiveView.Id, doc.ActiveView.GetTypeId(), box.Min, box.Max);
		}
		
		t.Commit();
	}
}

private List<Room> GetRoomsInSelection(UIDocument uidoc, Document doc)
{
	var rooms = new List<Room>();
	var selectionIds = uidoc.Selection.GetElementIds().ToList();
	foreach (var id in selectionIds) {
		var elem = doc.GetElement(id);
		if (elem is Room) {
			var room = elem as Room;
			rooms.Add(room);
		}
	}
	return rooms;
}
0 Likes
Message 6 of 10

Michael_Coffey_G
Contributor
Contributor

@jeremy_tammik  Please confirm the issue with area callout plans.  Thanks.

0 Likes
Message 7 of 10

jeremy_tammik
Alumni
Alumni

Dear Michael,

  

Before asking the devteam. I checked with Gemini:

  

  

Its answer and suggestions sound useful to me, but I cannot tell offhand how much it is hallucinating or not.

   

Please review the answer, let us know whether it helps and your opinion on its suggestions.

   

Thank you.

 

Cheers

 

Jeremy

 

P.S. My retirement is imminent, so I suggest you start getting used to not addressing me directly any longer. I'll be at DevCon in Amserdam. See you there?

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 8 of 10

Michael_Coffey_G
Contributor
Contributor

@jeremy_tammik Thanks for the reply.  I am already employing this workaround to create the area plan with a crop box from the bounding box.  It would be nice if the dev team could respond about why the ViewSection.CreateCallout method doesn't work in an area plan even though it does in the UI.

0 Likes
Message 9 of 10

jeremy_tammik
Alumni
Alumni

Ok, I passed it on. I also asked Gemini to summarise it succinctly and clearly for me, and that was partually successfuyl, although I hand-edited my final message after all:

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 10 of 10

TripleM-Dev.net
Advisor
Advisor

Hi @Michael_Coffey_G ,

 

Check the documentation, https://revapidocs.com/2020.htm?id=272ce735-271e-6ae3-8b36-c31207c99e56.htm 

As a AreaPlan is derived from a Viewplan it should work, but I think  "doc.ActiveView.GetTypeId()" should not be taken from the AreaPlan but a valid FloorPlan is my guess.

 

Inspect the callout created in the UI with RevitLookup and see what it uses.

 

- Michel