DevCamp Session on What’s New

Yesterday we had a great start to the AEC DevCamp here in Boston with lots of great presentations and meetings, and ending with the traditional beer bust at the Autodesk offices in Waltham half an hour’s bus ride away from the convention centre here in Boston.

Today is packed with more presentations, obviously, some of which I will hate to miss since there are multiple tracks and I cannot attend all of them simultaneously.
Some sessions will be presented by members of the Revit development team and include unique information and insights not available anywhere else.

I’ll also present the first of my own sessions, on what’s new in the Revit 2011 API and how to use it.
Several of the areas I cover have already been discussed here in the blog.
My main topics in that session will be:

I plan to publish details on the new Idling event samples here as well as soon as I can get to it.
Right here and now, let me at least complete the overview of the new SDK samples.

New SDK Samples in Revit 2011

I have already mentioned a number of the new SDK samples provided in the Revit 2011 SDK in previous posts, and in some cases described their use and implementation in detail as well, but I notice that a complete overview listing them all is still missing so far.

So here it is.
The following samples are completely new:

I added links to existing blog posts on the ones I already discussed.

We also have these three SDK samples which existed in previous incarnations and were rewritten from scratch because the underlying API functionality was completely changed:

  • HelloRevit
  • ImportExport
  • TransactionControl

SDK Sample Spreadsheet

I also updated my
Revit SDK sample spreadsheet which
provides an overview and classification of all SDK samples into various categories.
I initially created it to keep track of all the external command registration data required for Revit.ini entries to load the samples, and to automatically generate the text file read by the first incarnation of

RvtSamples

to handle all of them in one go.
Nowadays RvtSamples in included in the SDK itself, and the development team creates the text file to drive it, but I still keep my spreadsheet up to date.
I also used this way back for the DE101-3 Revit SDK Sample Smörgåsbord presentation at

AU 2008
.
Anyway, here is the updated
version for Revit 2011.

Time for breakfast.
I am on the nineteenth floor looking out at another wonderful day outside the window with a beautiful view northward over the Charles River, Cambridge and the MIT, a huge and completely cloudless blue sky after heavy thunderstorms in the past days.
Painful to spend a day like this cooped up in a convention centre, however exciting the topic may be…


Comments

12 responses to “DevCamp Session on What’s New”

  1. bsyap Avatar
    bsyap

    Hi,
    I am using a Structural Modeling/Design application to model’design a simple building. And I am trying to save the content/data generated by the application into a revit file format (.rvt) using the Revit API.
    Example :
    1)How to save the (Source)Structural Beam Data (generated by my Structural Modeling/Design application) into the (Target)Beam Data in Revit Structural Software. (.rvt)
    2)How to map each of my external data into a revit file.
    eg: Let’s said my beam object contain properties like beam depth(DOUBLE), beam length(DOUBLE), beam offset(DOUBLE),beam mark(string),isConcreate(boolean)…, how do I map all this field into Revit beam object.
    As a result, Autodesk Revit Structure can be able to generate the same building i have modeled/designed.
    Any idea of doing this?
    Any help would be greatly appreciated.
    Regards,
    bsyap

  2. Dear bsyap,
    1) You can define shared parameters on the beam elements and store arbitrary data in those. For more information on this, look at the Parameters category:
    http://thebuildingcoder.typepad.com/blog/parameters
    2) For mapping data between an external database and Revit elements, the safest bet is to make use of the Revit element UniqueId property, which provides a unique identifier for each element.
    Cheers, Jeremy.

  3. Hi Jeremy,
    Thanks for the reply. I have read the solution you provided above. However, i need to save all the content/data generated by a third party structural application to a .rvt(Revit file). The solution you provided is for Revit user to import external database into Revit program, but what i intended to do is to write the structural content into a .rvt extension file.
    I have study the Revit API and the class structure of Revit (Application,Document, Element,…)and the Revit class structure is huge.
    Below is the scenario of what i am intended to do.
    1)Create the Revit file. (How can i create a Revit file without the using the IexternalCommand doc = commandData.Application.ActiveUIDocument.Document;
    I have try to create a new Revit document using this, but it won’t works.
    Application revitApp = new Application();
    Document doc = revitApp.NewProjectDocument(RevitTemplate);
    Exception Thrown : revitApp.Family Template Path threw an exception of type
    {Autodesk.Revit.Exceptions.ApplicationException} = {“Object has not been initialized yet.”}
    I have all the content of a building model such as grid/beam/column/slab/load/wall. How am i get all this data fit into the Revit building model.
    Eg:
    2)Creation of beam/grid/slab object. (How do i map my own beam data to the revit beam object.)
    Eg: I have a myBeam class. After initiation of myBeam object, how do i map the value of each of the properties into the beam object in Revit.
    public class myBeam
    {
    //private fields
    private double length;
    private string beammark;
    private bool isconcreate;
    //Constructor
    public myBeam(){}
    //Properties
    public double Length{ get{} set{} }
    }
    3)Save the Revit file. (How can I save the Revit document file.)
    doc.SaveAs(“example.rvt”),this command didn’t work since the early exception thrown.
    Any help would be greatly appreciated.
    Regards,
    bsyap

  4. Dear bsyap,
    The Revit API is actually pretty small compared to AutoCAD ARX.
    You cannot create a new instance of the Revit Application class.
    An application instance is provided to you in the external command Exectue callback method, and other Revit API entry point methods.
    You cannot drive Revit or make ose of the Revit API from outside a Revit API callback context, as described in numerous posts on this blog, e.g.
    http://thebuildingcoder.typepad.com/blog/2010/04/asynchronous-api-calls-and-idling.html
    Cheers, Jeremy.

  5. Hi Jeremy,
    Thanks again for the reply. Since I can’t create
    an instance of Revit Application file, i can’t store all my third party application building information into the Revit file.
    May I know is there any alternative ways to store a third party application building data(beam length, column width,…) in order to be imported and shared by the Revit application.
    Besides that, do i need to set/map each of my building data respectively to a building data in Revit. But how? using element iteration and set the value of each element?
    Eg: I have a myBeam class. After initiation of myBeam object, how do i map the value of each of the properties into the beam object in Revit.
    public class myBeam
    {
    //private fields
    private double length;
    private string beammark;
    private bool isconcreate;
    //Constructor
    public myBeam(){}
    //Properties
    public double Length{ get{} set{} }
    }
    Any suggestion would be greatly appreciated.
    Regards,
    bsyap

  6. Dear bsyap,
    I never said that you cannot create a new Revit file, just that you cannot create an instance of the main Revit Application.
    Creating new doucments is enabled by the following Applicaton member methods:
    – NewFamilyDocument
    – NewProjectDocument
    – NewProjectTemplateDocument
    You can also create new Revit building elements in the file, and store your application data in new and existing elements, either using existing element properties or your own custom shared parameters.
    It seems to me that you are rushing ahead of things. How about simply downloading and studying the Revit SDK and the introduction to the Revit API presented there.
    You can also read the Getting started category of this blog.
    Cheers, Jeremy.

  7. Daniel LAMBLIN Avatar
    Daniel LAMBLIN

    Hello Jeremy,
    I simply want to make a saveas of rvt file when user create a new file. for instance I click on a button to lauch this method :
    UIApplication app = commandData.Application;
    Document doc = app.ActiveUIDocument.Document;
    SaveAsOptions options = new SaveAsOptions();
    options.OverwriteExistingFile = true;
    string fich = “D:/DATA/d.lamblin/Documents/docsaveas.rvt”;
    try
    {
    doc.SaveAs(fich);
    }
    catch (Exception e)
    {
    string msg = e.Message;
    System.Diagnostics.Debug.WriteLine(“Write to ” + fich + ” Failed ” + msg);
    System.Diagnostics.Debug.WriteLine(e.Message);
    }
    But SaveAs doesn’t work : ‘Internal error’ each time.
    Is it a problem of context ?
    (In which case I can use saveas ?)
    Regards,
    Daniel

  8. Dear Daniel,
    You ask “Is it a problem of context?”
    That makes me think…
    Have you implemented an external command?
    If not, you need to work through the Revit API getting started material, especially the DevTV and My First Revit Plugin tutorials:
    http://thebuildingcoder.typepad.com/blog/about-the-author.html#2
    Here are some additional pointer for getting started:
    http://thebuildingcoder.typepad.com/blog/2015/01/cloud-accelerator-and-more-revit-stuff.html#3
    Once you have worked through the tutorials, you know what you need about external commands and valid Revit API context.
    Have you installed the Revit SDK, and do you have the Revit API help file RevitAPI.chm at hand?
    That is obviously the first place to look.
    By the way, although you instantiate a SaveAsOptions instance and set its OverwriteExistingFile, you never make use of it.
    Did you intend to overwrite an existing file?
    If so, pass in the options to the SaveAs method.
    Cheers, Jeremy.

  9. Daniel LAMBLIN Avatar
    Daniel LAMBLIN

    Hello Jeremy,
    I have allready maked several applications from REVIT, so I have REVIT SDK with all his samples.
    I don’t want to overwrite an existing file. I implemented an external command :
    [Transaction(TransactionMode.ReadOnly)]
    [Regeneration(RegenerationOption.Manual)]
    public class CmdDocSaveas : IExternalCommand
    {
    public Result Execute(ExternalCommandData commandData,
    ref String message, ElementSet elements)
    {
    if (null == commandData.Application.ActiveUIDocument.Document)
    {
    message = “Active view is null.”;
    return Autodesk.Revit.UI.Result.Failed;
    }
    Document doc = commandData.Application.ActiveUIDocument.Document;
    string fich = “C:/docsaveas.rvt”;
    try
    {
    doc.SaveAs(fich);
    }
    catch (Exception e)
    {
    string msg = e.Message;
    System.Diagnostics.Debug.WriteLine(“Write to ” + fich + ” Failed ” + msg);
    System.Diagnostics.Debug.WriteLine(e.Message);
    }
    System.Windows.MessageBox.Show(doc.PathName, ” SaveAS”);
    return Result.Succeeded;
    }
    }
    Of course my target is to help user to give a right name to his files and help him to range it.
    The first step is to be able to do a saveas.
    When I click to the good button on my ribon panel, the command start but fail in the saveas method:
    “An internal error has occured”
    any idea ?
    regards,
    Daniel

  10. Dear Daniel,
    Nope, sorry, no idea.
    I created a new add-in using your code to implement the external command Execute method like this:
    Document doc = commandData.Application.ActiveUIDocument.Document;
    if( null == doc )
    {
    message = “Active view is null.”;
    return Result.Failed;
    }
    string fich = “C:/docsaveas.rvt”;
    try
    {
    doc.SaveAs( fich );
    }
    catch( Exception e )
    {
    string msg = e.Message;
    System.Diagnostics.Debug.WriteLine( “Write to ” + fich + ” Failed ” + msg );
    System.Diagnostics.Debug.WriteLine( e.Message );
    }
    Debug.Print( doc.PathName + ” saved by SaveAs” );
    return Result.Succeeded;
    It performs flawlessly for me and creates:
    01/13/2015 01:02 PM 3,620,864 docsaveas.rvt
    So, sorry to say, there is something else wrong in your system.
    SaveAs is used in many locations and situations in all kinds of Revit add-ins, including several discussed here on the blog.
    Here are some of the more recent examples:
    Family related:
    http://thebuildingcoder.typepad.com/blog/2014/09/modifying-saving-and-reloading-families.html
    http://thebuildingcoder.typepad.com/blog/2014/10/creating-a-sloped-wall.html#4
    Server related:
    http://thebuildingcoder.typepad.com/blog/2013/12/saving-a-new-central-file-to-revit-server.html#3
    A bit older:
    http://thebuildingcoder.typepad.com/blog/2011/05/cascaded-events-and-renaming-the-active-document.html
    Unfortunately, people in general have infinite creativity in finding ways to make life difficult for themselves.
    I do what I can to try to prevent it, but to little avail :-)
    I wonder what is causing this issue for you.
    Best of luck resolving it!
    Cheers, Jeremy.

  11. Daniel LAMBLIN Avatar
    Daniel LAMBLIN

    Hello Jeremy,
    I understand your answer. I am sure now that the code is right (is it important to known), so I can look after other reasons, probably outside REVIT.
    Thanks for your test with my code.
    Regards
    Daniel

  12. Dear Daniel,
    My pleasure, thank you for your appreciation, and sorry I could not say more.
    Have you ensured that you can successfully save the Revit project file manually in the user interface?
    Good luck resolving it!
    Cheers, Jeremy.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading