I'm having problems creating extrusion roofs on arbitrary planes.
I've attached code and a revit project to run it in (2015). If you change the x variable to zero it works fine.
Thanks,
Jon
The problem is in the way you are creating the ReferencePlane. Take a look at the parameters for NewReferencePlane2, it needs 3 points to create the plane and you are passing in 1 point and 2 vectors, which is giving you a plane with a freaky orientation that the RoofCreator takes some exception with apparently.
Here's the fix for your example code:
rp = doc.Create.NewReferencePlane2(origin, origin + vx, origin + vy, v);
Hi Scott,
Thanks for your reply and pointing out the problem. I can generate the extrusion roofs with this ammendment.
However Revit is pretty fragile with this. Why does it crash when running with the attached project?
I've attached some updated code to find a roof type with equivalent thickness. What is the characteristic that is the problem here?
Cheers,
Jon
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:
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.
Hi Scott,
Thank you for a very insightful analysis. Makes total sense to me. I'll try it out asap and submit a request for the development team to take a closer look if I can reproduce.
Meanwhile:
Hi Jon,
I added your sample code as a new command to The Building Coder samples, if you don't mind, since we have never shown how to use the NewExtrusionRoof method before, and I like the interesting roof shape produced:
I hope that meets your approval. 🙂
Thank you!
Cheers,
Jeremy
Here is the post, hot off the press:
http://thebuildingcoder.typepad.com/blog/2014/09/events-again-and-creating-an-extrusion-roof.html
Thank you for the nice sample!
Cheers,
Jeremy