Jon and Scott Wilson discussed some issues creating extrusion roofs on arbitrary planes in the Revit API discussion forum in the past couple of days.
One neat spin-off is a simple little external command that shows the basic use of the NewExtrusionRoof method, so I took the opportunity of adding that to The Building Coder samples.
Before getting to the details of that, here is a little update on the upcoming events:
October will be a busy travelling month for me, participating in hackathons in Zurich, Brussels and Berlin, with the German Autodesk University in Darmstadt taking place in between as well.
The DevDay, meetup and hackathon event calendar I published a month ago remains valid.
As planned and announced, I am participating at Autodesk University in Las Vegas and the ADN DevDay and DevHack events preceding it.
My class proposals were not accepted, so my main responsibility besides the DevDay and DevHack will be to lead the Revit API expert panel SD5156 – Open House on the Factory Floor.
You can check the AU 2014 class catalogue for the complete list of classes.
The DevDays registration is now open to ADN members. The participation is free of charge.
At several sites worldwide, you can stay on for a DevHack or an evening meetup.
The meetups are open for non-ADN members as well.
The list of sites I published a month ago remains valid.
This year's DevDays theme is 10x, sharing how Autodesk is expanding its business and how you can join in on this 10x journey by using Cloud, Mobile and Desktop technologies to expand your user base by 10x while growing your revenue and profits.
The associated meetups offer an opportunity to gather with ADN partners, Autodesk and other local technologists in your community for a social and educational evening. The focus will be on bringing 3D to the web and mobile devices. Autodesk is investing in technology to make it easy for people to bring 3D content to the web across a whole range of industries and applications in addition to design and engineering. We'll have lively discussions and sharing on where broader technologies are heading as well as how to make the web an engaging 3D experience for your customers and target users.
These meetups are open to non-ADN members, so feel free to invite your technology friends and join us for some food, beverages and engaging conversation!
You can check the locations at which evening meetups will be held by visiting autodeskdevdays.com/meetups.
With all these events and conferences coming up, we will be doing a lot of presenting.
Here is a list of 33 presentation tips and tricks, pointed out by Jim Quanci, courtesy of Geoffrey James, plus another nine important suggestions specific to discussing API and source code contributed by Stephen Preston:
Sounds too good to be true, doesn't it? Let's see how well we can abide by them all :-)
Back to some hard-core Revit API usage.
In their discussion on extrusion roof failure on arbitrary planes in the Revit API discussion forum, Jon and Scott Wilson are looking at more subtle issues.
Ignoring those for the moment, I just grabbed Jon's example code to demonstrate the basic use of the NewExtrusionRoof method, using it to add a new external command named CmdNewExtrusionRoof to The Building Coder samples.
It generates this stair-shaped element, which in actual fact really is a roof:
The completely self-contained external command Execute method mainline looks like this:
UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Document doc = uidoc.Document; using( Transaction tx = new Transaction( doc ) ) { tx.Start( "NewExtrusionRoof" ); RoofType fs = new FilteredElementCollector( doc ) .OfClass( typeof( RoofType ) ) .Cast<RoofType>() .FirstOrDefault<RoofType>( a => null != a ); Level lvl = new FilteredElementCollector( doc ) .OfClass( typeof( Level ) ) .Cast<Level>() .FirstOrDefault<Level>( a => null != a ); double x = 1; XYZ origin = new XYZ( x, 0, 0 ); XYZ vx = XYZ.BasisY; XYZ vy = XYZ.BasisZ; SketchPlane sp = SketchPlane.Create( doc, new Autodesk.Revit.DB.Plane( vx, vy, origin ) ); CurveArray ca = new CurveArray(); XYZ[] pts = new XYZ[] { new XYZ( x, 1, 0 ), new XYZ( x, 1, 1 ), new XYZ( x, 2, 1 ), new XYZ( x, 2, 2 ), new XYZ( x, 3, 2 ), new XYZ( x, 3, 3 ), new XYZ( x, 4, 3 ), new XYZ( x, 4, 4 ) }; int n = pts.Length; for( int i = 1; i < n; ++i ) { ca.Append( Line.CreateBound( pts[i - 1], pts[i] ) ); } doc.Create.NewModelCurveArray( ca, sp ); View v = doc.ActiveView; ReferencePlane rp = doc.Create.NewReferencePlane2( origin, origin + vx, origin + vy, v ); rp.Name = "MyRoofPlane"; ExtrusionRoof er = doc.Create.NewExtrusionRoof( ca, rp, lvl, fs, 0, 3 ); Debug.Print( "Extrusion roof element id: " + er.Id.ToString() ); tx.Commit(); } return Result.Succeeded;
You can download the most up-to-date version from The Building Coder samples GitHub repository.
The version discussed above is 2015.0.112.0.