Posts

Greetings, folks!

Here is a quick solution to an inconvenience I was having when setting up some Window Legend sheets today. In this particular case I’ve decided to use the Phased Out Legends approach discussed many years ago in this blog post by Martijn de Riet. This is from 2012 but it’s still a valid approach in my opinion. We’ve enjoyed quite a few treats in the recent years, sadly Legends are still to get the attention they need.

The premise is that you setup your Window views as plain old Plan and Elevation views using one long long wall containing all your window types. In order to hide that in all your normal views, you place this rig inside the ‘Existing’ phase and you also demolish them in that same phase. Then you simply adjust your views to show said phases correctly. These dummy windows would remain hidden in all normal views including schedules. That’s the gist of it.

I bet there were a number of ways to automate the task of creating all the ‘mini views’ for each window type, but what I found myself doing is duplicating the same plan and elevation view as dependant views, adjusting the crop region as needed and placing them on the appropriate sheet. Tedious, tedious work.

Duplicate Views on Sheets

What came out of my frustration was a neat way to duplicate Views on Sheets. I can see how that can be quite handy in so many situations where you simply want to save some of the hustle of all the duplicating and dragging and dropping. So here you go, folks, a nice little Macro that you can use inside your Application Macros straight away (unless you need Administrative rights in which case you can go and kick your IT’s butt from me).


// Use inside the Application Macros
public void DuplicateViewPort()
{
	Document doc = this.ActiveUIDocument.Document;			
				
	Viewport viewportToDuplicate = ViewportToDuplicateFromSelection(this.ActiveUIDocument);
	View viewToDuplicate = ViewToDuplicate(doc, viewportToDuplicate);
	XYZ placementPoint = viewportToDuplicate.GetBoxOutline().MaximumPoint;
	using(Transaction t = new Transaction(doc, "dulicate viewport"))
	{
		t.Start();
		Viewport.Create(doc, viewportToDuplicate.SheetId, viewToDuplicate.Id, placementPoint);				
		t.Commit();
	}
}
// Returns the Selected Viewport to Duplicate - promps for selection
internal Viewport ViewportToDuplicateFromSelection(UIDocument uidoc)
{
	var selectedViewPort = uidoc.Selection.PickObject(ObjectType.Element, "Pick Viewport");						
	var viewport = uidoc.Document.GetElement(selectedViewPort.ElementId) as Viewport;
							
	return viewport;
}
// Returns the duplicate View to be placed on the Sheet
internal View ViewToDuplicate(Document doc, Viewport viewport)
{
	using(Transaction t = new Transaction(doc, "duplicate view"))
	{
		t.Start();	
		var view = doc.GetElement(viewport.ViewId) as View;				
		var duplicateView = doc.GetElement(view.Duplicate(ViewDuplicateOption.AsDependent)) 
                   as Autodesk.Revit.DB.View;
		t.Commit();
		
		return duplicateView;
	}			
}

Feel free to use it as you see fit. Ask away, if you have issues implementing it. Use the code to create Dynamo nodes of any sort or kind and generally knock yourselves out.