How to call Render Plugin using AddinPlugin

How to call Render Plugin using AddinPlugin

HusseinOthman75
Enthusiast Enthusiast
576 Views
3 Replies
Message 1 of 4

How to call Render Plugin using AddinPlugin

HusseinOthman75
Enthusiast
Enthusiast

I've created Render Plugin. I want to call it using Addin Plugin, i use the follwing code but it is not working :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Navisworks.Api;
using Autodesk.Navisworks.Api.Plugins;
using NvwApplication = Autodesk.Navisworks.Api.Application;

namespace TagNoRenderAddinPlugin
{
    [PluginAttribute("TagNumberRenderPlugin",
                     "ADSK",
                     ToolTip = "To Invoke Render1",
                     DisplayName = "TagNumberRenderPlugin")]
    public class TagNumberRenderPlugin : AddInPlugin
    {
        public override int Execute(params string[] parameters)
        {
            if (!NvwApplication.IsAutomated)
            {
                PluginRecord pluginRecord = NvwApplication.Plugins.FindPlugin("TagNoRender.ADSK");
                if (pluginRecord is RenderPluginRecord && pluginRecord.IsEnabled)
                {
                    RenderPlugin plugin = (RenderPlugin)(pluginRecord.LoadedPlugin ?? pluginRecord.LoadPlugin());
                    NvwApplication.ActiveDocument.ActiveView.RequestDelayedRedraw(Autodesk.Navisworks.Api.ViewRedrawRequests.OverlayRender);

                }
            }

            return 0;
        }
    }
}

 

The Render plug in name "TagNoRender". 

The Render plugin is tested and working perfectly when its dll is copied to Plugin folder of Navisworks it is called 

and working perfectly, but i want to call it manually as required. When i click this addin plugin button in Navisworks intrface nothing happen?

Could you please help me about this issue?

Thanks in advance. 

 

0 Likes
577 Views
3 Replies
Replies (3)
Message 3 of 4

HusseinOthman75
Enthusiast
Enthusiast

Hi  tetsuya_miwa,

i kept tying & trying several times, but this code is not working. Could you please provide a working example.

Thanks in advance.

 

0 Likes
Message 4 of 4

lanneauolivier
Enthusiast
Enthusiast

You do not need to load a RenderPlugin. It is loaded automatically dll when Navisworks is launching.

 

Plugins.FindPlugin() allows you to load a plugin that is inside your plugin's dll -> Plugins that are compiled inside the running dll.

If you need to load a plugin that is in another dll, you need to use Plugins.AddPluginAssembly(string fileName), with filename, the path to this dll

 

Hope it helps !

0 Likes