Advertisement

Saturday, December 3, 2016

RTC 2016 EUR – Boost Your BIM's Harry Mattison Granted Revit API Wishes (Update #4)

As he often does around the larger Revit conferences, Harry Mattison took and granted Revit API wishes at RTC 2016 EUR.

Wishes could be posted on Boost Your BIM or tweeted to @BoostYourBIM.

  • Originally published on October 21, 2016.
  • Updated on October 21, 2016 to add the third and fourth items.
  • Updated on October 22, 2016 to add the fifth item.
  • Updated on October 22, 2016 to add the sixth and final item, and to re-frame the article in the past-tense.
  • Updated on December 4, 2016 to add additional detail for consistency with like articles.

#RTCEUR API Wish #1: Purging Types and Families

The first wish granted from Porto is for Phil who wished for "a solution to purging unused Revit elements from a Revit model." Different elements need to be purged in different ways. This code will clean up unused system and loadable families and their types.


The “RollbackIfErrorOccurs” section is used to handle the case where deleting a wall type would result in this error.


For the source code, see this article

#RTCEUR Wish 2: Pipe Split and Hanger Creation

Brian wished for "splitting MEP Pipework at certain distances on the horizontals with Revit MEP Hangers." Here’s a look at how the API can be used to create a new set of pipes of a specified length to replace one long pipe. Hangers are placed at the start and end of each new pipe.

One opportunity for improvement would be to do something more sophisticated at the end of the original pipe. If your pipe comes in standard lengths, you may not want to end up with a 1′ piece of pipe at the end if you need 37′ total feet of pipe and your standard length is 6′.



For the source code, see this article

Making change (or select pipe lengths) at #RTCEUR

Building on yesterday’s post about pipe splitting, you may want a semi-intelligent way to choose quantities of pre-cut lengths to use when you break apart a long element into fabricated pieces.

Fortunately, this is the same challenge as how to make change for a given amount of money. You have a total amount (of money, length of pipe, etc) and a defined set of options (quarter, nickels, dimes, 6 and 10 foot pieces of pipe, etc) to use to get to the total. Many computer science students have probably tackled this problem and there are various solutions on the web.


The approach below uses recursion which is always exciting and adds a wrinkle that change-making doesn’t include. I added the idea of a “flexible length” and a minimum flexible length. It is possible to cut pipe into non-uniform lengths, but there is a minimum length that should not be allowed.

Some sample output for different lengths:


For the source code, see this article

Purge unused materials for another #RTCEUR API wish

Yesterday I looked at how to purge unused families and family types. Purging materials needs a different approach because they are not used directly in the project but are referenced by other objects.

Here is an approach that uses the DocumentChanged event, rolling back Transaction Groups, and other good things do find materials that can be deleted without elements being modified. It takes a bit of time to run because it is deleting all materials and undoing the deletions that modify other elements.


For the source code, see this article

Journal time-stamps at a set interval for another #RTCEUR #Revit API wish

Joel wished for “a time stamp added to journal files. I’m thinking something like an addin or macro that just notes the current time at specified intervals. The use would be for tracking performance – what processes take a long time, and how much how much time.”

It is so great that C# has the Timer class to make this easy – https://www.dotnetperls.com/timer


For the source code, see this article

The last #RTCEUR #Revit API Wish – Parts Want Levels

Here’s the last wish granted! RVT Links are used to model typical floors and parts are created from the walls and floors in the link instances. Here is how to use the API to set a user-created “Level” parameter for each part based on the name of the level in the host RVT nearest to the lowest point in the geometry of each part.


For the source code, see this article

Related

No comments: