At the end of August I had the chance to go to my home country to continue the evangelism on Autodesk new Large Model Viewer web service API. Always with the desire to give back part of my experience and knowledge to my home country, I decided to reach out to my Tech contacts in order to make these talks possible and expand my network with the Guatemalan Tech enthusiasts. The response I got from 5 of the Top Universities in Guatemala was simply amazing.
My Tech Evangelism tour started with #CampusTEC and Universidad Del Valle, where I had the opportunity to share how the Web is changing, and how Autodesk believes that 3D web should be something that starts taking over, we are a big 3D CAD design and software company, the tools exist and seeing the beautiful CAD designs that get created, should be available in your Web.
Later, during the week, I was made the opening Key note speaker at a great Tech Innovation Forum at Galileo University #FITGT, where I share my opinion and experience about Design, Education and 3D web, and how Design should be consider as one of the new pillars in education. With the many makers, we have around today, it just makes sense that these young enthusiasts get a head start shaping their minds to acquire great design skills and create new amazing things, in my opinion. A big thank you to Oscar Rodas. Adrian Catalan, Maria Zaghi and Yucely Beb for making these talks possible.
After a successful day spending time with many innovators and makers from Guatemala, I went to Universidad Rafael Landivar, where an audience of 200 aspiring engineers (Mechanical, Civil, Software) were eager to learn about how to add their Inventor, Revit, AutoCAD models on their own website. Big thanks to Boris Ruiz for the organization of this great group of students.
During my last days in Guatemala, I had the chance to meet with the Director of the new Computer Science department at Universidad Francisco Marroquin, where I had the chance to present the technology to 1st year students of the CS department and many have already started to reach out, eager to know how to make their Web 3D enabled. Thanks to Leonel Morales for hosting me.
I see there is a lot of potential in Guatemala when it comes to the Tech Business, I will keep you up to date on how what I showed turns out.
---------------------------------------------------------------------------------------------
Ok, enough of my traveling and evangelism experience, back to the Revit API. This week I had a chance to work and play with a command that deletes the imported CAD from your Revit Project. Something that got addressed by Harry Mattison from Boost Your BIM blog back in 2013. After seeing his nice post on it, I was curious to check if everything he shared will still work with Revit 2016 and sure it did.
Here is the question in our Revit API forum, posted by Vinay.
Question:Dear All,
Is there any possibilities of deleting imported cad through API.
Answer by Dale Bartlett: I have used this successfully:
Credit: http://boostyourbim.wordpress.com/2013/01/12/delete-imported-dwg/
(Document doc, bool pblnIncludeLinks)
{
using (Transaction tr =
new Transaction(doc, "DeleteImports"))
{
tr.Start();
foreach (ImportInstance ii in new
FilteredElementCollector(doc).
OfClass(typeof(ImportInstance)).
Cast<ImportInstance>().
Where(i => i.IsLinked == pblnIncludeLinks))
{
doc.Delete(ii.Id);
}
tr.Commit();
}
}
Adding to the Answer: The suggestion that Dale gave you is a great one, But I see that only works for Earlier versions of Revit 2013 and earlier probably. I read the source from where he got it and I noticed that the Author also recreated it for 2014. I tested myself using Revit 2015 and 2016 and it seems to be working fine with the imported CAD files.
Credit: https://boostyourbim.wordpress.com/2013/09/11/looped-deletion-of-elements-in-2014/
Here is how the Command looks.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using System.Linq;
#endregion
namespace testDebug
{
[Transaction(TransactionMode.Manual)]
public class Command : IExternalCommand
{
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
deleteImportsNotLinks(doc);
return Result.Succeeded;
}
public void deleteImportsNotLinks(Document doc)
{
IList<ElementId> toDelete = new List<ElementId>();
foreach (ImportInstance ii in new
FilteredElementCollector(doc)
.OfClass(typeof(ImportInstance))
.Cast<ImportInstance>()
.Where(i => i.IsLinked == false))
{
toDelete.Add(ii.Id);
}
using (Transaction t = new Transaction
(doc, "Delete Imports"))
{
t.Start();
doc.Delete(toDelete);
t.Commit();
}
}