I think it has something to do with the line lengths used in the curve array, combined with the internal workings of the API.
What I think is happening internally is that the API takes the first roof type it finds, creates the roof and then switches its type to the one you selected. If the profile you pass in is invalid for the first roof, it all falls to pieces regardless of whether it would be fine for the actual roof type you chose.
I noticed that the first roof type that the API returns in the collector of your test project is the 400mm one, and since your curve array contains 1ft segments with 90° internal angles, this would be invalid for a 400mm thick roof. Even though you are selecting the thinnest roof in your code (125mm) the API is trying to create the roof with the 400mm type and is crashing before it can change the type to 125mm.
You can test this in 3 ways:
- Comment out the roof creation code and just let your command draw the model lines and reference plane. Manually create the extrusion roof in the UI by tracing over the model lines and selecting your new reference plane. It works fine for the 125mm roof, but the 400mm causes an invalid profile error.
- Double the length of each line in your curve array. All good, no crash.
- Leave the original 1ft line segments, but delete the 400mm roof type before running the command. All good, no crash.
Looks like another API bug to me. We need to start getting a finder's fee for these 🙂
I actually think this is the same error you were first getting. Technically the sketch doesn't need to be aligned with the reference plane and shouldn't have given you the error, but because the plane was skewed, the sketch is projected onto the reference plane and the resulting projection probably contained lines too short (considereing the 90° internal bends) for the roof type it was using and this caused the error.