iLogic Excel Multivalue parameter for Find same value

iLogic Excel Multivalue parameter for Find same value

kfc10
Participant Participant
704 Views
4 Replies
Message 1 of 5

iLogic Excel Multivalue parameter for Find same value

kfc10
Participant
Participant

Hi, does anyone have an idea?

Is something like this possible with iLogic? Files in the attachment. 

2021-04-25_21h38_39.png

I created the code below and I don't know how to proceed.

location = "myfile.xlsx"
sheet1 = "Sheet1"
numberrow = ""

Try
	p1 = "dia"
	m1 = Parameter.Param(p1)
Catch
	'Creating a parameter
	op1 = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddbyExpression(p1, 10, "mm")
End Try

Try
	p2 = "length"
	m2 = Parameter.Param(p2)
Catch
	'Creating a parameter
	op2 = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddbyExpression(p2, 100, "mm")
End Try

'Creates a list of materials, draws from the list created in the Excel table LIST 
MultiValue.List(p1) = GoExcel.CellValues(location, sheet1, "B2", numberrow)

i = GoExcel.FindRow(location, sheet1, "dia", "=", Parameter("dia"))
Parameter("length") = GoExcel.CellValue(location, sheet1, "C" & i)

  

Accepted solutions (1)
705 Views
4 Replies
Replies (4)
Message 2 of 5

dutt.thakar
Collaborator
Collaborator

@kfc10 

 

I am not having Inventor 2022, so can not open your file, Maybe you can change some things as stated below in your code and see if that works.

 

location = "myfile.xlsx" ' Please add the file name with full file path here and not only the file name
sheet1 = "Sheet1"
numberrow = ""

Try
	p1 = "dia"
	m1 = Parameter.Param(p1)
Catch
	'Creating a parameter
	op1 = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddbyExpression(p1, 10, "mm")
End Try

Try
	p2 = "length"
	m2 = Parameter.Param(p2)
Catch
	'Creating a parameter
	op2 = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddbyExpression(p2, 100, "mm")
End Try

'Creates a list of materials, draws from the list created in the Excel table LIST 
MultiValue.List(p1) = GoExcel.CellValues(location, sheet1, "B2", numberrow)

i = GoExcel.FindRow(location, sheet1, "dia", "=", Parameter("dia"))
Parameter("length") = GoExcel.CurrentRowValue("length")

  If you can post the file in Inventor 2021 version, I would be able to look at the behaviour as well in Inventor.

 

Hope this will help you.

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes
Message 3 of 5

kfc10
Participant
Participant

Hello, we did not understand. I guess I explain it wrong, sorry. I'll try to explain better. See picture.

2021-04-26_17h15_40.png

0 Likes
Message 4 of 5

dutt.thakar
Collaborator
Collaborator
Accepted solution

@kfc10 

 

Ok, I think I did not understand earlier, what you are trying to achieve but these snapshots had made it quite clear.

 

Try the below code. Keep in mind one thing, it assumes that, the diameter is always in the increment of 10mm,(i.e. 10, 20,30, etc.), and based on that it tries to find the right cell address and then add it to the multi-value list for length.

 

location = "myfile.xlsx" ' Please add the file name with full file path here and not only the file name
sheet1 = "Sheet1"
numberrow = ""

Try
	p1 = "dia"
	m1 = Parameter.Param(p1)
Catch
	'Creating a parameter
	op1 = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddbyExpression(p1, 10, "mm")
End Try

Try
	p2 = "length"
	m2 = Parameter.Param(p2)
Catch
	'Creating a parameter
	op2 = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddbyExpression(p2, 100, "mm")
End Try

'Creates a list of materials, draws from the list created in the Excel table LIST 
MultiValue.List(p1) = GoExcel.CellValues(location, sheet1, "B2", numberrow)

i = GoExcel.FindRow(location, sheet1, "dia", "=", dia)
j = GoExcel.FindRow(location, sheet1, "dia", "=", dia + 10)
MultiValue.SetValueOptions(True, DefaultIndex := 0)
MultiValue.List(p2) = GoExcel.CellValues(location,sheet1,"C" & i,"C" & j-1)
RuleParametersOutput()
InventorVb.DocumentUpdate

 

Hope this will help you.

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
Message 5 of 5

kfc10
Participant
Participant

Hi @dutt.thakar 

Thank you very much.

That's incredible. I thought that was not possible.

0 Likes