Quantcast
Channel: All Revit API Forum posts
Viewing all articles
Browse latest Browse all 66666

How to get imported Categories

$
0
0

Hi,

 

In Revit Graphics/Visibility Overrides dialog, I can see the Imported Categories tab.

2016-07-28_1818.png

In API Category has a property CategoryType which is Enum with the following values:

  • Invalid
  • Model
  • Annotation
  • Internal
  • AnalyticalModel

Looks like CategoryType corresponds the tabs in Dialog, but not. Imported Categories also have CategoryType = CategoryType.Model, but not appear in the Model Categories tab.

 

Is there a way to find out whether a category is Imported or not?

 

I actually found two ways. The first on is implicit. I just looked into RevitLookup and checked the properties of Imported category:

2016-07-28_1823.png

I noticed the following:

  • Category.Id is not BuiltInCategory, i.e. value > 0
  • Properties AllowsBoundParameters, CanAddSubcategory, HasMaterialQuantities and IsCuttable are always false for imported categories.

As a result, I cretaed the extension method:

    public static class CategoryExtenstions
    {
        public static bool IsImportedCategory(this Category category)
        {
            if (Enum.IsDefined(typeof(BuiltInCategory), category.Id.IntegerValue))
                return false;

            if (category.Id.IntegerValue < -1)
                return false;

            return category.AllowsBoundParameters == false &&
                category.CanAddSubcategory == false &&
                category.HasMaterialQuantities == false &&
                category.IsCuttable == false;
        }
    }

It works. I tested it only for couple models. But want to now is it reliable method or not?

 

The second one is more complicated, but gave for me the same result.

Searching by keyword "Imported" in Revit API help, I've found the only enum member:

2016-07-28_1829.png

Sounds like this is exactly that I need.

 

This enum member is related with DWG Export Options. In UI we can find it in DWG Export Settings dialog:

2016-07-28_1831.png

 

I will not provide the code snippet for this approach. It is really much complicated and gives the same result.

 

Are there other ways to find out Imported Categories? Definitely internally Revit knows about that, but how to get this info in API? Or I have already found this way? :)

 

Thanks,

Victor.


Viewing all articles
Browse latest Browse all 66666

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>