Showing results for 
Search instead for 
Do you mean 
Reply

How to call a dll file with a button in the block styler?

I had created a dll file with .Net VB, and I created a block styler with a button, how can I click this button and my dll file could be executed?
Best Regards
Christian
3 REPLIES

Re: How to call a dll file with a button in the block styler?

For yourself ONLY:

Look in the NX10 docs

Home -> Fundamentals -> Customizing the NX environment -> Customizing your environment -> Customizing Ribbon bar, toolbars, and menus -> Create new commands

 

 

 

To share with all users at your site:

Briefly, you need to either:

1) Create something using Menuscript

To get the menuscript docs, you have to install the (NOT SELECTED BY DEFAULT) API documentation when you install the docs,

 

or

 

2) Deal with ribbon (RTB) and/or toolbar (TBR) files

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: How to call a dll file with a button in the block styler?

Hi Ken_A,
Thanks for your suggestion, but maybe i didn't discribe it very clear, I mean this button is made in Block Styler, not just create a button in NX and run dll file, please find below...

ElseIf block Is button0 Then
'---- Enter your code here -----
<Here I need add some programs to run the dll file which I made>
Best Regards
Christian

Re: How to call a dll file with a button in the block styler?

Imports System.Reflection

 

can you try adding this code in UPdate area

 


If System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory() & "YourDLLFileName.dll") Then
pathDLL = AppDomain.CurrentDomain.BaseDirectory() & "YourDLLFileName.dll"
Else
GoTo EndState
End If

Dim asm As Assembly = Assembly.LoadFrom(pathDLL) 'Load the assembly
Dim t As Type = asm.GetType("NAMESPACE.CLASS") 'Get a reference to the type that contains the code
Dim info As MethodInfo = t.GetMethod("METHOD_NAME") 'Get a reference to the method on the type that we want to call
If Not info Is Nothing Then
Dim instance As Object = Activator.CreateInstance(t) 'Create an instance of the type to call the method on
info.Invoke(instance, param) 'Invoke the method with no parameters

End If