Call dll from iLogic

Call dll from iLogic

Anonymous
Not applicable
2,634 Views
11 Replies
Message 1 of 12

Call dll from iLogic

Anonymous
Not applicable

Hi All

 

I am new to the .net but have used iLogic for some time. I have tried to reference a sub inside a Class (dll file).

 

I have some parameters that I want to set from the dll.

 

Parameter "Lenght1" and "Width1" exist in the model file

 

I can call the sub and receive the msgBox but I cannot figure out how to set parameters from the dll through iLogic.

 

I get the following error message:

"Object reference not set to an instance of an object."

 

Can anyone help me with setting the parameters? Or point me in the right direction

 

See simplified example below:

 

'iLogic call

 

 

AddReference "System.Runtime"

AddReference "C:\Vault\Designs\Testing\iLogic_VB\SubCall.dll"

Parameter.UpdateAfterChange = True 
MultiValue.UpdateAfterChange = True 
iLogicVb.UpdateWhenDone = True 

Dim tool as New SubCall.ClassSubCall

tool.Testing(UserAnswer) 'Yes or No
  tool.Parameter = Parameter
  tool.MultiValue = MultiValue
  tool.Length1 = Parameter("Length1")
  tool.Width1 = Parameter("Width1")

 

'dll file

Imports Autodesk.iLogic.Interfaces

Public Class ClassSubCall

Public Parameter As IParamDynamic

Public MultiValue As IMultiValueParam

Public ILogicVB As ILowLevelSupport

Public Length1 As Double

Public Width1 As Double

 

Public Sub Testing(ByVal UserAnswer As String)

If UserAnswer = "Yes" Then

MsgBox("OK, message received")

Parameter("Length1") = 100

Parameter("Width1") = 50

Else

MsgBox("No message received")

Parameter("Length1") = 150

Parameter("Width1") = Parameter("Length1") / 2

End If

End Sub

End Class


 

0 Likes
Accepted solutions (1)
2,635 Views
11 Replies
Replies (11)
Message 2 of 12

bradeneuropeArthur
Mentor
Mentor

you need to create a New statement:

 

Public Sub new(ByVal UserAnswer As String)
If UserAnswer = "Yes" Then
MsgBox("OK, message received")
Parameter("Length1") = 100
Parameter("Width1") = 50
Else
MsgBox("No message received")
Parameter("Length1") = 150
Parameter("Width1") = Parameter("Length1") / 2
End If
End Sub
End Class

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 3 of 12

Anonymous
Not applicable

Hi

 

I am not quite following you. Is this necessary only on Subs? Works fine on functions. Perhaps it is possible to return an array

 

Call from iLogic (model opdates fine)

AddReference "System.Runtime"

AddReference "C:\Vault\Designs\KH test\Testing\iLogic_VB\SubCall.dll"

Parameter.UpdateAfterChange = True 
MultiValue.UpdateAfterChange = True 
iLogicVb.UpdateWhenDone = True

Dim tool as New SubCall.ClassSubCall

Length1=tool.FunctionTest(UserAnswer)

 

dll content

Imports Autodesk.iLogic.Interfaces

Public Class ClassSubCall

Public Parameter As IParamDynamic

Public MultiValue As IMultiValueParam

Public ILogicVB As ILowLevelSupport

 

Public Function FunctionTest(ByVal UserAnswer As String)

 

If UserAnswer = "Yes" Then

MsgBox("OK, message received")

 

FunctionTest = 100

Else

MsgBox("No message received")

 

FunctionTest = 150

End If

End Function

End Class

0 Likes
Message 4 of 12

bradeneuropeArthur
Mentor
Mentor
Try to test with only a message box. You will see that nothing happens on the new statement

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 12

Anonymous
Not applicable

Thanks for your tips... But I think that I am missing the basics

 

Can you refer to any articles etc. for best practice on this area?

0 Likes
Message 6 of 12

bradeneuropeArthur
Mentor
Mentor
Tell me what your code needs to do.
I will send you an example asap

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 7 of 12

Anonymous
Not applicable

 

Any help would be appreciated.

 

This is on a Proof Of Concept level.

 

Based on a specific answer from the user in Form1 I want to retreive the Dimensions Width1 and Length1 from a dll and update the model. Hopefully this is clear.

 

The Form1 is an iLogic form not from the .NET

 

Capture.JPG

0 Likes
Message 8 of 12

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Sorry.

 

But I think your code is correct.

it works with this:

 

 Dim Tool As ClassSubCall.ClassSubCall = New ClassSubCall.ClassSubCall()

        'a.FunctionTest("aa")
        MsgBox(Tool.FunctionTest("Yes"))

        'Length1 = Tool.FunctionTest("Yes")
    End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 9 of 12

Anonymous
Not applicable

Hi

 

Yes it works with the function test. But here I can only retreive one value.

 

Public Function FunctionTest(ByVal UserAnswer As String)

If UserAnswer = "Yes" Then

MsgBox("OK, message received")

 

FunctionTest = 100

Else

MsgBox("No message received")

 

FunctionTest = 150

End If

End Function

 

 

If I try to do the same with a Sub and set multiple values and try to set the Length1 and Width1

Public Sub Testing(ByVal UserAnswer As String)

If UserAnswer = "Yes" Then

MsgBox("OK, message received")

Parameter("Length1") = 100

Parameter("Width1") = 50

Else

MsgBox("No message received")

Parameter("Length1") = 150

Parameter("Width1") = 75

End If

End Sub

 

It does not produce a value...

 

Dim tool as New SubCall.ClassSubCall
MsgBox(tool.Testing("Yes"))
tool.Testing(UserAnswer)

 

0 Likes
Message 10 of 12

bradeneuropeArthur
Mentor
Mentor
Hoi should define an array. And return that

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 11 of 12

smilinger
Advisor
Advisor
Accepted solution

Apparently you made a mistake by using the Parameter member in your Testing method before it's assigned a value. You should write this line:

tool.Parameter = Parameter

before this line:

tool.Testing(UserAnswer)

Or you should do that in a Constructor, aka Sub New() as suggested by @bradeneuropeArthur in the 2nd post.

Message 12 of 12

Anonymous
Not applicable

Could it really be that simple? Yes it could...

 

AddReference "System.Runtime"

AddReference "C:\Vault\Designs\KH test\Testing\iLogic_VB\SubCall.dll"

Parameter.UpdateAfterChange = True 
MultiValue.UpdateAfterChange = True 
iLogicVb.UpdateWhenDone = True


Dim tool as New SubCall.ClassSubCall
tool.Parameter = Parameter
tool.Length1 = Parameter("Length1")
tool.Width1 = Parameter("Width1")
tool.Testing(UserAnswer)

 

Thanks for the support, both of you. Very much appreciated

0 Likes