Jeremy Tammik

July 2009

Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

« Getting Started with the Revit API | Main | Managing SDK Samples »

August 28, 2008

The Revit SDK Contents

The Revit SDK or Software Developer Kit is included in every Revit product installation CD. You can search the installation for a file named *sdk*.zip. In Revit 2009, it is named 'Revit 2009 SDK.zip' and located in a subdirectory 'Utilities\Common\Software Development Kit'. It can also be downloaded from the public Revit developer center which can be reached via www.autodesk.com > Communities > Developers > Products & Technologies > Revit Architecture and Revit Structure, or from the members-only ADN web site .

The contents of the Revit SDK are basically for documentation purposes only. All that is really needed to allow a Revit plug-in to run is the Revit API .NET assembly RevitAPI.dll, which is always present in every Revit installation and located in the Program subfolder, the same place as Revit.exe itself. Additionally, you need a development environment to compile your plug-in. The standard development environment we normally use is Microsoft Visual Studio. You can also use the free Visual Studio express version with reduced functionality, or any other .NET development environment. Alternatively, in Revit 2009, you can use the Visual Studio Tools for Application or VSTA environment which is included with the Revit product instead of compiling an external .NET plug-in assembly.

Let us look at the contents of the Revit SDK in more detail. Here are the documents present in the top level directory

  • Read Me First.doc
  • Getting Started Revit API 2009.doc
  • Add-On Applications and Non-Power Users.doc
  • Revit API Diagram.dwf
  • Revit SDK License.rtf
  • Revit VSTA User Manual.pdf
  • RevitAPI.chm

'Read Me First.doc' provides a brief overview over the SDK contents and is the first place to start exploring. The next step is 'Getting Started Revit API 2009.doc', which explains the basic paradigms and architecture, how to create a Revit plug-in, and many further details. A graphical overview of the API class hierarchy is provided by 'Revit API Diagram.dwf'. The license is provided in a separate file, and a detailed user manual for VSTA, the Visual Studio Tools for Applications, which can be used to create macros inside of Revit instead of loading them as external plug-ins separately compiled in an external development environment.

The main help file is RevitAPI.chm, which lists all the classes provided in the API and their properties and methods. It does not do much to explain how these classes work together to solve specific programming tasks. For that, the best source of information is the collection of samples, which we will discuss in detail later.

There are two more documents to mention in this context, even though they are not present in the standard SDK release:

  • Guide to placing Family Instances with the API.doc
  • Revit_2008_api_user_manual.pdf

The guide to placing family instances is a recent addition to the Revit SDK update. Unfortunately, it did not make it into the Revit 2009 web update 1 in June 2008, so it will be added to the next version of the SDK. Currently, it is available from the ADN web site in the Revit knowledgebase or in the updated version of the Revit SDK web update 1 which was posted to ADN after the public release of the Revit product web update 1. For non-ADN members, I have also added a copy of it right here for 2009 and here for 2008.

The Revit API user manual is a work in progress and is also planned to be included in the standard SDK at some future point in time. Currently, the draft version is available from the ADN web site Revit 2008 Samples and Documents page. Again, here is a copy of it for non-ADN members.

In addition to the documents listed above, the SDK root folder also includes the following subdirectories:

  • API Changes
  • Add-in Manager
  • Revit Structure
  • VSTA Samples
  • Samples

API Changes lists the changes between the current and the previous version of the API and is useful for migrating existing applications. The changes are documented in an xml file Added.xml and displayed through an XSLT generated view. XSLT stands for XSL Transformation or eXtensible Stylesheet Language Transformation. An XSL style sheet transforms the XML data into a specific view in the browser.

The Add-in Manager is a utility application for loading and managing plug-ins and is accompanied by its own documentation.

A set of additional documentation is provided specifically for Revit Structure in an own folder. Some VSTA samples are provided.

Finally, we have the largest component of the SDK by far, the SDK samples. The SDK samples provide over a hundred real live examples of how the API classes work together to solve specific programming tasks, ranging from the very simple to pretty complex.

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00e553e16897883300e554778be18834

Listed below are links to weblogs that reference The Revit SDK Contents:

Comments

Jeremy Tammik,

I am new for Autodesk Revit, But i have 4 yrs of exp in Autocad Vlisp, VBA, C#.Net, ObjectArx. Now i want to create new family in revit using .Net API, i don't know it can be done or not?

i searched in the Revit SDK samples, But i did't found the samples program. Please help me "How to create new family in Revit using .Net API".

Thanks in advance.
Senthil Prabu B R

Hi Senthil,

Thank you for your suggestion. Unfortunately, I am sorry to say that the Revit API currently does not provide any functionality for creating families.

Best regards,

Jeremy

Is there any other alternate way to create Revit family at runtime and utilize that in the active project? Please give me some idea.

Thanks,
Senthil Prabu B R

Hi Senthil,

Revit currently provides no API at all within the family editor. This feature is very high on the developer wish list. You can generate a new family document using app.NewFamilyDocument(), and you can populate it from a command running within another document using code like the following:

public void createProfileFamilyDoc()
{
Application app = mRevit;
Autodesk.Revit.Creation.Application creApp = app.Create;

// draw some lines forming a unit square in the XY plane:

CurveArray curves = new CurveArray();

XYZ startPt = new XYZ();
XYZ endPt = new XYZ();

startPt.X = 0.0;
startPt.Y = 0.0;
startPt.Z = 0.0;
endPt.X = 10.0;
endPt.Y = 0.0;
endPt.Z = 0.0;
curves.Append( creApp.NewLineBound( startPt, endPt ) );

startPt.X = 10.0;
endPt.Y = 10.0;
curves.Append( creApp.NewLineBound( startPt, endPt ) );

startPt.Y = 10.0;
endPt.X = 0.0;
curves.Append( creApp.NewLineBound( startPt, endPt ) );

startPt.X = 0.0;
endPt.Y = 0.0;
curves.Append( creApp.NewLineBound( startPt, endPt ) );

Plane basePlane = creApp.NewPlane( XYZ.BasisZ, XYZ.Zero );

mFamilyDoc.BeginTransaction();
Autodesk.Revit.Creation.Document creDoc = mFamilyDoc.Create;
SketchPlane plane = creDoc.NewSketchPlane( basePlane );
ModelCurveArray mc = creDoc.NewModelCurveArray( curves, plane );
mFamilyDoc.EndTransaction();
mFamilyDoc.SaveAs( mFamilyFileName );
mFamilyDoc.Close();
}

However, you will probably run into some severe limitations very quickly. For a deeper discussion, I would suggest trying the Revit API discussion group at http://discussion.autodesk.com.

Best regards,

Jeremy

Hi Jeremy,

Thanks for the instant replay, I am able to draw model lines in the family editor using API. But now i want to draw Solid Extrusion in family editor. Please help me.

Thanks & Regards,
Senthil Prabu B R

Hi Senthil,

Glad you liked it! Unfortunately, as said, there is basically no support for drawing anything at all through the API in the family editor. Regarding extrusions, the situation is even more limited ... the Extrusion class is read-only, so to speak. It is derived from GenericForm, which can be *queried* for a generic form for use in family modelling and massing. The Revit API currently provides no methods at all for creating these kinds of shapes. So I am completely unable to help you any further in this. Sorry about that. Good luck finding an alternative solution!

Best regards,

Jeremy

Hi Jeremy Tammik

Hi i am new in revit sdk. Now i want to different between lenght and cutlenght. and also need a actual lenght of the family object, i don't know it can be done or not?


i searched in the Revit SDK samples, But i did't found the samples program. Please help me "How to find the family object lenght. e.g., family library include the more than two material. In material takeoff display the common parameter list. I need actual start and end point of each material. Please help me".


Thanks in Advance.

Dharanidharan R

Hi Dharanidharan,

I'm aftraid I do not know of any solution offhand. All I can think of is to explore the geometrical representation in detail. Maybe different materials are represented on separate faces, and you can query and analyse the dimensions of each face.

Good luck and best regards, Jeremy.

Hi Jeremy Tammik


Thanks for your replay. One additional question. How to retrirve the current display unit (Like Feet and Fractionaly inch its display 1'-5 1/2") how to display this. and how to change the current display unit in api.

I have the project unit sample. But it can raise some error. "RiseRunOrAngleType does not exist in the Enum Namespace". I am straggle this point. please guide me.


Regards

Dharanidharan R

Dear Dharanidharan,

Sorry, I cannot answer your query offhand. Right now I am travelling and have no possiblity to explore it in depth.

Best regards, Jeremy.

Hi Jeremy Tammik

I Hope you can return your trip. How to duplicate the family type name in revit sdk.


Regards

Dharanidharan R

Dear Dharanidharan,

Thank you, I returned, and now I am on the road once again ... I am not completely clear on the meaning of your question ... if you are asking how to duplicate a family symbol, then the question is answered by

http://thebuildingcoder.typepad.com/blog/2008/11/creating-a-new-family-symbol.html.

Best regards, Jeremy.

Hi Jeremy Tammik

Thanks for your replay. Its my previous query. I Can retrieve the current display unit. but i dont know how to change unit (i.e., Project Units -> Format -> Units -> Decimal feet to some other). set command posible to change the units? help me.


Regards

Dharanidharan R

Dear Dharanidharan,

Please refer to the ProjectUnit SDK sample mentioned in

http://thebuildingcoder.typepad.com/blog/2008/09/units.html

It lists and sets units and format options. In more detail, it implements an external command which lists all the units in the current project and displays their format information; displays the decimal symbol type of the current project units, which can be set to comma or dot; and displays the slope type of current project units, which can be either rise or angle.

Cheers, Jeremy.

Hi Jeremy,
I'm just starting with the revit api/ide, so maybe a trivial question, how would you write a 'purge unused materials' program. My project files often get overloaded with all sorts of unwanted materials from loaded families or pasted elements so that it becomes a hassle to find and select those materials needed.If its easy for you could you provide the code for this?
Thanks, Michael

Hi Michael,

Sounds like a sweet little project. I'll make a note of it. If anyone has a contribution to make, feel free to do so and I will be happy to publish it. It will probably be a while before I get around to it ... unless I use it right here and now as an example in the current training ... I wonder whether there is one single parameter that is used to store the current material of an element? If so, it would be a simple matter of implementing a filter that selects all elements with an entry for that parameter and identifying all unique values. All other material definitions can be eliminated. Maybe.

It would help if you could provide a good sample project as a starting point and list what materials are used in it and which should be eliminated.

Cheers, Jeremy.

Hi Jeremy,
I would like to create a solution which searches the current .rvt for any/all in-place families and produce an html report of these items. Is there a way to use the filtering capabilities for this?
The reason for this is because it's our experience that in-place families seriously degrade performance. We'd like to identify in-place instances and see if they can be recreated as external families.
Thank you.

Hi Michael,

Sounds like another great idea for a sweet and doable little project. I'll make a note of this as well. If anyone has a contribution to make, please feel free to do so and I will be happy to publish it. It will probably be a while before I get around to it. It would help if you could provide a sample project as a starting point with a couple of in-place families and a specification of what the list that you expect as a result should look like. Actually, even better than a sample project would be a journal file that creates such a project from scratch.

Cheers, Jeremy.

Hello,
I have both a sample file and the journal file. What's the best way to send it to you?

Hi Jeremy Tammik,

Now i am create sheets for all drafting view at runtime. i can do it. but it has raised one problem. for. e.g. Drafting view (E20) it create the only one sheet at a time then i can create the another sheet with same Drafting view (E20) it show the error ("The View E20 is not appropriate, or it was placed in another sheet"). Then i can change the Drafting view
i.e. E20->right click-> Duplicate view-> duplicate with detailing.
change E20 -> E20-A. Then i can create the sheet it will be create. Right now i will create Drafting view (Duplicate with detailing ) at run time. How do i will make change this. pls guide me.
I can create 50 sheet at runtime with same Drafting View (E20) and different operation and cut length.

Regards,
Dharanidharan R

Hi Michael,

I got the following feedback about determining if a family is in-place or not:

You can use the fact that the doc.EditFamily throws exception for in-place families. For other elements either EditFamily will return a valid document or fi will be null.

System..::.ArgumentException is thrown when the input argument-"loadedFamily"-is an in-place family.

foreach (Autodesk.Revit.Element e in collection)
{
FamilyInstance fi = e as FamilyInstance;
if (fi != null)
{
try
{
Document famDoc = doc.EditFamily(fi.Symbol.Family);
}
catch
{
MessageBox.Show("In Place Family");
}
}
}

Cheers,
Adam

Dear Dharanidharan,

I am glad the creation of sheets for drafting views works for you. I understand that you have a problem when you try to create multiple sheets displaying the same view. You can work around this problem by duplicating the view manually using the context menu. You are now asking how to duplicate the view through the API to avoid the manual step. Is that correct?

I do not know offhand whether it is possible to duplicate a view through the API. How have these views been generated? If they were generated through the API as well, it might be simpler to generate all the required copies of them right from the beginning to avoid the need to duplicate them later.

Cheers, Jeremy.

Hi Jeremy Tammik,

Do you have any idea about duplicate a view through API. If its possible pls guide me.

Regards,
Dharanidharan R

Dear Dharanidharan,

I assume you are aware of the various methods available to create new views on the Autodesk.Revit.Creation.Document class, e.g.

ViewDrafting NewViewDrafting()
ViewSheet NewViewSheet( FamilySymbol titleBlock )
View3D NewView3D( XYZ viewDirection )
ViewPlan NewViewPlan( string viewName, Level, ViewType )
ViewSection NewViewSection( BoundingBoxXYZ )

There are also some samples in the Revit SDK demonstrating how to make use of some of these methods, e.g. AllViews, CreateViewSection, and FrameBuilder.

However, none of these exactly address your need of exactly duplicating an existing view. I asked the development team for advice on this issue, and their reply is that unfortunately there is currently no way to duplicate a view through the API, and there is no known work-around to do it either (duplicate/duplicate with detail/duplicate as dependent). Sorry for the bad news.

Cheers, Jeremy.

Hi Jeremy Tammik

Thanks for your suggestion, now i'd hold that process. I need another help to you. How to bring the View (3D viwe or detail view) in Picture box (Front End Form). You have any idea about that. please guide me.

Thanks in Advance

Dharanidharan R

Dear Dharanidharan,

Do you mean how to redraw some of the Revit model geometry in your own dialogue's picture box? There is no direct support for that in the Revit API, but some of the Revit SDK samples demonstrate rudimentary approaches. Some of them are mentioned in the discussions on geometry viewers and workarounds for picking a point:

http://thebuildingcoder.typepad.com/blog/2008/09/geometry-viewer.html

http://thebuildingcoder.typepad.com/blog/2008/10/picking-a-point.html

Cheers, Jeremy.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

RSS Feed

Search

Search