Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Extrusion roof fails

5 REPLIES 5
Reply
Message 1 of 6
GeomGym
1342 Views, 5 Replies

Extrusion roof fails

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

Tags (2)
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: GeomGym

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);

 

 

 

 

Message 3 of 6
GeomGym
in reply to: Anonymous

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

Message 4 of 6
Anonymous
in reply to: GeomGym

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:

 

  1. 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.
  2. Double the length of each line in your curve array. All good, no crash.
  3. 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.

Message 5 of 6
jeremytammik
in reply to: Anonymous

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:

 

NewExtrusionRoof.png

 

I hope that meets your approval.  🙂

 

Thank you!

 

Cheers, 

 

Jeremy



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

Message 6 of 6
jeremytammik
in reply to: jeremytammik

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



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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community