Advertisement

Saturday, December 3, 2016

RTC 2014 NA – Boost Your BIM's Harry Mattison Granted Revit API Wishes (Updated)

Updated on December 4, 2016: changed order to descending.

From the Boost Your BIM website:

RTCNA Wish #1: Replace detail groups with detail components

Michael McCune sent a wish via Twitter to “replace detail group instances with a detail component”.

That’s a good wish, and one that can almost be completely granted via the API as shown in this video.



The limitation is that the API provides no way to identify the rotation angle of a group instance. For any element in a subclass of the Instance class (such as a family instance, import instance, or Revit link instance) the API provides GetTransform() which contains the data needed to determine the instance’s rotation angle. The AssemblyInstance class also implements GetTransform().

Unfortunately, the Group class has no such method. As a result, while we could rotate the newly created detail components, there is no way to query the detail group instance to determine how much each detail component should be rotated.

For the source code, see this article

#RTCNA Wish 2 granted: Find pinned elements

Steve wishes for an easy way to use the API to find pinned elements. Wish granted!



For the source code, see this article

#RTCNA Wish 3: Copy rooms from one phase to another

Matt and some others asked how to “Copy All Rooms/Spaces to all phases in project”. This example shows how we can specify a “source phase” and create new rooms for each of those rooms in a “target phase”.



For the source code, see this article

#RTNCA Wish 4: Dimension creation

Last night at the API Open House, we talked about the power and limitations of the Dimensions API.

This example shows how to create dimensions that reference two parallel faces. The video shows running the command in a locked 3D view and selecting the end faces of beams. It is also necessary to set the view’s workplane so that the direction of the dimension lies in this plane.

More automated creation of these dimensions could be achieved by programatically getting the faces from the beams so that the user need only select the beam instead of the 3 faces shown in this sample.



For the source code, see this article

#RTCNA Wish 5: Delete (almost) all revisions

Scott sent a tweet about deleting all revisions from a project. The tricky part is that, just like how the UI grays out the Delete button when there is only one revision in the project, we can’t use the API to delete the last revision.


For the source code, see this article

#RTCNA Wish 6: Save all groups to file

In response to a tweet asking to save all groups, I responded that there is no API for Save Group. That’s true, but all hope is not lost.

This video shows how the API can be used to generate a text file listing all model groups. Then this text file is used as input to a journal file that saves each group to its own file.



For the source code, see this article

Related

No comments: