Excel Reading in ilogic code

Excel Reading in ilogic code

Anonymous
Not applicable
869 Views
6 Replies
Message 1 of 7

Excel Reading in ilogic code

Anonymous
Not applicable

Hi

i read two excel files in this code. I want for Rows 4 to 8, 5 parts created with their name A1, B1, V, A2, B2...

in the loop that i write it creates the first one but for second it fives me the error as below

Error in rule: Rule6, in document: A final.ipt

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

first i input 3 for ID=3 and then i write 4 in the form but it give me that errorCapture.PNG

 

Sub Main()
ThisApplication.ActiveView.Fit
For J=3 To 7
GoExcel.Open("C:\Users\a.khakbaz\Desktop\Inventor\Linking to Pv elit\nozzle\Nozzles", "Sheet1")
VV=InputBox("Prompt", "id", "Default Entry",MessageBoxButtons.YesNo)
If VV=0 Then 
Exit Sub
End If
i = GoExcel.FindRow("C:\Users\a.khakbaz\Desktop\Inventor\Linking to Pv elit\nozzle\Nozzles", "Sheet1","ID", "=", VV)
N_ID= GoExcel.CurrentRowValue("nominalDiameter")
PIPE_THK=GoExcel.CurrentRowValue("actualThickness")
PRO_CEN=GoExcel.CurrentRowValue("outsideProjection")
PAD_OD=GoExcel.CurrentRowValue("padDiameter")
Dim sFilePath As String= ThisDoc.Path & "\"
ThisDoc.Save
doc = ThisDoc.Document
sNewName=GoExcel.CellValue("B" & i)
GoExcel.Close
GoExcel.Open("C:\Users\a.khakbaz\Desktop\Inventor\Linking to Pv elit\nozzle\WNFLG2", "Sheet1")
i = GoExcel.FindRow("C:\Users\a.khakbaz\Desktop\Inventor\Linking to Pv elit\nozzle\WNFLG2", "Sheet1","NPS","=",N_ID)
iLogicVb.UpdateWhenDone = True
O = GoExcel.CurrentRowValue("O")
C1 = GoExcel.CurrentRowValue("C")
CB = GoExcel.CurrentRowValue("CB")
CC= GoExcel.CurrentRowValue("CC")
R = GoExcel.CurrentRowValue("R")
No = GoExcel.CurrentRowValue("No")
G = GoExcel.CurrentRowValue("G")
D = GoExcel.CurrentRowValue("D")
X = GoExcel.CurrentRowValue("X")
A1 = GoExcel.CurrentRowValue("A")
Y1 = GoExcel.CurrentRowValue("Y1")
YY = GoExcel.CurrentRowValue("YY")
RA = GoExcel.CurrentRowValue("RA")
RuleParametersOutput()
GoExcel.Close
ThisDoc.Document.Update()
ThisDoc.Document.saveas(sFilePath & sNewName & ".ipt",True)
Next J
End Sub

 

0 Likes
870 Views
6 Replies
Replies (6)
Message 2 of 7

HermJan.Otterman
Advisor
Advisor

could you attach/send the excel files also

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 7

Anonymous
Not applicable
could you please take a look at below link...
i send my question again and also my excel files are attached.
Now i just cant give drawing.
if have nay idea, i'm willing to read
thank you
http://forums.autodesk.com/t5/inventor-customization/excel-reading-in-ilogic-code/m-p/6065546/highli...
0 Likes
Message 4 of 7

HermJan.Otterman
Advisor
Advisor

the problem is in the line :

 

sNewName As String = GoExcel.CellValue("B" & i)

 

if you remove that line it works

 

i'm not sure what it does..

(you have to restart invenor or have to save the xls after you get the error to get it going again)

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 5 of 7

HermJan.Otterman
Advisor
Advisor

this is Rule 3, and now it works (with me)

I turned some things off, you can turn them on but I doubt if they do anything, but you can judge that better.

I changed the line for sNewName...

 

 

Sub Main()
kk_LineNumber=1
For counter = 1 To 10
'MsgBox(counter,,"test")
GoExcel.Open(ThisDoc.Path & "\" & "Nozzles.xlsx", "Sheet1")
GoExcel.FindRowStart = kk_LineNumber+1
LineNumber = GoExcel.FindRow("Nozzles.xlsx", "Sheet1", "RadialNozzle", "=", "true", "class", "=" ,150, "flangeType", "=", 0)

'MsgBox(LineNumber,,"test2")
If LineNumber<>-1 Then
kk_LineNumber = LineNumber
nominalDiameter = GoExcel.CurrentRowValue("nominalDiameter")
MessageBox.Show("aa = "  & nominalDiameter, "Title")
MessageBox.Show("kk = "  & kk_LineNumber, "Title")
Dim sFilePath As String= ThisDoc.Path & "\"
'ThisDoc.Save'doc = ThisDoc.Document'Dim sNewName As String = GoExcel.CellValue("B" & i)
Dim sNewName As String = GoExcel.CurrentRowValue("description")
'MsgBox(sNewName)'GoExcel.Close'Next j'GoExcel.Open("C:\Users\Ali Khakbaz\Desktop\nozzle\WNFLG2.xlsx", "Sheet1")'i = GoExcel.FindRow("C:\Users\Ali Khakbaz\Desktop\nozzle\WNFLG2.xlsx", "Sheet1", "NPS", "=", aa)
LineNumber2 = GoExcel.FindRow(ThisDoc.Path & "\" & "WNFLG2.xlsx", "Sheet1", "NPS", "=", aa)
MessageBox.Show("Message"  & LineNumber2-1, "Title",MessageBoxButtons.OK)
Lenght=  GoExcel.CurrentRowValue("O")
RuleParametersOutput()
GoExcel.Close
ThisDoc.Document.Update()
ThisDoc.Document.saveas(sFilePath & sNewName & ".ipt",True)
End If
Next counter
ThisApplication.ActiveView.Fit
End Sub

 

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


Message 6 of 7

Anonymous
Not applicable
thanks for your reply..
would you please take a look at the corrected code to give me your idea?
I correct code and I want to add drawing to this code but it did not work for me
i'm waiting for your answer
0 Likes
Message 7 of 7

Anonymous
Not applicable
0 Likes