xBimTeam / XbimWindowsUI

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

Set DrawingControl3D.SelectionColor with latest version of HelixToolkit #202

Open christianstroh opened 1 year ago

christianstroh commented 1 year ago

If i set the property SelectionColor of the class DrawingControl3D in my XAML file, i get this exception:

Method not found: "Void HelixToolkit.Wpf.MeshBuilder.AddTube(System.Collections.Generic.IList`1, Double, Int32, Boolean, Boolean, Boolean)".

In the Xbim.WindowsUI package, the setter of this property calls the method HighlighSelected(), which calls AddTube from the HelixToolkit package. I guess in the latest stable version of the HelixToolkit.Wpf package there is no method overload with this signature. When i clone the Xbim.WindowsUI git repository, Visual Studio automatically installs HelixToolkit and HelixToolkit.WPF version 2.14.0.

andyward commented 1 year ago

We've seen something similar before in #200 - Are you loading Xbim.Windows UI in Revit? Or another 3rd party application?

Basically it's likely environmental - HelixToolkit seemingly broke an API in a minor release, and when another library brings in a different version of Helix, and the app resolves via binding redirects etc - it's loading in an incompatible version.

We could look to upgrade to the latest version. 2.23 - but I don't know if that would help if you're bringing in another older version somehow. Perhaps you can see what is loaded as per the comment in #200

Equally I have a branch that I hope will be merged soon that uses Helix.Core.WPF which may help (it uses the new netcore Engine and related net6 branches)

christianstroh commented 1 year ago

Thank you for your response.

I'm using Xbim.WindowsUI in a .NET Framework 4.8 Windows Application (Visual Studio), the DrawingControl3D is embedded in the main window (xaml file).

For the time being I can do without setting the property or try an older version of the HelixToolkit, not the latest version 2.23. And I will try Helix.Core.WPF when your branch is merged.

andyward commented 1 year ago

If you use the version of Helix we've built against (2.14.0) you should be fine? https://github.com/xBimTeam/XbimWindowsUI/blob/faa8e9450866f929c7514e2b4b18d285648ccf75/Xbim.Presentation/Xbim.Presentation.csproj#L44

christianstroh commented 1 year ago

When i don't set the property SelectionColor via WPF data binding, the application starts with HelixToolkit.Wpf 2.14.0. But when i bind the property, a ArgumentNullException is thrown with this stack trace:

at System.Linq.GroupedEnumerable3..ctor(IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer`1 comparer) at Xbim.Presentation.WpfMeshGeometry3D.GetGeometry(EntitySelection selection, XbimModelPositioningCollection positions, Material mat) at Xbim.Presentation.DrawingControl3D.GetSelectionGeometry(IPersistEntity newVal, WpfMaterial mat) at Xbim.Presentation.DrawingControl3D.HighlighSelected(IPersistEntity newVal) at Xbim.Presentation.DrawingControl3D.set_SelectionColor(Color value)

I think its because the property Selection is still null at this call: m = WpfMeshGeometry3D.GetGeometry(Selection, ModelPositions, mat); When i set this property to a new EntitySelection, another exception occurs.