Message 1 of 25
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
Solved! Go to Solution.