create part file with i logic code

create part file with i logic code

Anonymous
Not applicable
629 Views
7 Replies
Message 1 of 8

create part file with i logic code

Anonymous
Not applicable

it is my code.

GoExcel.Open("C:\Users\a.khakbaz\Desktop\nozzle\Cube.xlsx", "Sheet1")

Dim sFilePath As String= ThisDoc.Path & "\"
Dim sNewName As String

CurrentFilename = ThisDoc.PathAndFileName(False) 
For i=2 To 4
doc = ThisDoc.Document

sNewName=GoExcel.CellValue("A" & i)
Length = GoExcel.CellValue("B" & i)
width= GoExcel.CellValue("C" & i)
Height = GoExcel.CellValue("D" & i)
doc.saveas(sFilePath & sNewName & ".ipt",True)
Next i
iLogicVb.UpdateWhenDone = True

i send you cube.ipt and cube.xlsx

in This code i want for each row of excel, a part file with the name of  reading from column A (a1 or a2 or a3) is created and parameters (Lenght, Width and Height) changed.

BUT THE PROBLEM IS THAT a1.ipt and a2.ipt and a3.ipt created but with Length=width=Height=5mm. why my parameters do not change for a1 and a2??

Inventor 2016

0 Likes
Accepted solutions (1)
630 Views
7 Replies
Replies (7)
Message 2 of 8

danijel.radenkovic
Collaborator
Collaborator

Why should you not try iPart?

My opinion is that the best way to do it by Creating iPart.

Here is a link:

https://knowledge.autodesk.com/support/inventor-products/learn-explore/caas/CloudHelp/cloudhelp/2014...

 

iPart works like Family of similar members. You can easily switch between them as you can see on the image below.

example.png

 

Regards

Danijel

 

 

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
0 Likes
Message 3 of 8

danijel.radenkovic
Collaborator
Collaborator

By the way,

Here is iLogic way.

GoExcel.Open(ThisDoc.Path & "\" & "Cube.xlsx", "Sheet1")

Dim sFilePath As String= ThisDoc.Path & "\"
'CurrentFilename = ThisDoc.PathAndFileName(True) 
For i=2 To 4
doc = ThisDoc.Document
sNewName=GoExcel.CellValue("A" & i)

Length= GoExcel.CellValue("B" & i)
width= GoExcel.CellValue("C" & i)
Height = GoExcel.CellValue("D" & i)
RuleParametersOutput() ThisDoc.Document.Update() ThisDoc.Document.saveas(sFilePath & sNewName & ".ipt",True) Next i
iLogicVb.UpdateWhenDone = True
GoExcel.Close

update rule parameters.png

Regards

Danijel

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
Message 4 of 8

Anonymous
Not applicable
Thanks for your reply,
but still a have problem,
Lenght, width and Height of the three parts (a1, a2 and a3) are 5mm. (Last row of the excel)
Why??
0 Likes
Message 5 of 8

danijel.radenkovic
Collaborator
Collaborator
Accepted solution

@Anonymous wrote:
Thanks for your reply,
but still a have problem,
Lenght, width and Height of the three parts (a1, a2 and a3) are 5mm. (Last row of the excel)
Why??

 

 Probably you didn't copy whole code. Make sure that you need to have two lines marked with blue color. One is to update Rule parameters and other to update part.

 

GoExcel.Open(ThisDoc.Path & "\" & "Cube.xlsx", "Sheet1")

Dim sFilePath As String= ThisDoc.Path & "\"
'CurrentFilename = ThisDoc.PathAndFileName(True) 
For i=2 To 4
doc = ThisDoc.Document
sNewName=GoExcel.CellValue("A" & i)

Length= GoExcel.CellValue("B" & i)
width= GoExcel.CellValue("C" & i)
Height = GoExcel.CellValue("D" & i)
RuleParametersOutput() ThisDoc.Document.Update() ThisDoc.Document.saveas(sFilePath & sNewName & ".ipt",True) Next i
iLogicVb.UpdateWhenDone = True
GoExcel.Close

I have recorded a video of test so you can see is it works as you wished or not.

Best regards

Danijel

Inventor 2018/Windows 10 x64
If this information was helpful, please consider marking it as an Accepted Solution by using the Accept as Solution. Kudos are also gladly accepted.
0 Likes
Message 6 of 8

Anonymous
Not applicable
YOUR RIGHT...
THANK YOU
CAN YOU TAKE A LOOK AT THIS PROBLEM WHICH I POSTED RECENTLY
http://forums.autodesk.com/t5/inventor-customization/drawing-automatic/td-p/6061005
0 Likes
Message 7 of 8

Anonymous
Not applicable
i added below code to your code for opening a1 to a3 .ipt but it gives error
why?
For i=2 To 4
sNewName=GoExcel.CellValue("A" & i)
ThisDoc.Launch(sFilePath & sNewName & ".ipt")
Next i
0 Likes
Message 8 of 8

Anonymous
Not applicable
0 Likes