Hi Everyone
I'm looking for a way to generate files using an excel using Ilogic I assume.
It's kinda the same as Iparts but without the links.
To start simple I was thinking about a profile and a variable Length.
The excel would have 2 Columns.
Name & Length
I want to populate the excel with multiple names and its lengths.
The Ilogic is then Imbedded to the "master part file" and looks into the Excel to generate my files.
1. It has to look into the first row and save as "Name"
2. changes the "Length" parameter to the correct value
3. save again or more ideally saves again and leaves the file open.
4. Repeat until there are no more rows.
I was hoping this would be a basic start but can't find anything on the forum.
I did find this link:
Creating simple series of large numbers of parts using excel spreadsheet and parameter list - Autode...
But they decided to use Iparts instead.
In the future I want to adapt the code to be able to change more then 1 parameter but 1 parameter is a very good start.
Can anyone send me in the right direction?
Br
Justin
Solved! Go to Solution.
Solved by Michael.Navara. Go to Solution.
See the sample in attachment. There is profile generator for L-profiles (Inv 2024)
Code sample:
Sub Main()
Dim part As PartDocument = ThisDoc.Document
Dim targetDir = IO.Path.GetDirectoryName(part.FullFileName)
Dim fileName As String = IO.Path.Combine(targetDir,"PartTable.xlsx")
Dim sheetName As String = "Sheet1"
GoExcel.Open(fileName, sheetName)
Dim row As Integer = 2 'Start from second row
Dim name As String
Dim length As String
Dim size As String
Do
name = GoExcel.CellValue("A" & row)
If String.IsNullOrEmpty(name) Then Exit Do
length = GoExcel.CellValue("B" & row)
size = GoExcel.CellValue("C" & row)
part.ComponentDefinition.Parameters.Item("Length").Expression = length
part.ComponentDefinition.Parameters.Item("Size").Expression = size
part.Update()
Dim newPartFileName As String = IO.Path.Combine(targetDir, name & ".ipt")
part.SaveAs(newPartFileName, True)
row += 1
Loop
GoExcel.Close()
End Sub
I was unable to open your file in inventor 2023.
But I recreated your part with the same parameters and paste the code in my rules.
It works. I do see you say it's a code sample.
So is the code you posted here the full code or is it missing some other code?
Just asking to be sure.
Thank you very much for helping me. I will be able to customize this code a lot and make our work much more efficient.
Best Regards
Justin
It is just a working sample. That means it works, but a lot of code is omitted for readability and brevity. For example there is no error handling for any case like
In my opinion this is just about 10% of the final safe and user-friendly code. But it depends on your needs.
Can't find what you're looking for? Ask the community or share your knowledge.