Hi there! Im trying to build some Macros for duplicating views and I have got an issue I havent found an anwser to. Its pretty simple, this code is only working when I choose "AsDependent" as ViewDuplicateOption. As long as I choose "WithDetailing" or "Duplicate" it raise an error that says "View cannot be duplicated". I know I can check if a view is available to duplicate it with CanBeDuplicated method. But what I want to know is why I cant duplicate the active view if I can do it normally in Revit.
Testing with FloorPlan. Level 1.
The code:
public void DuplicarVista()
{
UIDocument uidoc = this.ActiveUIDocument;
Document doc = uidoc.Document;
View ActiveView = null;
ActiveView= uidoc.ActiveView;
int nduplicates = 4;
using (Transaction t = new Transaction(doc,"Duplicate Views"))
{
t.Start();
for (int i = 1; i < nduplicates; i++)
{
Element CreatedView = doc.GetElement(ActiveView.Duplicate(ViewDuplicateOption.Duplicate));
}
t.Commit();
}
}
Solved! Go to Solution.
Solved by jjesusdelpino. Go to Solution.
I have restarted Revit, tried again and now it works fine. Dont know what was going on but its working so... I mark this as a solution in case someone need code to duplicate Views. Thanks.
Hi, I am new to Revit Api. My question is what is the purpose of the for loop here?
Can't find what you're looking for? Ask the community or share your knowledge.