»Dim inst As FamilyInstance
»Dim instCat As Category
»Dim ss As ElementSet = doc.Selection.Elements
»' Make sure we have a single
FamilyInstance selected
»If Not ss.Size = 1 Then
» MsgBox("You must pre-select a single
element!")
» Return
IExternalCommand.Result.Cancelled
»Else
» Dim itTmp As ElementSetIterator
= ss.ForwardIterator
» itTmp.MoveNext()
» Dim elTmp As
Revit.Element = itTmp.Current
» If Not TypeOf elTmp Is FamilyInstance Then
» MsgBox("Selected element is NOT a
standard family instance!")
» Return
IExternalCommand.Result.Cancelled
» Else
» inst = elTmp
» instCat = inst.Category
» End If
»End If