Number plate Creation

Number plate Creation

mahesh_s493TE
Contributor Contributor
743 Views
24 Replies
Message 1 of 25

Number plate Creation

mahesh_s493TE
Contributor
Contributor

Hi,

 

I want to create number plate based on the excel file.

Through iLogic program is created.

 
Sub main
	Dim oInvApp As Inventor.Application = ThisApplication
	Dim oDoc As Document = oInvApp.ActiveDocument
	If Not TypeOf oDoc Is AssemblyDocument Then Exit Sub
	Dim oAsmDoc As AssemblyDocument = oDoc
	Dim oAsmDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
	Dim oPart As ComponentOccurrence
	Try : oPart = oAsmDef.Occurrences.ItemByName("OriginalPart:1") : Catch : Exit Sub : End Try
	Dim oUParams As UserParameters = oAsmDef.Parameters.UserParameters
	Dim oParam As UserParameter
	Try : oParam = oUParams("FileLocation") : Catch
		oParam = oUParams.AddByValue("FileLocation", "", UnitsTypeEnum.kTextUnits) : End Try
	oParam.Value = GetFileLocation(oInvApp)
	If String.IsNullOrEmpty(oParam.Value) Then Exit Sub
	If Not IO.File.Exists(oParam.Value) Then Exit Sub
	Call CopyPipes(oPart, oParam.Value)
	oDoc.Update()
End Sub

Private Function GetFileLocation(ByVal oInvApp As Inventor.Application) As String
	Dim oFileDlg As Inventor.FileDialog = Nothing: oInvApp.CreateFileDialog(oFileDlg)
	oFileDlg.Filter = "Excel File (*.xlsx;*.xls)|*.xlsx;*.xls"
	oFileDlg.ShowOpen()
	Return oFileDlg.FileName
End Function

Private Function CopyPipes(oPart As ComponentOccurrence, ByVal sFileLoc As String)
	Dim sNameSheet As String = "Sheet1"
	Dim i As Integer = 2
	Dim slastPN, sCellValue As String
	Dim oPartDef As PartComponentDefinition = oPart.Definition
	Dim oPartDoc As PartDocument = oPartDef.Document
	Dim oSketch As PlanarSketch = oPartDef.Sketches("TextSketch")
	Dim oText As Inventor.TextBox = oSketch.TextBoxes(1)

	GoExcel.Open(sFileLoc, sNameSheet)
	Do
		slastPN = GoExcel.CellValue(sFileLoc, sNameSheet, "A" & i)
		If Not String.IsNullOrEmpty(slastPN) Then
			oPartDef.Parameters.UserParameters("Text").Value = slastPN
			oPartDoc.Update()
			oPartDoc.SaveAs("C:\Users\ValBrid106\Documents\Project\valbrid\LVAC\NAME PLATE\" & slastPN & ".ipt", True)
		End If
		i += 1
	Loop While Not String.IsNullOrEmpty(slastPN)
	GoExcel.Close()
End Function

 After run the program,

The following error message is occurred.

Error on line 40 in rule: Rule0, in document: PANEL NAME PLATE.iam

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

How will I modify the iLOGIC program., Kindly advice on this.,

Thanks

0 Likes
Accepted solutions (1)
744 Views
24 Replies
Replies (24)
Message 2 of 25

CCarreiras
Mentor
Mentor

HI!

 

Only looking at the code will be hard to suggest something.

You have to share the files to yake a look and understand all the picture.

CCarreiras

EESignature

0 Likes
Message 3 of 25

mahesh_s493TE
Contributor
Contributor

Hi,

I need the name plate like below., In excel there is large of name plate to be create.

mahesh_s493TE_1-1749781601141.png

 

For the template creation, I make it like below.

mahesh_s493TE_0-1749781447526.png

Thanks.,

0 Likes
Message 4 of 25

batuhanozmen98
Enthusiast
Enthusiast

Hi, Can you SS your Fx parameter table?

0 Likes
Message 5 of 25

mahesh_s493TE
Contributor
Contributor

mahesh_s493TE_0-1749807956632.png

 

0 Likes
Message 6 of 25

mahesh_s493TE
Contributor
Contributor

This one or something else.,

0 Likes
Message 7 of 25

batuhanozmen98
Enthusiast
Enthusiast

Yes that one, the error at line 40 so can you change it like this:

 

oPartDef.Parameters.UserParameters("FileLocation").Value = slastPN

 

0 Likes
Message 8 of 25

mahesh_s493TE
Contributor
Contributor

Hi,

 

mahesh_s493TE_0-1749812180905.png

 

The same error is occurred., 

mahesh_s493TE_1-1749812280665.png

 

 

0 Likes
Message 9 of 25

batuhanozmen98
Enthusiast
Enthusiast

I also need FX table of OriginalPart

Also can you try to replace line 40 with:

oText.Text = slastPN

 

0 Likes
Message 10 of 25

mahesh_s493TE
Contributor
Contributor

Hi,

 

After modification the code, it is working fine., Thanks a lot.,

0 Likes
Message 11 of 25

batuhanozmen98
Enthusiast
Enthusiast

You are welcome

If this solved your problem, please click ACCEPT SOLUTION .

0 Likes
Message 12 of 25

mahesh_s493TE
Contributor
Contributor

Hi,

One more needed in this Topic,

I need to maintain text size height - 7 mm, after completion of program, the text size changed to 3.05 mm.

Initially in the OriginalPart section, text size is 7mm.

How will I maintain text size constant? any solution is there, kindly reply.

Thanks

0 Likes
Message 13 of 25

batuhanozmen98
Enthusiast
Enthusiast

the solution is you need to set FormattedText of textbox if you want to keep text properties of existing text.

 

oText.FormattedText = slastPN

 

0 Likes
Message 14 of 25

mahesh_s493TE
Contributor
Contributor

Hi,

 

After updating of codes, the text height remains kept as 3.05mm.

oText.FormattedText = slastPN

Any other settings is there? kindly reply.

 

 

0 Likes
Message 15 of 25

batuhanozmen98
Enthusiast
Enthusiast

Like I said If you set the text height of originalPart to 7mm setting it with formattedText will not effect the height

 

Also you can set the font size with this piece of code:

 

oText.Style.FontSize = 7.0
0 Likes
Message 16 of 25

mahesh_s493TE
Contributor
Contributor

Hi,

GoExcel.Open(sFileLoc, sNameSheet)
	Do
		
		slastPN = GoExcel.CellValue(sFileLoc, sNameSheet, "A" & i)
		If Not String.IsNullOrEmpty(slastPN) Then
			oText.Style.FontSize = 7.0
			oText.FormattedText = slastPN
			oPartDoc.Update()
			oPartDoc.SaveAs("C:\Users\ValBrid106\Documents\Project\valbrid\LVAC\NAME PLATE\" & slastPN & ".ipt", True)
		End If
		i += 1
	Loop While Not String.IsNullOrEmpty(slastPN)
	GoExcel.Close()
End Function

After updating of program, the text size remains as 3.05mm.,

How will I proceed further?

 

0 Likes
Message 17 of 25

mahesh_s493TE
Contributor
Contributor

Hi,

GoExcel.Open(sFileLoc, sNameSheet)
	Do
		
		slastPN = GoExcel.CellValue(sFileLoc, sNameSheet, "A" & i)
		If Not String.IsNullOrEmpty(slastPN) Then
			oText.Style.FontSize = 7.0
			oText.FormattedText = slastPN
			oPartDoc.Update()
			oPartDoc.SaveAs("C:\Users\ValBrid106\Documents\Project\valbrid\LVAC\NAME PLATE\" & slastPN & ".ipt", True)
		End If
		i += 1
	Loop While Not String.IsNullOrEmpty(slastPN)
	GoExcel.Close()
End Function

After updating of program, the text size remains as 3.05mm.,

How will I proceed further?

0 Likes
Message 18 of 25

batuhanozmen98
Enthusiast
Enthusiast

try to swap these lines:

oText.Style.FontSize = 7.0
oText.FormattedText = slastPN

like this:

oText.FormattedText = slastPN
oText.Style.FontSize = 7.0

 

0 Likes
Message 19 of 25

mahesh_s493TE
Contributor
Contributor

Hi,

slastPN = GoExcel.CellValue(sFileLoc, sNameSheet, "A" & i)
		If Not String.IsNullOrEmpty(slastPN) Then
			oText.FormattedText = slastPN
			oText.Style.FontSize = 7.0
			oPartDoc.Update()
			oPartDoc.SaveAs("C:\Users\ValBrid106\Documents\Project\valbrid\LVAC\NAME PLATE\" & slastPN & ".ipt", True)
		End If
		i += 1
	Loop While Not String.IsNullOrEmpty(slastPN)
	GoExcel.Close()
End Function

 After changed the codes & updating the program, the text size remains as 3.05mm.

What can I do?

0 Likes
Message 20 of 25

batuhanozmen98
Enthusiast
Enthusiast

At this point you may want to share some demo project that include your iLogic rule

0 Likes