Technical Summit Day 1 and Removing References

Today was the first day of the Autodesk internal Technical Summit in Toronto, and pretty exciting.

Also, I just had a note from Norway on how to remove references that looks worthwhile sharing.

So here is a list of today's multifaceted topics:

Technical Summit Day 1

This being an internal meeting, I cannot talk openly about all the topics covered.

A couple of titbits that I found especially exciting are based on openly available research, though, so I can't do much harm mentioning those.

R3 – Recent Rendering Research

One talk discussed viewing and rendering and mentioned these exciting recent results that are all being incorporated:

JavaScript Optimisation

The same presentation also mentioned some impressive tips and tricks for enhancing JavaScript performance, e.g. encoding metadata requiring quick lookup in SQL tables, then mapping those tables to JSON arrays.

Further fundamental JavaScript performance optimisation recommendations include:

Rotation Invariant Spherical Harmonics for Shape Classification

Check out this fascinating paper on Tools for 3D-Object Retrieval: Karhunen-Loeve Transform and Spherical Harmonics by D.V. Vranić, D. Saupe, and J. Richter.

For practical use, it obviously needs to implement some kind of grouping of buckets of similar shapes, which is a completely different additional story...

Highly Recommended Web App Packages

Are you building any kind of web application at all?

You certainly should be, nowadays, if you are a professional application developer.

If not, you should be aware that most bits and pieces of functionality of those 2 GB footprint desktop applications can be rebuilt in a browser with much smaller footprint in very short time. So if you don't do it, somebody else is going to pretty soon.

Here is a pretty comprehensive list of useful packages that help a lot in supporting numerous best practices for a web app:

By the way, Angular also provides the best tutorial for anything I have ever seen, Shaping up with Angular.js.

You absolutely must check it out, if only to be impressed by the level of didactics that is achievable today.

There was a lot more, of course... I am really looking forward to day 2!

Removing RVT Links

Back to the everyday Revit API, here is a question raised and immediately answered by Håvard Dagsvik of Cad Quality as:

Question: I'm trying to remove RVT links from a project.

This code works fine:

  public void RemoveRvtLinks( Document doc )
    FilteredElementCollector elemColl
      = new FilteredElementCollector( doc )
        .OfClass( typeof( RevitLinkType ) );
    IList<ElementId> eIds = new List<ElementId>();
    foreach( RevitLinkType r in elemColl )
      if( r is RevitLinkType )
        RevitLinkType rvtLink = r as RevitLinkType;
        if( null == rvtLink || rvtLink.IsNestedLink )
        eIds.Add( rvtLink.Id );
    doc.Delete( eIds );

I'm using RevitLinkType instead of RevitLinkedInstance to avoid the Revit UI message saying that 'the last instance has been removed; do you want to remove the reference'.

The catch is that if the link is Unloaded, Not Found or for some reason not present both will throw an exception.

The API doesn’t seem to provide a 'Remove' method for links, only Document.Delete.

But in such cases there is nothing to delete.

Is this possible to do at all?

Answer: Apparently yes.

After further testing, I can confirm that the code above works both on unloaded and not found links.

Here is a cleaned-up and slightly more succinct version using LINQ avoiding the duplicate casts above:

  public void RemoveRvtLinks2( Document doc )
    FilteredElementCollector links =
      new FilteredElementCollector( doc )
        .OfClass( typeof( RevitLinkType ) );
    ICollection<ElementId> ids
      = links.Cast<RevitLinkType>()
        .Where<RevitLinkType>( r => !( r.IsNestedLink ) )
        .Select<RevitLinkType, ElementId>( r => r.Id )
    doc.Delete( ids );