Code:
public void CreateDependentViews()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
using(Transaction t = new Transaction(doc, "Duplicate View 5x"))
{
t.Start();
int i = 0;
while (i < 5)
{
uidoc.ActiveView.Duplicate(ViewDuplicateOption.AsDependent);
i++;
}
t.Commit();
}
}
I expanded it a bit more and did some renaming based on Areas just to enhance it a bit.
Code:
public void CreateDependentViews()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
using(Transaction t = new Transaction(doc, "Duplicate View 5x"))
{
t.Start();
int i = 0;
while (i < 5)
{
ElementId dupViewId = uidoc.ActiveView.Duplicate(ViewDuplicateOption.AsDependent);
View dupView = doc.GetElement(dupViewId) as View;
char c = (char) (i + 65);
dupView.Name = uidoc.ActiveView.Name + " - AREA " + c.ToString();
i++;
}
t.Commit();
}
}
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
using(Transaction t = new Transaction(doc, "Duplicate View 5x"))
{
t.Start();
int i = 0;
while (i < 5)
{
uidoc.ActiveView.Duplicate(ViewDuplicateOption.AsDependent);
i++;
}
t.Commit();
}
}
I expanded it a bit more and did some renaming based on Areas just to enhance it a bit.
Code:
public void CreateDependentViews()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
using(Transaction t = new Transaction(doc, "Duplicate View 5x"))
{
t.Start();
int i = 0;
while (i < 5)
{
ElementId dupViewId = uidoc.ActiveView.Duplicate(ViewDuplicateOption.AsDependent);
View dupView = doc.GetElement(dupViewId) as View;
char c = (char) (i + 65);
dupView.Name = uidoc.ActiveView.Name + " - AREA " + c.ToString();
i++;
}
t.Commit();
}
}
Great macro, Troy! Thanks!
ReplyDeleteFor my use, I adapted it to add a building name to it:
public void Dependent_All_Five()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
using(Transaction t = new Transaction(doc, "Duplicate for All Buildings"))
{
t.Start();
ArrayList list = new ArrayList();
list.Add("Broadway");
list.Add("Dakota");
list.Add("Lincoln");
list.Add("Riverside");
list.Add("Queens");
foreach (string value in list)
{
ElementId dupViewId = uidoc.ActiveView.Duplicate(ViewDuplicateOption.AsDependent);
View dupView = doc.GetElement(dupViewId) as View;
dupView.Name = uidoc.ActiveView.Name + " - " + value;
}
t.Commit();
}
}