How to pass parameter to RenderPlugin

HusseinOthman75
Enthusiast
Enthusiast

How to pass parameter to RenderPlugin

HusseinOthman75
Enthusiast
Enthusiast

Hi,

I want to pass parameters to RenderPlugin like AddInPlugin (when calling ExecuteAddInPlugin method from an application). Furthermore, how to call RenderPlugin from application or from another plugin. 

Thanks in advance

0 Likes
Reply
1,001 Views
12 Replies
Replies (12)

alexisDVJML
Collaborator
Collaborator

Answer to the last part of your question, aka call/passing parameters to RenderPlugin from another plugin (mechanism below however I guess can easily be extended to cover ExecuteAddInPlugin scenario).


Let's take one of our case as exemple: our Ribbon plugin allows the user to select rendering options that are used by our RenderPlugin.
To minimize data exchange between plugins, both share a reference to an instance of our RendererOptions class that contains dozens of structures and parameters.
Since the RenderPlugin use this for each render, in theory there is (ALMOST) nothing to do. When the RibbonPlugin change any parameter in RendererOptions instance, the RendererPlugin will use this at the next render.


I said ALMOST, because we need to tell Navisworks that a redraw is needed, so your RenderPlugin will be called and do its stuff.
This done with:

Application.ActiveDocument.ActiveView.RequestDelayedRedraw(ViewRedrawRequests.All);

Note: this queue a redraw request which is 99% of the time what you want (I can elaborate of the 1% case if needed).

Important/Additional Comments:
- to be exhaustive, you could have case where changing some parameters requires to recompute some cached CPU-intensive stuff. Best is to do this in your Ribbon to keep the Rendering fast and responsible.
- in theory you should use a shared lock or equivalent between both Plugin when doing such stuff. In practice, if you change these settings on a ribbon event, it seems it's not needed, Navisworks being, in the past and in the foreseeable future, mostly single-threaded.

Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
0 Likes

HusseinOthman75
Enthusiast
Enthusiast

hi alexisDVJML,

Your contribution is highly appreciated. However, as i'm not proffessional Naviswork API programmer, can you please drive a simple example illustrate this case. 

Best Regards

0 Likes

lanneauolivier
Enthusiast
Enthusiast

Hi Hussein,

 

Use public variables to change it from another class as described here

https://forums.autodesk.com/t5/navisworks-api/call-render-plugin-through-addinplugin/m-p/9430718

 

HusseinOthman75
Enthusiast
Enthusiast

I want to pass data from C# application or AddinPlugin to render plugin through JSON object, is it possible???

0 Likes

HusseinOthman75
Enthusiast
Enthusiast

I want to pass data from C# application or AddinPlugin to render plugin through JSON object, is it possible???

0 Likes

HusseinOthman75
Enthusiast
Enthusiast

i use this code to pass parameter to Addin Plugin 

//
navisworksApplication.ExecuteAddInPlugin("Visualizer.ADSK", pa);

 

How to do the same with Render Plugin??

0 Likes

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @HusseinOthman75 ,

 

Can you please share more details about the JSON data you want to pass into the Render Plugin?
Also, how do you plan to use that data in the plugin?
A clear explanation will help me understand your needs better and assist you more effectively.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes

HusseinOthman75
Enthusiast
Enthusiast

Hi  naveen.kumar.t

First sorry for delay because i was despair of finding solution. My point is : i'm using an application that sends JSon data to Addin plugin to select certain model items. When the items are selected Render plugin display the item name.

What i need to do is to display the status of the item beside its name by sending the status to Render plugin using JSon object.

Displaying data for each model item is of crucial important to me.

Thanks in advance

0 Likes

HusseinOthman75
Enthusiast
Enthusiast

You support is highly appreciated. We count on you. Regards

0 Likes

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @HusseinOthman75 ,

 

It isn't possible to directly pass data into a render plugin. Instead, you would need to create an intermediary plugin or class capable of reading the data and making it accessible to the render plugin.

I haven't tested this approach on my end yet. Could you give it a try and let me know your findings?

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @HusseinOthman75 ,

 

Since you mentioned wanting to pass the selected item data to RenderPlugin, you could make use of PickItemFromPoint within RenderPlugin.

Please check this blog demo 
https://adndevblog.typepad.com/aec/2013/05/navisworks-2014-api-new-feature-inputplugin.html


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes

HusseinOthman75
Enthusiast
Enthusiast

Hi naveen.kumar.t ,

Grateful for your assistance. Please bear with me. i can't get your point but i will try to make my point more clear. I use AddInPlugin to select certain model items. Autmoatically RenderPlugin is called by Navisworks to display model item name : i use this method,

         graphics.Text2D(new TextFontInfo("typeFace", 7, 4, true, false), _name , _point2D, (int)1, (int)1);

where _name contains the model item name (from model itself). So my idea is : if i can send my custome date (which i get from database ) using JSon object or whatever , then i can attach this date to (_name) string and let it appear with model item name. 

Thank you for you assistance

 

 

0 Likes