Delete All Drafting Views

Delete All Drafting Views

Anonymous
Not applicable
1,708 Views
3 Replies
Message 1 of 4

Delete All Drafting Views

Anonymous
Not applicable

Hello, I'd like some assistance in creating a C# AddIn (Revit 2016).

 

It must delete all drafting views in the model.

 

I appreciate any input, thanks!

0 Likes
1,709 Views
3 Replies
Replies (3)
Message 2 of 4

WhiteSharx
Contributor
Contributor

Here you go

Create a macro module and paste this

 

		public void DelAllDraftView()
		{
			Document doc = this.Document;
			List<ElementId> L = new FilteredElementCollector(doc).
				OfClass(typeof(View)).ToElements().Cast<View>().
				Where(x=>x.ViewType==ViewType.DraftingView).
				Select(y=>y.Id).ToList();
			using( Transaction t = new Transaction( doc ) )
			{
				t.Start( "Deleting DraftingViews" );
				doc.Delete(L);
				t.Commit();
			}			
		}

Make sure that a drafting view is not an active one before starting the execution of macro

0 Likes
Message 3 of 4

Anonymous
Not applicable

Run button is grayed out, after creating module. ?

0 Likes
Message 4 of 4

WhiteSharx
Contributor
Contributor

At first you create a module

After that you create a macro in similar fashion.

 

Have a look at this https://www.youtube.com/watch?v=XmNVKaZ4psA