Exemple #1
0
        public override Value Evaluate(FSharpList <Value> args)
        {
            var result = new List <List <FamilyInstance> >();

            //"Get an interface to the divided surfaces on this element."
            //TODO: do we want to select a face instead and try to get
            //the divided surface that way?
            DividedSurfaceData dsd = SelectedElement.GetDividedSurfaceData();

            if (dsd == null)
            {
                throw new Exception("The selected form has no divided surface data.");
            }

            foreach (Reference r in dsd.GetReferencesWithDividedSurfaces())
            {
                Autodesk.Revit.DB.DividedSurface ds = dsd.GetDividedSurfaceForReference(r);

                var gn = new GridNode();

                int u = 0;
                while (u < ds.NumberOfUGridlines)
                {
                    var lst = new List <FamilyInstance>();

                    gn.UIndex = u;

                    int v = 0;
                    while (v < ds.NumberOfVGridlines)
                    {
                        gn.VIndex = v;

                        //"Reports whether a grid node is a "seed node," a node that is associated with one or more tiles."
                        if (ds.IsSeedNode(gn))
                        {
                            FamilyInstance fi
                                = ds.GetTileFamilyInstance(gn, 0);

                            //put the family instance into the tree
                            lst.Add(fi);
                        }
                        v = v + 1;
                    }

                    //don't add list if it's empty
                    if (lst.Any())
                    {
                        result.Add(lst);
                    }

                    u = u + 1;
                }
            }

            _data = Value.NewList(
                Utils.SequenceToFSharpList(
                    result.Select(
                        row => Value.NewList(
                            Utils.SequenceToFSharpList(
                                row.Select(Value.NewContainer))))));

            return(_data);
        }