Open IFC through API

Open IFC through API

Anonymous
Not applicable
3,245 Views
11 Replies
Message 1 of 12

Open IFC through API

Anonymous
Not applicable

When I click "open IFC" and choose a file, the model from the loaded file appears in the project view. Is there a way to this through the API? If it's not possible, maybe I could at least somehow create a family from the IFC file and add it to the project?

0 Likes
3,246 Views
11 Replies
Replies (11)
Message 2 of 12

jeremytammik
Autodesk
Autodesk

Please read the Revit API help file first of all before asking any questions whatsoever.

 

It provides the following answer right away:

 

  Application.OpenIFCDocument Method (String)

Another way to open an IFC file programmatically is to simply launch Revit.exe and specify the filename in the command line:

 

http://thebuildingcoder.typepad.com/blog/2010/07/ifc-import-and-conversion-journal-script.html

 

Cheers,

 

Jeremy



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

0 Likes
Message 3 of 12

Anonymous
Not applicable

Thank You for the answer. Well, I had tried the OpenIFCDocument method, but it didn't add a new family to the project. Once I use OpenIFCDocument, what should I do to see the family from the IFC file in the project browser.

0 Likes
Message 4 of 12

jeremytammik
Autodesk
Autodesk

"Family" is a pure Revit concept.

 

IFC knows nothing about families and never will.

 

An IFC file can define a project, not a family.

 

Therefore, if you open an IFC file, it will appear in the project view and never as a family.



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

0 Likes
Message 5 of 12

Anonymous
Not applicable

I'm sorry. I guess I wasn't very precise in describing my problem. I wanted to open IFC file in Revit and be able to add and modify parameters of the model from the IFC file. That is why I wanted to have it as a family in a project. I tried using OpenIFCDocument, but it doesn't open a new project in Revit. OpenAndActivateDocument doesn't work for IFC. In fact I'm new to Revit and I don't even know if what I'm trying to achieve is possible 😞 

0 Likes
Message 6 of 12

jeremytammik
Autodesk
Autodesk

You should definitely understand your needs from an end user point of view before even starting to think about the programmatic solution.

 

The Revit API almost only supports functionality that is available through the UI.

 

You should therefore research the optimal workflow and best practices to address your task at hand manually through the user interface first of all.

 

To do so, please discuss and analyse it with an application engineer, product usage expert, or product support.

 

Once you have got that part sorted out, it is time to step into the programming environment.

 

I hope this helps.

 

Cheers,

 

Jeremy



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

Message 7 of 12

GeomGym
Advocate
Advocate

Hi Jeremy, hope you're well.  For once, you post a reply that I totally disagree with.  

Here's a reply that disagrees with your statements in turn.

 

"Family is a pure Revit concept" 

"IFC knows nothing about families and never will." ???

IFC has classes derived from an IfcTypeProduct which are to all practical purposes the same as an Revit Family, and this concept is understand in various BIM software.  You can read the description here.  http://www.buildingsmart-tech.org/ifc/IFC4/final/html/link/ifctypeproduct.htm  Note this was introduced in IFC2x which as I understand it was released circa 2000, a similar time to early development of Revit?  If a family is a revit concept, I'm not sure how Bentley recognizes anything in a .rfa file http://communities.bentley.com/products/building/building_analysis___design/f/5917/t/87255   I am pretty sure that manufacturers have expressed object libraries in various forms including CAD prior to this.

 

Types as a concept in Revit (variations of a master parameric definition) is not typically implemented in IFC developments but hopefully this changes soon.  IFC4 offers this and I am working on some object library projects that wish to utilize this.

 

"An IFC file can define a project, not a family."

This is again incorrect.  IFC4 added a new context, the IfcProjectLibrary http://www.buildingsmart-tech.org/ifc/IFC4/final/html/link/ifcprojectlibrary.htm

This is appropriate for exchanging data in the form of object libraries and the like as per it's definition.  It would not contain project and instance elements.  I don't believe Revit supports this context in it's native importer or exporter.

 

"Therefore, if you open an IFC file, it will appear in the project view and never as a family."

This might be true at this point in time, but I would hope it might change at some point in time if Autodesk wants to support openBIM workflows.

 

To reply to the original question, Geometry Gym offers a 3rd party importer that does generate families and create parameters based on types in IfcProject and IfcProjectLibrary.  http://geometrygym.blogspot.com.au/search/label/Revit  This is primarily from the user interface, however if you require from the API then I can refactor the method slightly and provide it as a public method in the dll.  An alternative would be to edit the open source importer and make it recognize these ifc concepts.

 

I look forward to discussing further,

 

Jon

Message 8 of 12

jeremytammik
Autodesk
Autodesk

Dear Jon,

 

Thank you very much for picking this up and pointing out my errors.

 

Yes, I am well, leaving for vacation tomorrow, rather a lot of last minute stuff, can use a break  🙂

 

I totally agree with your disagreement.

 

I was not aware of this powerful aspect of the IFC structure.

 

You explanation comes in very handy!

 

I was thinking of writing a bit about IFC anyway, and also mention your IFC C# class library, so I can add this aspect there as well.

 

Thanks again!

 

Cheers,

 

Jeremy



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

0 Likes
Message 9 of 12

Anonymous
Not applicable
Thank You for the reply. I'll certainly check out theese links.
0 Likes
Message 10 of 12

jeremytammik
Autodesk
Autodesk

Hi guys,

 

I published a summary of parts of our conversation on The Building Coder:

 

http://thebuildingcoder.typepad.com/blog/2016/07/ifc-import-and-open-source.html#4

 

Cheers,

 

Jeremy



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

0 Likes
Message 11 of 12

Anonymous
Not applicable

Dear Both, 

I have similar question, Hope can get your experience. 

- I can open the IFC file by Revit UI. 

- I'm trying to open IFC file by Revit API. 

==> currently, i use  "Document ifcdoc = app.OpenIFCDocument(path);" to open IFC file. 

But i can't see it load or active in Revit Window. 

Could you please help share the extra step to show my document into Revit Window.

 

 

 

 

 

 

0 Likes
Message 12 of 12

jeremytammik
Autodesk
Autodesk

Does that call return a valid `ifcdoc` variable representing the loaded document?

 

Does the loaded IFC document show up in RevitLookup, e.g., in the Application Documents collection?

 

https://www.revitapidocs.com/2020/8a32ffe0-7e80-e85c-78aa-1af48ace4d74.htm

 

If so, and it is not visible on screen, you may need to open and activate it as described above.

 

Have you set the IFCImportOptions.Action to open or link the file?

 

https://thebuildingcoder.typepad.com/blog/2014/04/whats-new-in-the-revit-2015-api.html#3.08

 



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

0 Likes