Returning value from a function

Returning value from a function

pccheung
Contributor Contributor
336 Views
1 Reply
Message 1 of 2

Returning value from a function

pccheung
Contributor
Contributor

Dear all,

I am trying to create a function to get the ElementId from the SolidPattern from FillPatternElement.

My functions seems fails to return the solidFillPatternId, instead, it seems returning a null(Not Sure).

Could anybody corrects my code if it is wrong?

1.PNG

 

 

        //Get the Solid Fill Pattern 
        public ElementId GetSolidFillPatternId(Document doc)
        {
            List<FillPatternElement> fillPatternList = new FilteredElementCollector(doc).WherePasses(new ElementClassFilter(typeof(FillPatternElement))).
                ToElements().Cast<FillPatternElement>().ToList();

            ElementId solidFillPatternId = null;

            foreach (FillPatternElement fp in fillPatternList)
            {
                if (fp.GetFillPattern().IsSolidFill)
                {
                    solidFillPatternId = fp.Id;
                }
            }

            return solidFillPatternId;
            
        }

 

 

 

 

Thanks!!

 

 

0 Likes
337 Views
1 Reply
Reply (1)
Message 2 of 2

jeremytammik
Autodesk
Autodesk

Presumably, the `if` condition within the `foreach` loop is never fulfilled.

 

Try debugging the code to see exactly what happens.

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes