Asking for help on creating an automatic part creation with Excel for tags

Asking for help on creating an automatic part creation with Excel for tags

be2TRFJJ
Observer Observer
248 Views
3 Replies
Message 1 of 4

Asking for help on creating an automatic part creation with Excel for tags

be2TRFJJ
Observer
Observer

Hi all !

 

I have to create hundreds of tags as individual parts. It's a pretty tedious task doing it manualy, so i would love to automate it, but have limited knowledge on doing said task. I usually find what I want through these forums, but not for this much automation (it's a lot for me 🙂).

 

Here is an example of what I have as an excel sheet : (sorry if there is a bad translation on here)

Label NumberTypeLength (mm)Width (mm)Height (mm)FRENROUPORESIT
ETIQ-0001GRAVOPLY EP 0.835150,8MARCHE / ARRETON / OFFPORNIT / OPRITLIGAR / DESLIGARENCENDIDO / APAGADOACCENSIONE / SPEGNIMENTO

 

So goal is to make from this one line, 6 different parts :

Capture.PNG

Each looking like this : with their dimensions and text linked to the excel sheet.

Capture2.PNG

Since my company isn't used to using iLogic, I would like each parts to be not linked with eachother (other than the excel link of course). So my guess is a macro would be adequate.

 

I appreciate in advance everyone who takes the time to help me.

Cheers !

0 Likes
249 Views
3 Replies
Replies (3)
Message 2 of 4

chris
Advisor
Advisor

@be2TRFJJ  Interesting... what is the goal with the parts, are they being constrained in an assembly, printed, drawings, etc? Is it just those 6 languages and only the message changes? or will the part size change based on the length/size of a word or specific font?

 

Message 3 of 4

be2TRFJJ
Observer
Observer
The parts are to be used in assembly to designate commands. A drawing with their dimensions with an export in PDF and DXF will be needed (and very likely needing to be automated) but i'm focusing on creating them first. Yes, each tag says the same thing but in 6 different languages. The size is indicated in Length x Width x Thickness but goal is to rarely change it to make it uniform. Tho the option is there for extra-long words, as each languages is different.

I'll keep doing them manually for now. I have limited time to do as many as I can.

Thank you for your awnser !
0 Likes
Message 4 of 4

dalton98
Collaborator
Collaborator

Hello. I don't think its possible to link inventor documents to excel like this. I know you can link parameters, but this only works for numerical values (hopefully in the future they add text parameter capability). You can also add excel files to inventor by: Manage > Insert Object. But, this still requires an ilogic rule to update the inventor file.

 

Anyways I created this rule. It parses through each row of an excel file to create a copy inventor part.

AddReference "Microsoft.Office.Interop.Excel.dll"
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Excel
Dim oDoc As PartDocument = ThisDoc.Document
Dim filedirectory As String = IO.Path.GetDirectoryName(oDoc.FullFileName) & "\"
'link text to parameter example
oDoc.ComponentDefinition.Parameters.Item("EmbossParam").Value = "ON / OFF"
oDoc.Update()

Dim oxl As Excel.Application = CreateObject("Excel.Application")
oxl.Visible = True
Dim owb As Excel.Workbook = oxl.Workbooks.Open("C\temp\excelfile.xlsx")
Dim osheet As Excel.Worksheet = owb.ActiveSheet

'start on row 2
For i = 2 To osheet.UsedRange.Rows.Count
	'start on column 6
	For j = 6 To osheet.UsedRange.Columns.Count
		Dim newfiletext As String = osheet.Cells(i, j).Text
		Dim labelNo As String = osheet.Cells(i, 1).Text
		Dim sLanguage As String = osheet.Cells(1, j).Text
		Dim newfilename As String
		newfilename = labelNo & "-" & sLanguage & "-" & newfiletext.Replace(" / ", "-") & ".ipt"
		IO.File.Copy(oDoc.FullFileName, filedirectory & newfilename, True)
		'set true to see part open
		Dim newfileDoc As PartDocument = ThisApplication.Documents.Open(filedirectory & newfilename, False)
		newfileDoc.ComponentDefinition.Parameters.Item("EmbossParam").Value = newfiletext
		newfileDoc.ComponentDefinition.Parameters.Item("Length").Expression = osheet.Cells(i, 3).Text & " mm"
		'add other parameters
		newfileDoc.PropertySets(3).Item("Part Number").Value = Left(newfilename, newfilename.Length - 4)
		newfileDoc.Update()
		newfileDoc.Save()
		newfileDoc.Close()
	Next
Next
oxl.Quit