Advertisement

Saturday, December 3, 2016

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

  • Originally published on July 23, 2015.
  • Updated July 24, 2015 to include wishes #3-8. 
  • Updated July 27, 2015 to include wishes #9 & 10. 
  • Update July 27, 2015  to include the 'after party'.
  • Updated on December 4, 2016 to add additional detail for consistency with like articles.

There was A LOT of activity on Twitter today around the Revit Technology Conference North America (RTC NA, @RTCNA on Twitter) 2015, which started today in Washington DC. Signifying the importance of the event, there was also a lot of activity by Revit add-in developers in the leadup to the event. More on this aspect in subsequent posts.

Harry Mattison, he of the excellent Boost Your BIM blog, is holding a veritable one-man hackathon to grant your Revit API wishes during RTC NA 2015, which runs through Saturday. Simply express your wish and Harry will try to write a solution while he's at the convention.

From the Boost Your BIM website:

#RTCNA Wish 1 granted! Export wall type layer information

Jason wished that the API could be used to “create a data dump of wall types to show the different layers and assigned materials”

Two things to consider: Curtain and stacked walls don’t have layers, and <By Category> has no material element ID

For the source code, see this article

#RTCNA Wish 2 granted! Create view for every level for every view type

Jason gets another wish granted, this time to “Create a view for every level for every view type in your project file”



For the source code, see this article

#RTCNA Wish 3 granted! Join all walls and floors

Here’s how to find all wall/floor intersections and join their geometry. The first, simpler macro prompts the user to select to elements and then joins them. The 2nd one looks at each wall in the model and joins it to all intersecting floors.


For the source code, see this article

#AU2013 Wish granted! Convert multiple dimensions into one

Brok asked “Can you via #Revit API combine individual dims into a single string and remove the old dims?”

Yes!

The tricky part was figuring out how to avoid creating zero-length dimension segments between the references used by adjacent dimensions.



For the source code, see this article

#RTCNA wish 4 granted! Delete empty tags

Its great when a tiny bit of code can do something useful!
  • Filter for only elements in the active view: FilteredElementCollector(doc, doc.ActiveView.Id)
  • Get only tags with no text: Where(q => q.TagText == "")
  • Convert from Elements into a list of ElementIds (because that’s what Document.Delete() requires as an input): .Select(q => q.Id).ToList()


For the source code, see this article

#RTCNA wish 5 granted! Toposurface from Sokkia SDR file

Ken asked “Can an api help to use Sokkia survey data collection files (.sdr) directly into Revit topo’s without 3rd party conversions?”

There may be some tweaks needed to how the XYZ values are read from the SDR file, but this seems to come close

Results from sample file

For the source code, see this article

#RTCNA wish 6 granted! Create assemblies from groups

Here is how to create an assembly and assembly views from a group



For the source code, see this article

#RTCNA wish 7 granted! Isolated 3d view for each workset

Create a 3d view for each workset, and in that view isolate the display of the elements in that workset.

Note that to find worksets we use a FilteredWorksetCollector (not a FilteredElementCollector) and a WorksetKindFilter to get only the user worksets (don’t want view, family, project standard worksets).



For the source code, see this article

#RTCNA wish 8 granted! Delete unused elevation markers

Want to get rid of these?


For the source code, see this article

#RTCNA wish 9 granted! Place instances of multiple families

Jason asked if the API can be used to “select a bunch of families from a folder and automatically place them in an .rvt”



For the source code, see this article

#RTCNA wish 10 granted! Material replacement

Amy asked if the API can be used to find and replace materials

This implementation does that for wall types and could be extended for other objects where the material is stored in a different manner.


For the source code, see this article

#RTCNA leftover – know your StorageType

A question came up at RTC about why a certain parameter could not be set with the API. Turns out that it was a parameter that stored an ElementId. In this case, trying to set the parameter with a string for the name of the desired element does not work. And to make it confusing, it fails silently with no warning, error, or exception.

When the parameter was set with an ElementId, all was well. See the example below where we need to use the ID of the Phase named “Existing” instead of just setting the parameter to the string “Existing”.

For the source code, see this article

#RTCNA wish not granted (sorry!)

A request was made to “Turn off revision in a revision schedule in project. If I am working on RFI 2 when RFI 1 has not been submitted, i don’t want to confuse the Contractor, so would be nice if I can turn it off”

Because I think there is value is seeing how to figure out if something can or can’t be done, here is how I checked the CanFilter value of a titleblock revision schedule. Because it returned ‘false’ I don’t think this wish is grantable😦

For the source code, see this article

Great job Harry!


Related

No comments: