Support Forum

[Question] IFC import/export doesn't work ? [Solved]


Update I could make the IFC export work but still no sucess with import,

Hi,
I'm trying to write a python script to automate IFC import and export tasks, but I can't quite make it work.

I checked the ExportImportInteractor example where there supposed to be example for these kind of processes, and the DWG import and export works perfectly, but there is no example for ifc import, and the IFC export doesn't generate any output, nor any error message.

This is the code that I'm trying to run for export:

def ExportIFC(exportPath):
    drawingFileService = AllplanBaseElements.DrawingFileService()
    activeFileIndex = AllplanBaseElements.DrawingFileService.GetActiveFileNumber()
    doc =  AllplanIFW.InputViewDocumentData().GetInputViewDocument()
    ifcVersion = AllplanBaseElements.Ifc_4
    drawingFileService.ExportIFC(doc, [activeFileIndex], ifcVersion, exportPath)

and this is the import
def ImportIFC (importPath ):
    drawingFileService = AllplanBaseElements.DrawingFileService()
    doc = AllplanIFW.InputViewDocumentData().GetInputViewDocument()
    activeFileIndex = AllplanBaseElements.DrawingFileService.GetActiveFileNumber()
    drawingFileService.UnloadAll(doc)
    drawingFileService.LoadFile(doc, activeFileIndex, AllplanBaseElements.DrawingFileLoadState.ActiveForeground)
    ifcVersion = AllplanBaseElements.Ifc_4
    drawingFileService.ImportIFC(doc,ifcVersion, importPath)

Did I miss a step somewhere in the code?
Is there any prerequisites for the ExportImportInteractor to work with IFC ?

Show solution Hide solution

Hello!
I don't see any issues in your code for exporting the file. In fact I've used your code and it worked just fine on my computer.

For the import however the argument for ifcVersion should be given as an integer. See the documentation

ImportIFC( (DrawingFileService)doc, (DocumentAdapter)fileIndex, (int)ifcVersion, (wstring)fileName) -> BaseElementAdapterList

On the other hand the documentation is very confusing here. The second argument fileIndex is actually where the document adapter should be given. And I also don't understand, why the IfcVersion has to be given as integer, as in the IFCExport it is given as an instance of a IfcVersion class. And what is the sense of giving an IfcVersion to an import function in the first place. Seems we need to work on that. But for the moment please find the examples for IFC import and export attached.

Attachments (2)

Type: text/xml
Downloaded 395 times
Size: 2,50 KiB
Type: text/plain
Downloaded 437 times
Size: 6,43 KiB

Hello!
I don't see any issues in your code for exporting the file. In fact I've used your code and it worked just fine on my computer.

For the import however the argument for ifcVersion should be given as an integer. See the documentation

ImportIFC( (DrawingFileService)doc, (DocumentAdapter)fileIndex, (int)ifcVersion, (wstring)fileName) -> BaseElementAdapterList

On the other hand the documentation is very confusing here. The second argument fileIndex is actually where the document adapter should be given. And I also don't understand, why the IfcVersion has to be given as integer, as in the IFCExport it is given as an instance of a IfcVersion class. And what is the sense of giving an IfcVersion to an import function in the first place. Seems we need to work on that. But for the moment please find the examples for IFC import and export attached.

Attachments (2)

Type: text/xml
Downloaded 395 times
Size: 2,50 KiB
Type: text/plain
Downloaded 437 times
Size: 6,43 KiB

Quote by bmarciniec
Hello!

I don't see any issues in your code for exporting the file. In fact I've used your code and it worked just fine on my computer.
For the import however the argument for ifcVersion should be given as an integer. See the documentation
ImportIFC( (DrawingFileService)doc, (DocumentAdapter)fileIndex, (int)ifcVersion, (wstring)fileName) -> BaseElementAdapterListOn the other hand the documentation is very confusing here. The second argument fileIndex is actually where the document adapter should be given. And I also don't understand, why the IfcVersion has to be given as integer, as in the IFCExport it is given as an instance of a IfcVersion class. And what is the sense of giving an IfcVersion to an import function in the first place. Seems we need to work on that. But for the moment please find the examples for IFC import and export attached.

Thank you for your answer, this is just what I was looking for


https://connect.allplan.com/ uses cookies  -  More information

Accept