GeometryGym / GeometryGymIFC

C# classes to generate and parse OpenBIM IFC files
Other
269 stars 97 forks source link

Cannot import CrossSectionPositions when IfcNonNegativeLengthMeasure is used #48

Closed eihov closed 3 years ago

eihov commented 3 years ago

Hi,

When importing IfcSectionedSolidHorizontal the CrossSectionPositions list will only be availiable if IfcParameterValue is used as IfcCurveMeasureSelect. When I use IfcNonNegativeLengthMeasure the CrossSectionPositions list will not get loaded:

image

image

Thank you for any feedback!

eihov commented 3 years ago

I have looked into the code of parsing IfcCrossSectionPosition and made a new parse method to parse lists like these:

public static List<string> SplitField(string s)
        {
            var returnValues = new List<string>();
            var len = s.Length;
            int pos = 0;
            while (true)
            {
                if (!(pos < s.Length))
                { 
                    throw new Exception("Unrecognized format!");

                };
                if (pos == 0)
                {
                    if (s[pos] == '(')
                    {
                        pos++;
                    }
                    else
                    {
                        throw new Exception("Unrecognized format!");
                    }
                }

                string value = "";
                while (true)
                {
                    if (!(pos < s.Length))
                    {
                        throw new Exception("Unrecognized format!");
                    };

                    if (s[pos] == ',')
                    {
                        returnValues.Add(value);
                        pos++;
                        break;
                    }
                    if (pos == s.Length - 1 && s[pos] == ')')
                    {
                        returnValues.Add(value);
                        return returnValues;
                    }

                    value += s[pos];
                    pos++;
                }
            }
        }

So it can be used inside the parser like this:

image

Perhaps if I get the right permission I can make a pull request of these changes that you can review?

Thank you!