Autodesk / revit-ifc

IFC for Revit and Navisworks (2019+)
450 stars 194 forks source link

ENH: Add basic build informations #769

Open prenex opened 2 months ago

prenex commented 2 months ago

Enhancement Description

Hello revit IFC team!

I am really happy I have found this, because I want to debug the importer not importing some of the files properly (actually window and door families, when I see they are "nearly like" how when I export from REVIT so I thought I can make revit open them properly maybe).

But I see nowhere any information about how to build this properly, what VS version is the native version (I use 2019) and what things are needed.

Currently I do this:

I guess I need some kind of Revit plugin SDK or something? What exactly?

I also think I should be able to make a debug build and just attach the debugger to the process of REVIT, then put breakpoint here:

https://github.com/Autodesk/revit-ifc/blob/b83595ff01f72f2a63242e00daf01508f2264287/Source/Revit.IFC.Import/Importer.cs#L693

^^This is where I see the import process starts. I do not really see the place where the IFCWindowType and such are processed, but found places for the lining and panel props for example so its not clear where it is but I would just add random breakpoints first and step through the import process of wrongly imported files. If I see them being not bugs I will also try go annoy random people who write the exporter from the other software and let them fix it instead, just want to analyse things.

I have one more question: Is there native code parts for the IFC import process somewhere that I should also take a look at? At first sight I feel like this is not all what is happening, but that some of the process happens here and some in random native code (but I might be wrong).

I think these are very simple questions and the project README.md should contain answers to these or where to look up these. Maybe there is some docs I didn't find - but then they should be more highlighted that the information for bulding this is there. I see all kinds of people building this all the time so I guess its possible.

I do not know why the wix project does not get picked up after I installed the plugin for it, but here I learned that it should be possible to debug the plugin without that installer project:

https://github.com/Autodesk/revit-ifc/issues/22

I tried my best to collect things I've found out on my own about the build process so even if you decide not to change anything, at least people can stumble upon the findings so far.

Best regards, Richard Thier Owner, CEO - MagosIT Ltd.

Revit Version

2024.0.x

IFC for Revit Addon Version

24.x.x

Windows Version

10 22H2

prenex commented 2 months ago

deps Related screenshot (both for the WiX issue and the build issues)

prenex commented 1 month ago

Okay, to make these errors go away, one needs to add "References" to these projects to the following DLL files (see image). All of them are near REVIT.exe file. image

You need to do this for all of the projects separately by hand - but not all of them need all of these files. The first one with UI needs them all, but other projects can go with fewer.

Also you should set them not to copy into your project, but be referenced from the REVIT installation.

For the WIX issue, my problem was that I installed latest VS2019, .NET 4.8 WIX and that project is in Wix3 not Wix4. You can convert it and for me the conversion succeeded according to their logs: image image

I should also note that required .NET version seems to be .NET 4.8 - I had to install that dotnet variant SDK on my computer for REVIT 2024 ifc plugin version - but I found this via trial&error and digging around the project files

Also this other issue have helped me find the DLL files:

https://github.com/Autodesk/revit-ifc/issues/163

After this I still see ANTLR being missing - so I probably have to install that via nuget or something. ANTLR I guess is LR-parser library so I guess is used for parsing IFC files and such. Hope this information helps random people like me who want to build this and I will progress from here on further and note things if I find any relevant information.

prenex commented 1 month ago

Having ANTLR seems to be enough to build most of the projects now, but I get this build result:

Build started...
1>------ Build started: Project: Revit.IFC.Import.Core, Configuration: Debug x64 ------
2>------ Build started: Project: Revit.IFC.Export, Configuration: Debug x64 ------
2>  Revit.IFC.Export -> E:\revit_ifc\revit-ifc\Source\Revit.IFC.Export\bin\Debugx64\Revit.IFC.Export.dll
2>  E:\revit_ifc\revit-ifc\Source\Revit.IFC.Export\bin\Debugx64\Revit.IFC.Export.dll -> C:\ProgramData\Autodesk\ApplicationPlugins\IFC 2024.bundle\Contents\2024\Revit.IFC.Export.dll
2>  1 File(s) copied
1>  Revit.IFC.Import.Core -> E:\revit_ifc\revit-ifc\Source\Revit.IFC.Import.Core\bin\Debugx64\Revit.IFC.Import.Core.dll
2>  E:\revit_ifc\revit-ifc\Source\Revit.IFC.Export\bin\Debugx64\GeometryGymIFC.dll -> C:\ProgramData\Autodesk\ApplicationPlugins\IFC 2024.bundle\Contents\2024\GeometryGymIFC.dll
2>  1 File(s) copied
3>------ Build started: Project: IFCExporterUIOverride, Configuration: Debug x64 ------
1>  E:\revit_ifc\revit-ifc\Source\Revit.IFC.Import.Core\bin\Debugx64\Revit.IFC.Import.Core.dll -> C:\ProgramData\Autodesk\ApplicationPlugins\IFC 2024.bundle\Contents\2024\Revit.IFC.Import.Core.dll
1>  1 File(s) copied
4>------ Build started: Project: Revit.IFC.Import, Configuration: Debug x64 ------
4>E:\revit_ifc\revit-ifc\Source\Revit.IFC.Import\Utility\ParametersToSet.cs(68,20,68,31): error CS0117: 'Parameter' does not contain a definition for 'SetMultiple'
4>E:\revit_ifc\revit-ifc\Source\Revit.IFC.Import\Utility\IFCImportHybridInfo.cs(341,42,341,56): error CS1061: 'IFCHybridImport' does not contain a definition for 'UpdateElements' and no accessible extension method 'UpdateElements' accepting a first argument of type 'IFCHybridImport' could be found (are you missing a using directive or an assembly reference?)
4>E:\revit_ifc\revit-ifc\Source\Revit.IFC.Import\Utility\IFCImportHybridInfo.cs(603,27,603,52): error CS0117: 'ImporterIFCUtils' does not contain a definition for 'UpdateDirectShapeCategory'
4>E:\revit_ifc\revit-ifc\Source\Revit.IFC.Import\Data\IFCProduct.cs(406,22,406,37): error CS0165: Use of unassigned local variable 'hybridElementId'
3>  IFCExporterUIOverride -> E:\revit_ifc\revit-ifc\Source\IFCExporterUIOverride\bin\Debugx64\IFCExporterUIOverride.dll
3>  A rendszer nem találja a megadott elérési utat.
5>------ Skipped Build: Project: RevitIFCSetupWix, Configuration: Debug x86 ------
5>Project not selected to build for this solution configuration 
========== Build: 3 succeeded, 1 failed, 2 up-to-date, 1 skipped ==========

As you can see, actually the IFC import is the project that does not get built...

Also worth noting, that currently building these copies the built DLLs to some folder in C:\ProgramData.... I have installed REVIT to E:\ to preserve space (okay: put it bluntly I had not enough space on C for this huge product) so I am not sure if this is right or not, but I guess it is right, because I see in the same folder a 3dsmax plugin too which max picks up so I guess its common folder for plugins and I guess they get picked up instead of the built-in one when present.

It would have been maybe a good idea if you would only "copy" these around, it the whole build is successful though - because the way it is done I ended up only getting half of the (successfully build, not the erroneous) DLLs moved to the right location.

Is this some kind of version conflic? I try this with REVIT 2024 and I guess there is already revit 2025 so maybe the github code refers to things not existing in my installation? What version to use with what revit?

Screenshot about DLL being done for the export at least (import DLL does not get created and I am actually interested in that one): image

prenex commented 1 month ago

According to the WIX installer project I seem to be building code for the proper version for Revit2024: image

So I guess it should not be inconsistent versioning - or then version numbers also lie...

prenex commented 1 month ago

Actually it DOES look like version inconsistency when I look at the soruce code: image

The try-catched function tries to to the Parameter.SetMultiple(...) thing, which they even commented only gets available in REVIT 2024.1 - I guess my REVIT did not auto-update to that one? Or maybe mine is even further ahead if not behind?

In any ways: the code tried to be backwards compatible by catching this exception - but it is not really enough when I use the given DLL files for BUILD of this because VS and the compiler also will not see the method.

I guess I will look into what exact REVIT version I have and update it (hopefully I am just behind with it?)

If I am not behind, I can just exchange the source code temporarily to always throw the exception manually or just remove the newer code path and use the legacy that should run instead - then do similar edits for the rest of the files.

I keep this also here as possible information of any such thing in the future, but TL;DR: version mismatch for the plugin and 3dsmax version - that would probably run at runtime, but not let you build because build relies on function being there

prenex commented 1 month ago

Okay.... I literally cannot update REVIT now in the "Autodesk Access" app because when I click the "login" buttons - both on the bottom of the screen and the regular one - nothing happens.... When I click "see all products" it opens web browser and I can enter credentials and it lets me in... then still the "Access" app does not seem to recognize me.... image (here I clicked both the button on the very bottom, and in the "account" menu on the top-right-ish)

I know its unrelated but its crazy. So I clicked on updating the login / SSO things hoping this fixes the issue and got random bug (while however it also now says installation successful after clicking OK): image

So I guess I will go and manually change the code temporarily for the build / debug session so it always throws the exception so I can debug the plugin with my older revit2024...

I know this product is very legacy, just like when I was writing plugins for 3dsmax, but it could be better... just saying... at least for those who have the proper version there indeed should be some descriptions like the above ones in the readme otherwise its hard to get started any meaningful analysis unless one does a lot of revit plugin development anyways.

At least I wrote up my thoughts for people who might stumble upon this in the future - but can you move some relevant parts of this discussion into the readme maybe? Would be beneficial I guess..

prenex commented 1 month ago

Okay... after making the changes I mentioned, it all builds now.

I can also go attach debugger to revit.exe: image

If however you see that you cannot place breakpoints, it can be for various reasons. The pdb might need be near the DLL but I think it is not strictly needed: image

However I checked the Debug->windows->modules and see that the build DLLs that got copied to C:\ProgramData\ are not picked up, but the original DLLs that REVIt comes with are - maybe again, because I installed REVIT on E:\ (both its programdata parts and programfiles parts). I might try copying them to E:\RevitProgramData\ or just rename the original DLLs and add them right near revit.exe to make it sure: image

prenex commented 1 month ago

I tried to copy the files to here (to my E:\ programdata-like choice thatt I made at install) but did not work: image

However when I tried to copy them manually to near the Revit.exe file (and backuping the old DLLs that you can see I already started) I spotted something weird: image

The Revit.IFC.Import.DLL file was not copied by the build scripts!

You can see that Revit.IFC.Import.Core.DLL is there and copied, but this is not. I think this is some mistake in your build process where I see these copy steps and for this file / project it is missing!

See here: image

You can copy it from here after the build succeeds though: image

prenex commented 1 month ago

So after all of this, I copied the collected DLL files (bunch from the copied-to location, and the import dlls manually) to near Revit.EXE and made backups of original files first: image

Also copied this "GeometryGym" DLL - not knowing if needed, but was part of what the build produces: image

As you can see, for the importers I also copy the *.pdb files - just in case why not.

I can now set breakpoints after attaching to revit.exe with VS debugger: image

Sadly this breakpoint was not hit when I imported a file that actually have window lining and panel properties (I thought its a good breakpoint to see how the import process stack trace is generally) but I can clearly see the breakpoint got added - maybe this file is only for exporting - or despite the .ifc file having panel props and lining props it does not get called for some reason... anyways... would be glad to see where the import-related parts of window / door and furniture are if you can comment something to this.

prenex commented 1 month ago

The build however succeeded this way and I can debug the importer DLL: image

What I learned:

Did not yet know where I can find import codes that are related to importing ifcwindow and ifcdoor that I was interested analysing, but that is a different issue. Build-wise after all of these, the things successfully builds and can be debugged (see screenshot). I see the import process starts from that entry pointt where I am in my breakpoints and see data.

Hopefully this might help others with similar issues to get started - and should be useful writeup of possible problems you might face. I still hope something like this gets added to README.md - at least a simpler variant. I am sure for newcomers would be useful.

Best Regards, Richard Thier Owner, CEO - MagosIT Kft (Ltd)

AngelVelezSosa commented 1 month ago

Just reading all of this, I was at an internal conference last week - thanks for commenting your journey! I think we probably have to augment our documentation so that others don't experience the same pain - I'll file an internal JIRA item to do this.

prenex commented 1 month ago

Just reading all of this, I was at an internal conference last week - thanks for commenting your journey! I think we probably have to augment our documentation so that others don't experience the same pain - I'll file an internal JIRA item to do this.

Hi!

Thanks for the reply! Surely this should help other people in the same shoes.

Can you maybe also answer me the otherwise unrelated-to-build question about where I can see / debug codes that happen when importing IFCWindow and their family generation? I have a file where families do not get correctly generated albeit windowtype seems to be the same (file also seems to use "mapped representation"). I also have a file that I exported from revit that gets imported correctly and looks very same so I plan to analyse what is the difference in the import process. Is it in some kind of native closed source? I hope its not.

In any ways - I am thankful if you add something based on my journey to the readme file. Must be very useful to people!

prenex commented 1 month ago

So my last question:

image

As far as I see importing of windows should be somewhere here, but it looks like its a closed source DLL for the import process so I guess it would be also nice to add to the readme what exactly is this repo? Its exporter for IFC source mostly while importer is mostly clolsed source and a call just delegates from here? I see a lot of classes in the importer project however that has all kinds of "Process(...) methods (see marked with X on the image and red arrows) so I thought there is somethings that this code does around the importer but I couldn't put any breakpoint in any of those things.

I see that this IfcAnyHandle is basically the type for IFC objects and that there is a parse step first. That is also looking like closed source, but I realized the "process" part is what probably does the heavy lifting and creates data for revit according to the parsed ifc data. But that I also does not seem to hook into or analyse.

So my last question is this: Is this repo / codebase in any way helpful if I want to analyse IFC IMPORT into revit and on which files how it fails to properly import when the file is standards compliant looking? If not is there anything open sourced I can look at to understand the process? I really hoped this repo can help me with this, but now I am not even sure what the repo really does and what closed source parts do - that would be also helpful to write down.

o-babii commented 1 month ago

Hello @prenex,

First of all, thank you for providing valuable feedback on the issues encountered while building and debugging the code. We will use it to improve our process and supplement the documentation.

Regarding the debugging of the code that processes IFCWindow elements during import, it’s important to note that IFC entities are processed within Revit’s native code. As a result, I think, there is no publicly available information detailing this process. The Process(...) methods you mentioned are specifically used when linking the IFC model.

You mentioned having issues with generating Families for IFCWindows. Could you please provide more details about this problem? Ideally, if you will be able to share a simple file that reproduces the issue. With this information, we can investigate the problem and work on preparing a fix for Revit.

Regards, Oleksandr

prenex commented 1 month ago

Hello @o-babii,

It is a bit sad that I cannot debug into the code that processes IFCWindow elements during import because I am a developer currently contracting to a 3D floor planner where part of my job involved making it have exports to IFC so people can use revit (or similar architectural software) to work with the files further if they want. I thought the simplest way would be to check out this code and better understand how I can export more compatible.

So I wrote the export code for them from scratch to do ifc4 and it works in that sense that I see everything in both software, but I just wanted things more easy for users in revit so they can go and change all windows with the same family to some revit window. If I import this file (see attachment), revit creates 4 families for the 3 windows in the IFC file. In IFC they have a shared window type (also can add a project library if it helps) and that family gets loaded, but 3 more families get also added and referenced separately by each window. So the families are not shared (what would be my expectation).

I really hoped I can just step through the code and debug things to provide better compatibility, but maybe you can point me into some direction about how family assignments work in revit ifc import. I saw a file when revit could import the family, but often even if I export shared family objects from revit and re-import the exported ifc also not always working and often things get duplicated families - just because I saw it "rarely" happen I wanted to debug what is really the difference.

Attached zip file contains "nolib.ifc" which is a simplified output that "does not work" and "windowgood.ifc" is one that I see the families properly imported only once and window objects share the family according to window type. I wish to understand what to do to more properly reproduce the "working" one - without line-by-line making a total copy (we are nearly doing it at this point though - except in my example I exported simplified placeholder geometry).

When I import file frrom SD4 ifc export into revit and select the family that is not assigned (and have a proper IFC guid as source so not generated by revit on the fly) and click on "create instance" in REVIT then I can seem to get into the create instance mode in revit, but after clicking into a wall / moving the cursor the window does not get generated so I was suspecting maybe the not in the file window types get generated through the import process because revit cannot instantiate from the original window type properly? This is what I wanted to debug and to see what code paths are taken differently in the window import procecss. The reason why I wanted to debug especially the window family import was only that I do not have "working" files for any other object type that gets their family properly assigned according to object type entity in IFC so I was focusing trying to make this work first - but generally interested in how can I write out an ifc file where the objects I want to see in REVIT to have the same family - is there some kind of rules / documentation about how to do it? Or maybe anything similar?

Example files (nolib.ifc) - in case it helps:

examples.zip

In any ways - if making family connection of imported objects from ifc maybe lost cause, stiff thanks if you add process documentation for this (and a description what exactly this library covers). I know it is probably bunch of work to keep proper docs up, but very helpful.

Just an example: I also develop 3dsmax plugins (a c++ gltf import / exporter for a project pretty full-featured - so if you want native code doing it just access asynth SAS to which I made this some year ago when it was incomplete in autodesk 3dsmax at the time both the babylonjs C# and in native versions - uses both old and pbr materials on import + also zf3d import support) and docs would have helped a lot there too....

TL;DR: If you can direct me to somewhere about "how to make families connections in IFC files to be imported into Revit" that would be great as it would solve my original problem to be better compatible with your product - but if all this effort was just so I write up how to build this and you add the build docs that I guess was already worth some effort so others will not sumble upon this not knowing what it is.

I wish you a good day! Richard Thier Owner, CEO, Techlead - MagosIT Ltd.