miroiu / nodify

Highly performant and modular controls for node-based editors designed for data-binding and MVVM.
https://miroiu.github.io/nodify
MIT License
1.27k stars 205 forks source link

[Question] Problem about Revit-Nodify-Cooperation-Experiment #80

Closed sky92archangel closed 5 months ago

sky92archangel commented 9 months ago

Nodify is a great project . I have saw the nodify-example, and run the Nodify successful on the dotnet console-project ; 屏幕截图 2023-11-22 105942 so far, everthing is ok;

then, I thought about put Nodify into the Revit Plugin,called Revit-Nodify-Cooperation-Experiment ; But,an annoying problem occurred when I working on it;

########################################### the code : the entrypoint is SimpleDemoCommand

SimpleDemoCommand.cs

using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SEPD.TestSpace.SimpleNodifyRevit
{
    [Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
    [Journaling(JournalingMode.UsingCommandData)]
    public class SimpleDemoCommand : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        { 
            SimpleDemoView simpleDemoView = new SimpleDemoView(); 
            simpleDemoView.DataContext = new SimpleDemoViewModel();
            simpleDemoView.Show();

            return Result.Succeeded;
        }
    }
}

SimpleDemoView.xaml

<Window x:Class="SEPD.TestSpace.SimpleNodifyRevit.SimpleDemoView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:SEPD.TestSpace.SimpleNodifyRevit"
            xmlns:nodifyx="clr-namespace:Nodify;assembly=Nodify"  
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid> 

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid Grid.Column="0">
                        <nodifyx:NodifyEditor   >

                        </nodifyx:NodifyEditor>
                    </Grid> 
    </Grid>
</Window>

SimpleDemoViewModel.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SEPD.TestSpace.SimpleNodifyRevit
{
    internal class SimpleDemoViewModel
    {
    }
}

the error occurred : ERROR-SCREEN-SHOT-1: 屏幕截图 2023-11-22 104321 ERROR-SCREEN-SHOT-2: 屏幕截图 2023-11-22 104548 ERROR-DETAIL:

System.Windows.Markup.XamlParseException
  HResult=0x80131501
  Message=“初始化“Nodify.NodifyEditor”时引发了异常。”,行号为“19”,行位置为“26”。
  Source=PresentationFramework
  StackTrace:
   在 System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)

  此异常最初是在此调用堆栈中引发的: 
    System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, ref System.Threading.StackCrawlMark, System.IntPtr, bool, bool, bool)
    System.Reflection.RuntimeAssembly.InternalLoad(string, System.Security.Policy.Evidence, ref System.Threading.StackCrawlMark, System.IntPtr, bool)
    System.Reflection.RuntimeAssembly.InternalLoad(string, System.Security.Policy.Evidence, ref System.Threading.StackCrawlMark, bool)
    System.Reflection.Assembly.Load(string)
    System.Windows.SystemResources.ResourceDictionaries.LoadExternalAssembly(bool, bool, out System.Reflection.Assembly, out string)
    System.Windows.SystemResources.ResourceDictionaries.LoadThemedDictionary(bool)
    System.Windows.SystemResources.FindDictionaryResource(object, System.Type, System.Windows.ResourceKey, bool, bool, bool, out bool)
    System.Windows.SystemResources.FindResourceInternal(object, bool, bool)
    System.Windows.StyleHelper.GetThemeStyle(System.Windows.FrameworkElement, System.Windows.FrameworkContentElement)
    System.Windows.FrameworkElement.UpdateThemeStyleProperty()
    ...
    [调用堆栈已截断]

内部异常 1:
ArgumentOutOfRangeException: 长度不能小于 0。
Arg_ParamName_Name

################################### It seems error happened at the xmal initialize step if "nodifyx:NodifyEditor" has been typed in xaml file; This is the first step for Revit-Nodify cooperation development , if the problem could not be sovled, my experiment should be aborted.

miroiu commented 7 months ago

Hi! Sorry for the late response.

Try loading the theme in the App.xaml or whatever entry point the plugin is using before rendering the editor.

<ResourceDictionary Source="pack://application:,,,/Nodify;component/Themes/Dark.xaml" />
miroiu commented 5 months ago

I don't know if this helped. Please reopen the issue if you need more information.