Example #1
0
        public static bool IsValidElement(DB.Element element)
        {
            if (element is DB.ElementType)
            {
                return(false);
            }

            if (element is DB.View)
            {
                return(false);
            }

            if (element.Location is object)
            {
                return(true);
            }

            return
                (
                element is DB.DirectShape ||
                element is DB.CurveElement ||
                element is DB.CombinableElement ||
                element is DB.Architecture.TopographySurface ||
                element is DB.Opening ||
                element is DB.Part ||
                InstanceElement.IsValidElement(element)
                );
        }
Example #2
0
        protected virtual bool SetValue(DB.Element element)
        {
            if (ScriptVariableType.IsInstanceOfType(element))
            {
                Document     = element.Document;
                DocumentGUID = Document.GetFingerprintGUID();
                Value        = element.Id;
                UniqueID     = element.UniqueId;
                return(true);
            }

            return(false);
        }
Example #3
0
        public static Element FromElement(DB.Element element)
        {
            if (element is null)
            {
                return(null);
            }

            if (element.GetType() == typeof(DB.Element))
            {
                try
                {
                    if (DB.Category.GetCategory(element.Document, element.Id) is DB.Category category)
                    {
                        return(new Category(category));
                    }
                }
                catch (Autodesk.Revit.Exceptions.InternalException) { }
            }
            else
            {
                for (var type = element.GetType(); type != typeof(DB.Element); type = type.BaseType)
                {
                    if (ActivatorDictionary.TryGetValue(type, out var activator))
                    {
                        return(activator(element));
                    }
                }
            }

            if (GraphicalElement.IsValidElement(element))
            {
                if (InstanceElement.IsValidElement(element))
                {
                    if (Panel.IsValidElement(element))
                    {
                        return(new Panel(element as DB.FamilyInstance));
                    }

                    return(new InstanceElement(element));
                }

                return(GeometricElement.IsValidElement(element) ?
                       new GeometricElement(element) :
                       new GraphicalElement(element));
            }

            return(new Element(element));
        }
Example #4
0
 protected override bool SetValue(DB.Element element) => IsValidElement(element) && base.SetValue(element);
Example #5
0
 public GraphicalElement(DB.Element element) : base(element)
 {
 }
 public virtual bool AllowElement(DB.Element elem) => elem is R;
Example #7
0
 public static new bool IsValidElement(DB.Element element)
 {
     using (var options = new DB.Options())
         return(!(element.get_Geometry(options) is null));
 }
Example #8
0
 public GeometricElement(DB.Element element) : base(element)
 {
 }
Example #9
0
 protected Element(DB.Element element) : base(element.Document, element.Id)
 {
 }