Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to delete family from document ?

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Adamchuk_Nicolay
2333 Views, 1 Reply

How to delete family from document ?

Hi,

 

how to delete family from project (not symbol or instance) ?

Can not to use ActiveDocument.Delete(ElementID) becouse can not find the ID for loaded family.

 

Thank you for advance.

1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Adamchuk_Nicolay

The way you can find the element id of the family is by filtering for families and then finding the desired family by name or some other characteristic:

 

void DeleteFamilyTest() {
            Family famToDelete = null;
            FilteredElementCollector fec = new FilteredElementCollector(uidoc.Document);
            fec.OfClass(typeof(Family));
            foreach (Element e in fec.ToElements()) {
                Family f = e as Family;
                if (null != f && f.Name.Equals("SomeFamilyName")) {
                    famToDelete = f;
                }
            }
            if (null != famToDelete) {
                uidoc.Document.Delete(famToDelete.Id);
            }
        }

 Hope this helps!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Rail Community