System.NotimplementedException error

System.NotimplementedException error

A_S_E_
Participant Participant
499 Views
6 Replies
Message 1 of 7

System.NotimplementedException error

A_S_E_
Participant
Participant

Hello there,

 

If anyone has any idea why is my code failing even though after successful build i Visual Studio itself. While implementing in Revit i Get the following error. It works fine with TaskDialog (commented) but not TestWindow.

 

Thanks for helping.

 

the code

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using System.Xml.Linq;
using System.Windows.Media.Imaging;
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.UI;
using Autodesk.Revit.ApplicationServices;


namespace ClassLibrary1
{

[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class Class2 : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{

UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;


//var components = uidoc.Selection.GetElementIds();

ICollection<ElementId> components = uidoc.Selection.GetElementIds();

TestWindow testWindow = new TestWindow(components);
testWindow.ShowDialog("Message",components.Count.ToString());
//TaskDialog.Show("Message", components.Count.ToString());
testWindow.Show();

//TaskDialog.Show("Revit", "Hello World");

return Result.Succeeded;
}
}

}

0 Likes
Accepted solutions (1)
500 Views
6 Replies
Replies (6)
Message 2 of 7

A_S_E_
Participant
Participant

A snip from the code in Visual Studio.

0 Likes
Message 3 of 7

ankofl
Advocate
Advocate

It looks like you implemented one of the window events, but left it unchanged

    TestWindow testWindow = new TestWindow();
    testWindow.Closed += TestWindow_Closed;

private void TtestWindow(object sender, EventArgs e)
{
    throw new NotImplementedException();
}
Message 4 of 7

Mohamed_Arshad
Advisor
Advisor

HI @A_S_E_ 

 

What is Test Window, its a Event? or Winform ? Can you explain in detail


Mohamed Arshad K
Software Developer (CAD & BIM)

Message 5 of 7

A_S_E_
Participant
Participant

Hello Arshad,

 

Thanks for reaching out, here it is

0 Likes
Message 6 of 7

Mohamed_Arshad
Advisor
Advisor
Accepted solution

HI @A_S_E_ 

 

   You have link Revit Context With the WPF, Kindly check the Below Image and Code for Reference

 

Reference Code (UI Back end)

 

 public partial class TestWindow : Window
    {
        public TestWindow(List<ElementId> ids, double count)
        {
            InitializeComponent();

            //List of Element to UI
            foreach(ElementId id in ids)
            {
                listBox.Items.Add(id.IntegerValue.ToString()); //List Box
            }

            //Add Count to UI
            countLabel.Content = count.ToString(); //Label

        }
    }

 

 

Reference Code (Revit Execute)

 

public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;
            Document doc = uidoc.Document;


            ICollection<ElementId> components = uidoc.Selection.GetElementIds();

            TestWindow testWindow = new TestWindow(components.ToList(), components.Count);
            testWindow.ShowDialog();


            //TaskDialog.Show("Revit", "Hello World");

            return Result.Succeeded;

        }

 

 

Output Image

 

Mohamed_Arshad_1-1700753272000.png

 

 

Hope this will helps 🙂

 


Mohamed Arshad K
Software Developer (CAD & BIM)

0 Likes
Message 7 of 7

A_S_E_
Participant
Participant

Thankyou so much it works like a charm.