Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External Selection #181

Open
JosefUIBK opened this issue Mar 4, 2022 · 0 comments
Open

External Selection #181

JosefUIBK opened this issue Mar 4, 2022 · 0 comments

Comments

@JosefUIBK
Copy link

JosefUIBK commented Mar 4, 2022

Hey,

i am trying to highlight a selected element in the drawingcontrol3D, but selected from external. So i have a list with all spaces of the model, when i select a space an event is triggered

`

using (var model = IfcStore.Open(filePathIFC1))
{

            var selectedSpace = model.Instances.OfType<IIfcSpace>().Where(p => p.Name.ToString() == entityID).FirstOrDefault() as IPersistEntity;

            SelectedElement = selectedSpace;


            DrawingControl.ReloadModel(DrawingControl3D.ModelRefreshOptions.ViewPreserveCameraPosition);
        }

`

From the XBim git WPFSample i have this code parts

`

public static readonly DependencyProperty ModelProviderProperty = DependencyProperty.Register("ModelProvider", typeof(ObjectDataProvider), typeof(MainWindow));

    private ObjectDataProvider ModelProvider
    {
        get
        {
            return MainFrame.DataContext as ObjectDataProvider;
        }
    }

    #endregion

    public IfcStore Model
    {
        get { return ModelProvider.ObjectInstance as IfcStore; }
    }


    void MainWindow_Loaded(object sender, RoutedEventArgs e)
    {
        ModelProvider.Refresh();
    }

    public IPersistEntity SelectedElement
    {
        get => DrawingControl.SelectedEntity;
        set => DrawingControl.SelectedEntity = value;
    }

    public Xbim.Presentation.DrawingControl3D.SelectionBehaviours SelectionBehaviour
    {
        get => DrawingControl.SelectionBehaviour;
        set => DrawingControl.SelectionBehaviour = value;
    }


    public Xbim.Presentation.EntitySelection Selection
    {
        get => DrawingControl.Selection;
        set => DrawingControl.Selection = value;
    }

    public delegate void SelectionChangedHandler(object sender, System.Windows.Controls.SelectionChangedEventArgs e);

    public event SelectionChangedEventHandler SelectionChanged;


    private void LoadXbimFile(string dlgFileName)
    {
        Clear();

        var model = IfcStore.Open(dlgFileName);
        var context = new Xbim3DModelContext(model);
        context.CreateContext();
        ModelProvider.ObjectInstance = model;

    }

`

The drawingcontrol3D is working fine, and highlight "OnSelectionChanged" is working fine inside the view. But i can't trigger onselectionchanged from external like in my first code part above. I mean i can, and everything is working... but the selected space is not highlightes afterwarts.

Thx for the help.

oh and this is my xaml

<Window x:Class="ResultViewerDALEC.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:presentation="http://schemas.Xbim.com/Presentation" xmlns:local="clr-namespace:ResultViewerDALEC" xmlns:webView="clr-namespace:Microsoft.Toolkit.Wpf.UI.Controls;assembly=Microsoft.Toolkit.Wpf.UI.Controls.WebView" xmlns:webView2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf" mc:Ignorable="d" xmlns:oxy="http://oxyplot.org/wpf" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:webEx="clr-namespace:ResultViewerDALEC.Commands" Title="MainWindow" MinWidth="750" ResizeMode="CanResize" Height="400" HorizontalContentAlignment="Center" HorizontalAlignment="Center" Loaded="MainWindow_Loaded">

<Window.Resources> <ObjectDataProvider x:Key="ModelProvider" IsInitialLoadEnabled="False" /> </Window.Resources>

`

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
    <Grid HorizontalAlignment="Center" VerticalAlignment="Top"   Name="MainFrame" DataContext="{StaticResource ModelProvider}">

`

<presentation:DrawingControl3D x:Name="DrawingControl" x:FieldModifier="public" Model ="{Binding}" Focusable="True" Width="Auto" Height="400" SelectedEntityChanged="DrawingControl_SelectedEntityChanged" ModelOpacity="1"> </presentation:DrawingControl3D>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant