Example #1
0
        public override sealed bool CastFrom(object source)
        {
            if (source is IGH_Goo goo)
            {
                source = goo.ScriptVariable();
            }

            var categoryId = DB.ElementId.InvalidElementId;

            switch (source)
            {
            case DB.Category c:   SetValue(c.Document(), c.Id); return(true);

            case DB.ElementId id: categoryId = id; break;

            case int integer:     categoryId = new DB.ElementId(integer); break;
            }

            if (categoryId.IsCategoryId(Revit.ActiveDBDocument))
            {
                SetValue(Revit.ActiveDBDocument, categoryId);
                return(true);
            }

            return(false);
        }
Example #2
0
        new public static Category FromElementId(DB.Document doc, DB.ElementId id)
        {
            if (id.IsCategoryId(doc))
            {
                return(new Category(doc, id));
            }

            return(null);
        }