Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Call Render plugin through AddinPlugin

cerqueira.tiago15
Participant

Call Render plugin through AddinPlugin

cerqueira.tiago15
Participant
Participant

The method R(view, Graphic) generates spheres in some coordinates. This is the only way that I have found to generate a sphere solid inside Navisworks. Therefore, I would like to call the plugin bellow through another AddinPlugin but I am able to do that only using ToolPlugin instead of RenderPlugin. As I don't want to override none of the tools available for the user navigate, this is the better way I have found. Is there a way to call it? If not, is there a better way to create geometry inside Navisworks?

class SpherePlugin : RenderPlugin
{

    public override void Render(View view, Autodesk.Navisworks.Api.Graphics graphics)
    {
        R(view, graphics);
    }
    public override void OverlayRender(View view, Autodesk.Navisworks.Api.Graphics graphics)
    {

        R(view, graphics);
    }
}

 

0 Likes
Reply
Accepted solutions (1)
1,432 Views
3 Replies
Replies (3)

Anonymous
Not applicable
Accepted solution

As far as I am aware, the render methods you've linked are called every time Navisworks attempts to update the frame (from mouse click, etc.) What I think you could do is something similar to the following:

class SpherePlugin : RenderPlugin
{
    public static <Object you want to render> Renderable = null;

    public override void Render(View view, Autodesk.Navisworks.Api.Graphics graphics)
    {
        if(Renderable != null)
        {
            // Do your drawing here
        }
        R(view, graphics);
    }
    public override void OverlayRender(View view, Autodesk.Navisworks.Api.Graphics graphics)
    {

        R(view, graphics);
    }
}

In this scenario it checks if there exists something needing to be drawn, and if it doesn draws it.

 

You calling code could then set renderable to whatever needs to currently be drawn, or to null to stop something from being drawn.

 

I know this seems very hacky and super inefficient but it's the best thing I've found to work for when I attempted this in the past.

cerqueira.tiago15
Participant
Participant

It works. Thanks a lot. Instead of null I use a non static variable to be evaluated during the call of the plugin. 

        public override int Execute(params string[] parameters)
        {
           
            if (enable)
            {
                RenderPluginRecord toolPluginRecord = (RenderPluginRecord)Application.Plugins.FindPlugin("MyPlugin.TIAG");
                RenderPlugin plugin = toolPluginRecord.LoadedPlugin;
                SpherePlugin spheres = (SpherePlugin)plugin;
                spheres.isRender = true;
            }

            else
            {

                RenderPluginRecord toolPluginRecord = (RenderPluginRecord)Application.Plugins.FindPlugin("MyPlugin.TIAG");
                RenderPlugin plugin = toolPluginRecord.LoadedPlugin;
                SpherePlugin spheres = (SpherePlugin)plugin;
                spheres.isRender = false;
            }

            enable = !enable;
            return 0;
        }

And in the method: 

        public bool isRender = false;
        public override void Render(View view, Autodesk.Navisworks.Api.Graphics graphics)
        {
            if (isRender)
            {
                R(view, graphics); 
            }
        }
        public override void OverlayRender(View view, Autodesk.Navisworks.Api.Graphics graphics)
        {

            if (isRender)
            {
                R(view, graphics); 
            }
        }

HusseinOthman75
Enthusiast
Enthusiast

How could you reference render plugin : SpherePlugin in the Addin Plugin?

0 Likes