Export/Import 3D Information Array

Export/Import 3D Information Array

Anonymous
Not applicable
600 Views
4 Replies
Message 1 of 5

Export/Import 3D Information Array

Anonymous
Not applicable

Hi everyone,

 

I am curious if there is a way to export and import a 3D Array of text generated in iLogic? How would I go about doing this? Thanks you any help rendered.

 

-Lance

0 Likes
Accepted solutions (1)
601 Views
4 Replies
Replies (4)
Message 2 of 5

HermJan.Otterman
Advisor
Advisor

what do you mean with a 3D array of text??

can you show a picure

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 3 of 5

Anonymous
Not applicable
Hello,

Thanks for the response! I have code which compiles information (strings) into a 3 dim array. I then have an assembly call upon that array, but it is temporary. I would prefer to load in an array at the beginning (already made previously), and go from there. It would also be good to export the array to a place I could pull it from later.

If you have any insight on this, it would be much appreciated! Thank you for your time.

Sincerely,
Lance
0 Likes
Message 4 of 5

Anonymous
Not applicable

This is a sample code illustrating what I am talking about:
3D Array Construction.PNG

My goal would be to export the array "Arr" to an external location and call upon it to index values. This 3D array is made of design data that would need to be extracted from Inventor files. For this reason, I am not creating this in another program.

 

If there is not a method of doing this, I may try to write something to accomplish it. 

 

0 Likes
Message 5 of 5

Anonymous
Not applicable
Accepted solution

Interestingly enough, I was able to export and import an array. This uses a text file to hold the array formatted in a multidimensional delimited manner. This will be cool to use!

 

SyntaxEditor Code Snippet

'Option explicit Off
Dim Matrix(5, 5, 5) As Double

Dim y As Integer
Dim x As Integer
Dim z As Integer
Dim user_y As String
Dim user_x As String
Dim user_z As String
Dim t As Integer
t = 0
y = 0
x = 0
z = 0

For x = 0 To 4
	For y = 0 To 4
		For z = 0 To 4
			Matrix(x, y, z) = t.ToString
			t = t + 1
		Next 
	Next
Next 

MessageBox.Show(Matrix.Rank & "=Rank & " & Matrix.Length & "=Length", "Dimensions")

Dim cycle As Integer
cycle = 0

While cycle <1
user_x = InputBox("Insert x-value", "Value Inquiry", "0")

user_y = InputBox("Insert y-value", "Value Inquiry", "0")

user_z = InputBox("Insert z-value", "Value Inquiry", "0")

MessageBox.Show(Matrix(Val(user_x), Val(user_y), Val(user_z)).ToString, "Value Inquiry Results")

Dim bool1 As Boolean
bool1 = InputRadioBox("Retry?", "Yes", "No", True, Title := "Program Cycle")
If bool1 = True
	cycle = 0
	Else
	cycle = 1
End If
End While

Dim bool2 As Boolean
bool2 = InputRadioBox("Export Array?", "Yes", "No", True, Title := "Array Export")

''Export

	Dim Temporary_x As String
	Dim Temporary_y As String
	Dim Collective As String
'	Collective = "{"
'	Temporary_y = ""
'	Temporary_x = ""
If bool2 = True
	Collective = ""
	For z = 0 To Matrix.GetLength(2)-2
		Temporary_y = ""
		For y = 0 To Matrix.GetLength(1)-2
			Temporary_x = ""
			For x = 0 To Matrix.GetLength(0)-2
				If x = 0
					Temporary_x = Matrix(x,y,z).ToString
				Else
					Temporary_x = Temporary_x & ":" & Matrix(x,y,z).ToString
				End If
			Next
			If y = 0
				Temporary_y = Temporary_x
			Else
				Temporary_y = Temporary_y & "," & Temporary_x
			End If 
		Next
		If z = 0
			Collective = Temporary_y
		Else
			Collective = Collective & ";" & Temporary_y
		End If
	Next

	Else
End If

'WriteAllText("Libraries\Documents\Test_1.txt",Collective.ToString)
oWrite = System.IO.File.CreateText(ThisDoc.PathAndFileName(False) & ".txt")
oWrite.WriteLine(Collective.ToString)
oWrite.Close
MessageBox.Show(Collective, "Preliminary Proof of Concept")

Dim Collective2 As String
Collective2 = My.Computer.FileSystem.ReadAllText(ThisDoc.PathAndFileName(False) & ".txt")

''Import
Dimz = Collective2.Split(";").Count - 1
Dimy = Collective2.Split(";")(0).Split(",").Count - 1
Dimx = Collective2.Split(";")(0).Split(",")(0).Split(":").Count - 1
Dim Matrix2(Dimx+1,Dimy+1,Dimz+1) As String
For z = 0 To Dimz
	For y = 0 To Dimy
		For x = 0 To Dimx
			Matrix2(x, y, z) = Collective2.Split(";")(z).Split(",")(y).Split(":")(x)
		Next
	Next
Next

MessageBox.Show(Matrix2.Rank & "=Rank & " & Matrix2.Length & "=Length", "Dimensions")

''Testing
cycle = 0

While cycle <1
user_x = InputBox("Insert x-value", "Value Inquiry", "0")

user_y = InputBox("Insert y-value", "Value Inquiry", "0")

user_z = InputBox("Insert z-value", "Value Inquiry", "0")

MessageBox.Show(Matrix2(Val(user_x), Val(user_y), Val(user_z)).ToString, "Value Inquiry Results")

Dim bool1 As Boolean
bool1 = InputRadioBox("Retry?", "Yes", "No", True, Title := "Program Cycle")
If bool1 = True
	cycle = 0
	Else
	cycle = 1
End If
End While

 

0 Likes