Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to call the iLogic snippets for Component.Add and Comstraints.AddMate in a method of a custom class inside my iLogic Rule and its giving me the error "The object reference was not set to an object instance.". I feel like i'm having similar problem to Alex from this post . I already tried to inherit from ThisRule which doesn't work (but changes the Snippet color to purple). Now i tried to adapt the solution from the other thread and pass ThisRule to my custom class which looks like this:
Sub Main()
Dim P7 As New AssemblyComponent(Me)
For counter = 0 To 2
P7.addComponentToAssembly()
Next
End Sub
Public Class AssemblyComponent : Inherits ThisRule
Dim partCount As Integer = 0
Dim mateCount As Integer = 0
Dim flushCount As Integer = 0
Public Sub addComponentToAssembly()
Me.partCount += 1
Dim seperator As String = ":"
Dim occurence As String = Me.name & seperator & CStr(Me.partCount)
Dim part = Components.Add(occurence, name & ".ipt")
Dim counter As Integer = 0
For Each item In constraintOptions
If item = "Mate" Then
mateCount += 1
Constraints.AddMate("Mate" & CStr(mateCount), "", Me.references(counter), occurence, Me.references(counter),
offset:=Me.offsets(counter))
ElseIf item = "Flush" Then
flushCount += 1
Constraints.AddFlush("Flush" & CStr(flushCount), "", Me.references(counter), occurence, Me.references(counter),
offset:=Me.offsets(counter))
End If
counter += 1
Next
End Sub
Dim ThisRule As ThisRule
Dim ThisDoc As Document
Dim Parameter As IParamDynamic
Dim MultiValue As IMultiValueParam
Dim ThisAssembly As IManagedAssembly
Dim Components As IManagedComponents
Dim Constraints As IManagedConstraints
Public Sub New(oThisRule As ThisRule)
ThisRule = oThisRule
ThisDoc = ThisRule.ThisDoc.Document
Parameter = ThisRule.Parameter
MultiValue = ThisRule.MultiValue
Components = ThisAssembly.Components
Constraints = ThisAssembly.Constraints
End Sub
End Class
Maybe someone has an idea or can tell me if i'm on a completly wrong track. I didn't get a definite answer from the thread i linked, that's why i'm asking here now. Thank you.
Solved! Go to Solution.