简体   繁体   English

在将 Revit 族属性导入 Revit 2017.exe 之前,如何使用 Revit API 读取它

[英]How can I read Revit Family Properties using Revit API before importing it into the Revit 2017.exe

I'm a software developer working at Architecture Design Firm ( Archcorp.biz ).我是一名在建筑设计公司 ( Archcorp.biz ) 工作的软件开发人员。 Here we are developing custom plugins for Revit 2017 using Revit API.在这里,我们正在使用 Revit API 为 Revit 2017 开发自定义插件。 I'd like to know is this possible to read family type and instance properties before importing it into the Revit 2017 editor?我想知道在将族类型和实例属性导入 Revit 2017 编辑器之前是否可以读取它? If yes, would appreciate some initial guide.如果是的话,希望得到一些初步的指导。 Thank you.谢谢你。

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.有一个名为BasicFileInfo的类http://www.revitapidocs.com/2018/f7a75811-b2ec-8b4c-10d3-6ed0eadf4551.htm可以在不打开文件的情况下为您提供有关文件 (rvt) 的一些基本信息。

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 http://thebuildingcoder.typepad.com/blog/2009/11/extract-part-atoms.html

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);我所要做的就是使用application.OpenDocumentFile(FamilyPath);读取 revit 族文件application.OpenDocumentFile(FamilyPath); method.方法。 The following code will help anyone to extract revit family types information.以下代码将帮助任何人提取 revit 族类型信息。

    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();

    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM