11-06-2023
12:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-06-2023
12:59 AM
@WCrihfield @Curtis_Waguespack Thank you answering.
As i understand it, in order to use the 'iProperties.Value()' snippet i need:
- To use the 'Document.DisplayName'
- To have the partdocument be present in the referenced documents of the assembly i'm running my rule from
Point 2 remains a problem for me because there is no referenced documents present in my assembly file, the assembly file is simply an empty document with various iLogic codes i use.
How would i get oPartDoc to be referenced document of my assembly file, inside the code i already made?
Because the solution @Curtis_Waguespack offered already assumed that there's referenced documents present in my assembly (if i'm not wrong).
My Code;
Imports System.Windows.Forms
Sub main
Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oFD As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFD)
oFD.InitialDirectory = oOrigRefName
oFD.Filter = "Excel file (*.xlsx)|*.xlsx|"
oFD.CancelError = True
On Error Resume Next
oFD.ShowOpen()
If Err.Number <> 0 Then
Return
ElseIf oFD.FileName <> "" Then
selectedfile = oFD.FileName
End If
Dim oExcel As String = selectedfile
Dim i As Integer = 3
Dim PartFileLoc As String = GoExcel.CellValue(oExcel, "Blad1", "A" & i)
If PartFileLoc = "" Then
MsgBox("Geen PartFileLoc gevonden in cell: A" & i)
Exit Sub
End If
Do While PartFileLoc <> ""
Dim oPartDoc As PartDocument = ThisApplication.Documents.Open(PartFileLoc, True)
oPartDoc.Activate
For Each rDoc As Document In oDoc.AllReferencedDocuments
msgBox(rDoc.FullDocumentName)
Next
Dim n As Integer
Dim nRow As Integer = 2
For n = 1 To 26
oLetter = Mid("ABCDEFGHIJKLMNOPQRSTUVWXYZ", n, 1)
oCellAddress = oLetter & nRow
oCellValue = GoExcel.CellValue(oCellAddress)
GoExcel.TitleRow = nRow
oColumnName = GoExcel.CellValue(oLetter & nRow)
If oColumnName <> ""
Dim oProperty As String = oColumnName
Dim oPropertyType As String = GoExcel.CellValue(oLetter & 1)
Dim oSetValue As String = GoExcel.CellValue(oExcel, "Blad1", oLetter & i)
iProperties.Value(oPartDoc.DisplayName, oPropertyType, oProperty) = oSetValue
End If
Next
i = i + 1
PartFileLoc = GoExcel.CellValue("A" & i)
oPartDoc.Save()
'oPartDoc.Close
Loop
End Sub