-1

I'm a software developer working at Architecture Design Firm (Archcorp.biz). Here we are developing custom plugins for Revit 2017 using Revit API. I'd like to know is this possible to read family type and instance properties before importing it into the Revit 2017 editor? If yes, would appreciate some initial guide. Thank you.

Ali Asad
  • 1,235
  • 1
  • 18
  • 33

2 Answers2

1

There is a class available called BasicFileInfo http://www.revitapidocs.com/2018/f7a75811-b2ec-8b4c-10d3-6ed0eadf4551.htm that will give you some basic information about the file (rvt) without opening it.

There is also a method described here that extracts some Parameters that have values set in the familiy without actually opening it. http://thebuildingcoder.typepad.com/blog/2009/11/extract-part-atoms.html

konrad
  • 3,544
  • 4
  • 36
  • 75
  • Hi Konrad, Thank you for your reply. However the suggested link doesn't explain anything regarding revit family types and parameters. – Ali Asad Oct 24 '17 at 04:29
  • Thanks for the explanation. maybe i should have asked it another way. anyway the answer I gave has helped me. please check that out too :) – Ali Asad Oct 25 '17 at 05:23
0

By struggling through some hours, I finally came up with a solution. All I have to do was to read revit family file by using application.OpenDocumentFile(FamilyPath); method. The following code will help anyone to extract revit family types information.

    private void ExtractFamilyInfo(Application app)
    {
        //A placeholder to store types information
        string types = "Family Types: ";


        //Open Revit Family File in a separate document
        var famDoc = app.OpenDocumentFile(FamilyPath);

        //Get the familyManager instance from the open document
        var familyManager = famDoc.FamilyManager;

        //Get the reference of revit family types
        FamilyTypeSet familyTypes = familyManager.Types;
        //Set iteration to forward
        FamilyTypeSetIterator familyTypesItor = familyTypes.ForwardIterator();
        familyTypesItor.Reset();

        //Loop through all family types
        while (familyTypesItor.MoveNext())
        {
            FamilyType familyType = familyTypesItor.Current as FamilyType;
            //read all family type names
            types += "\n" + familyType.Name;
        }

        //Display text on the UI
        DefaultControl.Instance.PropertyText.Text = types.ToString();

    }
Ali Asad
  • 1,235
  • 1
  • 18
  • 33