Multivalue parameter arrayList throwing error when assigning an array

Multivalue parameter arrayList throwing error when assigning an array

drouthierXAHY9
Participant Participant
429 Views
1 Reply
Message 1 of 2

Multivalue parameter arrayList throwing error when assigning an array

drouthierXAHY9
Participant
Participant

Hi there!

I'm getting an  "Object reference not set to an instance of an object." error when attempting to assign an array to a multivalue parameter. 

 

The multivalue parameter is "test" and the array I'm attempting to assign to the "test" parameter is the form array.

I've attempted to:

  • simply assign the materialStyle array
  • populate the formArray using the "add" function with the materialStyle array
  • directly assign the materialStyle array TO the formArray

 

I'm simply not good enough to figure out what I am doing wrong. 

 

Dave

 

AddReference "System.Linq"
AddReference "System.Xml"
AddReference "System.Xml.Linq"
AddReference "System.Core"

Imports System.Linq
Imports System.Xml.Linq
Imports System.Xml.Schema
Imports System.Xml

Sub Main
	Dim feedXML As XDocument
	Dim xmlDocName As String = "C:\Users\drouthier\Desktop\sheetmetalrules.xml"
	
	feedXML = XDocument.Load(xmlDocName)
	materialStyle = xmlFeedFilter(feedXML, "MaterialStyle")
		
	Dim formArray As New ArrayList()
	formArray.clear
	
	For x = 0 To UBound(materialStyle)
	formArray.add (materialStyle(x))
	Next x
	
	MultiValue.List("test") = formArray
End Sub

Public Function xmlFeedFilter(feedXML As Object, attributeName As String)
	Dim x As Integer
	Dim z As Integer
	Dim objectArray(0) As String
	
	For Each oElement As XElement In feedXML.Descendants()
		For Each oAttribute As XAttribute In oElement.Attributes()
			If oAttribute.Value = attributeName
				z = 0 
				For x = 0 To UBound(objectArray)
					If UBound(objectArray) = 0 Then
					Exit For
					Else
						If objectArray(x) = oElement Then
						z = 1
						Exit For
						End If
					End If
				Next x
				
				If z = 0 Then
				objectArray(UBound(objectArray)) = oElement
				ReDim Preserve objectArray(UBound(objectArray) + 1)
				End If
			End If
		Next oAttribute
	Next oElement

	BubbleSortAscending(list:= objectArray)
	xmlFeedFilter = objectArray
End Function

Public Sub BubbleSortAscending(list() As Object)
'  Sorts an array using bubble sort algorithm
'  Ascending
'  perform the call from the main as
'  BubbleSort (list:=array)
    Dim First As Long, Last As Long
    Dim i As Long, j As Long 
    Dim Temp As Object
    
    First = LBound(list) 
    Last = UBound(list) 
    For i = First To Last - 1 
        For j = i + 1 To Last 
            If list(i) > list(j) Then 
                Temp = list(j) 
                list(j) = list(i) 
                list(i) = Temp 
            End If 
        Next j 
    Next i 
End Sub
0 Likes
430 Views
1 Reply
Reply (1)
Message 2 of 2

bradeneuropeArthur
Mentor
Mentor

Hi,

 

First I see is that:

 

dim materialStyle as ???????
materialStyle = xmlFeedFilter(feedXML, "MaterialStyle")

Regards,

Autodesk Software: Inventor Professional 2018 | Vault Professional 2018 | Autocad Mechanical 2018
Programming Skills: Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
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 !

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