Community
HEllo,
I'm trying to update the Custom properties of an .iam according to its file name
Public Sub Tagnr() 'update custom prop "TAGNR" 'update Custom Parameter "TAGNR" 'according to name iam : projectNr...space tagnr PROJNR TCI.01.10 Dim invDocs As Documents Set invDocs = ThisApplication.Documents Dim invDoc As Document Set invDoc = ThisApplication.ActiveDocument Dim oSel As SelectSet Set oSel = invDoc.SelectSet On Error Resume Next If aSel.Count <> 1 Then MsgBox ("Please select only one assy to tag..") Exit Sub End If Dim oCoc As ComponentOccurrence Set oCoc = oSel.Item(1) Dim oParentOcc As ComponentOccurrence Set oParentOcc = oCoc.ParentOccurrence Dim bText As String Dim aText As String bText = oCoc.Name aText = oCoc.Name Dim oPos As Long oPos = InStr(bText, " ") bText = (Right(bText, (Len(bText) - oPos))) oPos = InStr(bText, ":") bText = (Left(bText, oPos - 1)) Dim i As Long Dim j As Long Dim OcFound As ComponentOccurrence i = 1 For Each oOcc In oParentOcc.SubOccurrences 'Debug.Print (invDocs.Item(i).DisplayName) If parOc Is oCoc Then j = i Set OcFound = oParentOcc.Definition.Occurrences(j) 'Debug.Print ("found it") Exit For End If i = i + 1 Next 'Debug.Print ("--" & j) Dim selDoc As Document Dim oProps As PropertySet Dim oProp As Property Set selDoc = invDocs.Item(j) Set aProps = selDoc.PropertySets("inventor User Defined Properties") For Each oProp In oProps Select Case custProp.Name Case "TAGNR" oProp.Value = bText End Select Next End Sub
But I can't find the way to make the link between the document.iam and the occurrence in the main .iam
any help would be greatly appreciated
Thanks