error in code

error in code

vistametals
Participant Participant
817 Views
4 Replies
Message 1 of 5

error in code

vistametals
Participant
Participant

I am new to ilogic.

trying to read a value out of an excel workbook that is embedded in my IPT file.

I keep getting

hk_row = 9' deleted parameter

'width_row = 3' deleted parameter


If thk >= 20 Then 
	thk_row = "13"
	
ElseIf thk >= 17 Then 
		thk_row = "13"
ElseIf thk >= 16 Then 
		thk_row = "13"
ElseIf thk >= 15 Then 
		thk_row = "13"
ElseIf thk >= 14 Then 
		thk_row = "12"
ElseIf thk >= 13 Then 
		thk_row = "12"
ElseIf thk >= 12 Then 
		thk_row = "12"
ElseIf thk >= 10 Then 
		thk_row = "11"
ElseIf thk >= 9 Then 
		thk_row = "10"
ElseIf thk >= 8 Then 
		thk_row = "9"
ElseIf thk >= 7 Then 
		thk_row = "8"
ElseIf thk >= 6 Then 
		thk_row = "7"
ElseIf thk >= 5 Then
		thk_row = "6"
ElseIf thk >= 4 Then 
		thk_row = "5"	
ElseIf thk >= 3 Then 
		thk_row = "4"
ElseIf thk >= 2 Then 
		width_row = "3"
ElseIf thk >= 1 Then 
		thk_row = "2"
ElseIf thk > 0 Then 
		thk_row = "1"
		
	


End If

'thk_column = 1' deleted parameter

'width_column = 8' deleted parameter

If width >= 20 Then 
	thk_column = "N"
	
ElseIf width >= 17 Then 
		thk_column = "N"
ElseIf width >= 16 Then 
		thk_column = "N"
ElseIf width >= 15 Then 
		thk_column = "N"
ElseIf width >= 12 Then 
		thk_column = "M"
ElseIf width >= 10 Then 
		thk_column = "L"
ElseIf width >= 9 Then 
		thk_column = "K"
ElseIf width >= 8 Then 
		thk_column = "J"
ElseIf width >= 7 Then 
		thk_column = "I"
ElseIf width >= 6 Then 
		thk_column = "H"
ElseIf width >= 5 Then 
		thk_column = "G"
ElseIf width >= 4 Then 
		thk_column = "F"
ElseIf width >= 3 Then 
		thk_column = "E"
ElseIf width >= 2 Then
	    thk_column = "D"
ElseIf width >= 1 Then 
		thk_column = "C"
ElseIf width > 0 Then 
		thk_column = "B"
		
	


End If



If lg >= 20 Then 
	thk_chart = "Sheet39"
	
ElseIf lg >= 17 Then 
		thk_chart = "Sheet39"
ElseIf lg >= 16 Then 
		thk_chart = "Sheet39"
ElseIf lg >= 15 Then 
		thk_chart = "Sheet39"
ElseIf lg >= 14 Then 
		thk_chart = "Sheet25"
ElseIf lg >= 12 Then 
		thk_chart = "Sheet25"
ElseIf lg >= 10 Then 
		thk_chart = "Sheet24"
ElseIf lg >= 9 Then 
		thk_chart = "Sheet23"
ElseIf lg >= 8 Then 
		thk_chart = "Sheet22"
ElseIf lg >= 7 Then 
		thk_chart = "Sheet21"
ElseIf lg >= 6 Then 
		thk_chart = "Sheet20"
ElseIf lg >= 5 Then 
		thk_chart = "Sheet19"
ElseIf lg >= 4 Then 
		thk_chart = "Sheet18"
ElseIf lg >= 3 Then 
		thk_chart = "Sheet17"	
ElseIf lg >= 2 Then 
		thk_chart = "Sheet16"
ElseIf lg >= 1 Then 
		thk_chart = "Sheet15"
ElseIf lg > 0 Then 
		thk_chart = "Sheet14"
		
	


End If

oPath = "\\filesrv\USERS\ENGINEERING\Inventor\"
'("\\filesrv\Engineering\Inventor\Inventor\INVENTOR_MASTERS\rect_stk_chart.xlsx", "Sheet1", "help", "=", 1)
oFileName = "thk_stk_rect.xlsx"
colm = Parameter("thk_column")
oPN = Parameter("thk_row")
sht = Parameter("thk_chart")
'get row using part number 
oRow = GoExcel.FindRow(oPath & oFileName, sht,"ht", "=", oPN)

Parameter("stk_thk") = GoExcel.CellValue("3rd Party:thk_stk_rect.xlsx", sht,  colm & oPN ) 'get value in 2nd column
'Parameter("ID") = GoExcel.CellValue(oPath & oFileName, "Sheet1", "C" & oRow) 'get value in 3rd column
'Parameter("LG") = GoExcel.CellValue(oPath & oFileName, "Sheet1", "D" & oRow ) 'get value in 4th column

InventorVb.DocumentUpdate()

errors that a cannot figure out. 

Error in rule: look_thk_combine, in document: rect_new.ipt

GoExcel: Could not match the column title: "ht"

System.ArgumentException: GoExcel: Could not match the column title: "ht"
at iLogic.GoExcel.FindColumn(String columnName)
at iLogic.GoExcel.FindRow(String fileName, String sheetName, Object[] sizeArgs)
at ThisRule.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

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

A.Acheson
Mentor
Mentor
Accepted solution

Hi @vistametals 

These can be difficult to figure out without the running file and excel sheet. I would suggest to step through the code moving the message box between each line with a message box and keep going untill it errors out. You can then be sure the preceeding line caused the error. You will also need to deal with the parameters that have been deleted. 

 

You can also try and target the lines thst the error message identifies. Check why it cannot find the objects. 

 

Another thing to note is all cells in a range need to be filled in. Do not leave them blank. Use N/A or similar. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 5

vistametals
Participant
Participant

Thank you. I deleted the unused parameters and filled in the blank ranges. Then the rule worked. Thanks again.

0 Likes
Message 4 of 5

A.Acheson
Mentor
Mentor

Great to here you got it working. Can you mark as solved what instructions worked for you so others can know it was successfull.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 5

A.Acheson
Mentor
Mentor
Accepted solution

Great to hear you got it working. Can you mark as solved what instructions worked for you so others can know it was successfull.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes