Number plate Creation

Number plate Creation

mahesh_s493TE
Contributor Contributor
790 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)
791 Views
24 Replies
Replies (24)
Message 21 of 25

mahesh_s493TE
Contributor
Contributor

Hi, please find the Demo project fyr.

0 Likes
Message 22 of 25

mahesh_s493TE
Contributor
Contributor

Hi, anything is needed from myside.,

0 Likes
Message 23 of 25

mahesh_s493TE
Contributor
Contributor

Hi,

Anything needed from myside., I am sent the demo project.,

0 Likes
Message 24 of 25

batuhanozmen98
Enthusiast
Enthusiast
Accepted solution

Ok I think I find the solution. You need to override the style of formatted text when pushing. Fontsize is in cm so if you want 7mm you need to input 0,7

 

oText.FormattedText = "<StyleOverride FontSize='0,7' Bold='False'>" + slastPN + "</StyleOverride>"

  

0 Likes
Message 25 of 25

mahesh_s493TE
Contributor
Contributor

mahesh_s493TE_0-1750232048181.png

Hi, Thanks a lot, finally I got the solution given by you.,

The text size changed to 7 mm.

mahesh_s493TE_1-1750232136069.png