Revit 2022 Windows Form load error

Revit 2022 Windows Form load error

harilalmn
Advocate Advocate
1,062 Views
5 Replies
Message 1 of 6

Revit 2022 Windows Form load error

harilalmn
Advocate
Advocate

Hi..

I was developing a C# plugin for Revit. 

It works fine in 2020 and 2021 versions. But nothing happens when they click the plugin button in 2022. My plug in should show up a windows form first. That is the main window. But it doesn't even open the window.

When I debug from Visual Studio, the following message shows up in the output window when I click the plugin button in Revit.

Here is the message;

 

*system.windows.media.animation warning:* 6 : unable to perform action because the specified storyboard was never applied to this object for interactive control.the

What could be wrong..?

0 Likes
Accepted solutions (1)
1,063 Views
5 Replies
Replies (5)
Message 2 of 6

RPTHOMAS108
Mentor
Mentor

Is your UI WPF or Forms?

 

Storyboards are a WPF (control animation) thing not a Forms thing. You get many of those messages when the Revit UI is created so more to do with that I think.

 

There is something else going on so when stepping through do you encounter any exceptions? What does the code used to show the Form look like? Are you using any 3rd party controls on the Form that could be already referenced elsewhere i.e. in the newer Revit?

 

 

 

0 Likes
Message 3 of 6

harilalmn
Advocate
Advocate

It is Windows Form.

 

My ExternalApplication has this code;

 

public Result OnStartup(UIControlledApplication application)
        {
            string panelName = "Test Panel";
            RibbonPanel panel = application.CreateRibbonPanel(panelName);
            string thisAssemblyPath = Assembly.GetExecutingAssembly().Location;
            Image img = Properties.Resources.Image32;
            ImageSource imgsrc=GetImageSource(img);
            PushButtonData buttonData = new PushButtonData(
                "cmdTestCommand",
                "Testing Command",
                thisAssemblyPath,
                "NewTest.TestingCommand"
                )
            {
                ToolTip = "Tooltip appears here....",
                LongDescription = "This is a long description......",
                Image = imgSrc,
                LargeImage =imgSrc
            };
            PushButton pushButton = panel.AddItem(buttonData) as PushButton;
            ContextualHelp cxtHelp = new ContextualHelp(ContextualHelpType.ChmFile,
            Path.Combine(Path.GetDirectoryName(thisAssemblyPath), "TestCommandHelp.chm"));
            pushButton.SetContextualHelp(cxtHelp);
         return Result.Succeeded;
      }

        private BitmapSource GetImageSource(Image img)
        {
            BitmapImage bmp = new BitmapImage();

            using (MemoryStream ms = new MemoryStream())
            {
                img.Save(ms, ImageFormat.Png);
                ms.Position = 0;
                bmp.BeginInit();
                bmp.CacheOption = BitmapCacheOption.OnLoad;
                bmp.UriSource = null;
                bmp.StreamSource = ms;
                bmp.EndInit();
            }
            return bmp;
        }

 

When I hover the button, the tool tip is shown. Even the F1 opens CHM file. But as soon as the tooltip pops up, the Output window of visual studio show this error;

system.windows.media.animation warning: 6 : unable to perform action because the specified storyboard was never applied to this object for interactive control.

 

Then if I click the button, nothing is executed...

0 Likes
Message 4 of 6

RPTHOMAS108
Mentor
Mentor

Again I think that error is a red herring and is related to Revit UI doing something unimportant wrong with the tooltip. That fact you have a button with tooltip indicates the code included above is generally ok.

 

What does IExternalCommand execute method look like, have you stepped through this? Is push button data pointing to correct class name, are there any exceptions associated with InitializeComponent of form?

0 Likes
Message 5 of 6

harilalmn
Advocate
Advocate
Accepted solution

OK, I don't know yet, what was the issue. I scrapped everything and this time downloaded and tried with Jeremy's Revit2022 plugin template for visual studio. It worked...!! 

 

Thanks for the responses @RPTHOMAS108 

0 Likes
Message 6 of 6

DollyPortis-WPM
Participant
Participant
Hello @harilalmn I am having the same problem. Can you share the plugin template you used that worked? Thank you.
0 Likes