xBimTeam / XbimWindowsUI

The home of XbimXplorer and WPF components for your desktop BIM applications.
Other
252 stars 149 forks source link

Viewer in WPF application #132

Closed cesarecaoduro closed 4 years ago

cesarecaoduro commented 4 years ago

It might be a stupid question but I can't find a straight forward way to visualize the model in the 3D control after I open it with the IfcStore and convert it.

using (var model = IfcStore.Open(of.FileName))
                {
                    var context = new Xbim3DModelContext(model);
                    context.CreateContext();

                    tb_output.Text = $"{model.FileName}\n";
                    try {
                        //Add multiple IFC types
                        var reqProducts = new IIfcProduct[0]
                            .Concat(model.Instances.OfType<IIfcElementAssembly>())
                            .Concat(model.Instances.OfType<IIfcBuildingElementProxy>());

                        tb_output.Text += $"Object count: {reqProducts.Count()}\n";

                    }
                    catch (Exception ex) {
                        tb_output.Text += $"Error: {ex.Message}\n";
                    }

What is the process? I can't find tutorial of good examples and the XBim explorer is hard to understand at the beginning. 2019-11-08 23_29_17-Autodesk Revit 2019 -  Project1 - Floor Plan_ Level 0

andyward commented 4 years ago

I think you just need to bind the model instance to the Model property of the DrawingControl3D component (which it looks like you've got running in the screenshot.)

If you want a simple example have you looked at https://github.com/xBimTeam/XbimWindowsUI/tree/master/Xbim.WinformsSample ?

While it's a Winforms sample it's actually wrapping the XAML control so doing the same things...

cesarecaoduro commented 4 years ago

I saw the example but it keeps saying that the application can't find the interop engine which is in the folder

andyward commented 4 years ago

What's the exact message?

What versions of XBim.Geometry are you using?

cesarecaoduro commented 4 years ago

It finally worked downloading all the references. Probably the nuget manager didn't download all the referenced packages.