New in 2019.1 – Attached Detail Group API

The new 2019.1 release has added API for attached detail groups! Thanks Autodesk!

For example:

  • GetAvailableAttachedDetailGroupTypeIds returns the attached detail groups of a group or group type
  • HideAllAttachedDetailGroups & HideAttachedDetailGroups to hide some or or all of a model group’s attached detail groups in a specific view
  • ShowAttachedDetailGroups to show an attached detail group on a model group in a specific view

attached detail 1

On a technical note, GetAvailableAttachedDetailGroupTypeIds returns a C# “set”, a data structure that can store certain values, without any particular order, and no repeated values. A couple good resources to learn more about sets are:

public void GetAvailableAttachedDetailGroupTypeIds()
{
    Document doc = this.ActiveUIDocument.Document;
    UIDocument uidoc = this.ActiveUIDocument;
    Group modelGroup = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element, "Select Model Group")) as Group;
    HashSet attachedDetailIds = modelGroup.GetAvailableAttachedDetailGroupTypeIds() as HashSet;
    TaskDialog.Show("Attached detail groups", string.Join(Environment.NewLine, attachedDetailIds.Select(q => doc.GetElement(q).Name)));
}
public void HideDetailGroup()
{
    Document doc = this.ActiveUIDocument.Document;
    UIDocument uidoc = this.ActiveUIDocument;
    Group modelGroup = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element, "Select Model Group")) as Group;
    Group detailGroup = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element, "Select detail group to hide")) as Group;
    using (Transaction t = new Transaction(doc, "hide detail groups"))
    {
        t.Start();
        modelGroup.HideAttachedDetailGroups(doc.ActiveView, detailGroup.GroupType.Id);
        t.Commit();
    }
}
public void ShowDetailGroup()
{
    Document doc = this.ActiveUIDocument.Document;
    UIDocument uidoc = this.ActiveUIDocument;
    Group modelGroup = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element, "Select Model Group")) as Group;
    Element detailGroupType = new FilteredElementCollector(doc).OfClass(typeof(GroupType))
        .OfCategory(BuiltInCategory.OST_IOSAttachedDetailGroups)
        .FirstOrDefault(q => q.Name == "Door Dimensions A6");
        
    using (Transaction t = new Transaction(doc, "show detail group"))
    {
        t.Start();
        modelGroup.ShowAttachedDetailGroups(doc.ActiveView, detailGroupType.Id);
        t.Commit();
    }
}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s