The Part Type is from the Family not from the FamilyInstance.
This code could help!
/// <summary>
/// Get PartType from the FamilyInstance
/// </summary>
/// <param name="familyInstance"></param>
/// <returns></returns>
public static PartType GetFamilyPartType(this FamilyInstance familyInstance)
{
if (familyInstance?.Symbol?.Family is Family family)
{
var type = family.get_Parameter(BuiltInParameter.FAMILY_CONTENT_PART_TYPE).AsInteger();
return (PartType)type;
}
return PartType.Undefined;
}
This is all the valid PartType on version 2021.
public enum PartType
{
Undefined = -1,
Normal = 0,
DuctMounted = 1,
JunctionBox = 2,
AttachesTo = 3,
BreaksInto = 4,
Elbow = 5,
Tee = 6,
Transition = 7,
Cross = 8,
Cap = 9,
TapPerpendicular = 10,
TapAdjustable = 11,
Offset = 12,
Union = 13,
PanelBoard = 14,
Transformer = 15,
SwitchBoard = 16,
OtherPanel = 17,
EquipmentSwitch = 18,
Switch = 19,
ValveBreaksInto = 20,
SpudPerpendicular = 21,
SpudAdjustable = 22,
Damper = 23,
Wye = 24,
LateralTee = 25,
LateralCross = 26,
Pants = 27,
MultiPort = 28,
ValveNormal = 29,
JunctionBoxTee = 30,
JunctionBoxCross = 31,
PipeFlange = 32,
JunctionBoxElbow = 34,
ChannelCableTrayElbow = 35,
ChannelCableTrayVerticalElbow = 36,
ChannelCableTrayCross = 37,
ChannelCableTrayTee = 38,
ChannelCableTrayTransition = 39,
ChannelCableTrayUnion = 40,
ChannelCableTrayOffset = 41,
ChannelCableTrayMultiPort = 42,
LadderCableTrayElbow = 43,
LadderCableTrayVerticalElbow = 44,
LadderCableTrayCross = 45,
LadderCableTrayTee = 46,
LadderCableTrayTransition = 47,
LadderCableTrayUnion = 48,
LadderCableTrayOffset = 49,
LadderCableTrayMultiPort = 50,
InlineSensor = 51,
Sensor = 52,
EndCap = 53,
HandrailBracketHardware = 54,
PanelBracketHardware = 55,
TerminationHardware = 56,
Rails = 57,
Handrails = 58,
TopRails = 59,
PipeMechanicalCoupling = 60
}
PanelBoard is number 14!
See yaa!