- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have tried countless revisions of my attached file, and I can not change the Custom Iproperty on all open documents.
I am using a 'For each Doc in ThisApplication.Documents.VisibleDocuments' followed by Doc.Activate
I am currently only running this on .ipt documents that are all in the current active project
If I use a messagebox to show the current Doc Name, my for loop is correctly cycling through each document
If i use the format iproperties.value(Doc, "Custom", FixProp) = FixVal it will correct the first open file only and no others
If I use the format iproperties.value("Custom", FixProp) = FixVal it will correct the current active file only
I have left all my attempts in my file, but just commented out so you can see what I have tried.
I am running this Code as an External Rule
Sub ApplyFix(FixType As String, FixProp As String, FixVal As String) Dim Doc As Inventor.Document 'Dim aDoc As Inventor.Document 'Dim ChkVal As String 'Dim Fail As Boolean 'Dim customPropertySet As Inventor.PropertySet For Each Doc In ThisApplication.Documents.VisibleDocuments Doc.Activate 'aDoc = ThisApplication.ActiveEditDocument 'customPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties") 'customPropertySet = Doc.PropertySets.Item("Inventor User Defined Properties") 'customPropertySet = aDoc.PropertySets.item("Inventor User Defined Properties") 'MessageBox.Show("Document: " & Doc.FullDocumentName,"BF56") Select Case FixType Case "iProp" Select Case FixProp Case "Finish" iProperties.Value(Doc, "Custom", FixProp) = FixVal 'iProperties.Value("Custom", FixProp) = FixVal ' Try ' Fail = False ' ChkVal = "" ' ChkVal = iProperties.Value(Doc, "Custom", FixProp) ' MessageBox.Show("ChkVal: " & ChkVal, Doc.FullDocumentName & " |BF67") ' iProperties.Value(Doc, "Custom", FixProp) = FixVal ' 'ChkVal = iProperties.Value(Doc, "Custom", FixProp) ' MessageBox.Show("FixVal: " & FixVal & vbCrLf & "ChkVal: " & ChkVal, Doc.FullDocumentName & " |BF70") ' 'If ChkVal <> FixVal Then Fail = True ' If FixVal <> iProperties.Value(Doc, "Custom", FixProp) Then Fail = True ' Catch ' Fail = True ' MessageBox.Show("Attempt set new" & vbCrLf & "FixProp: " & FixProp & " not found", "BF75" & Doc.FullDocumentName) ' 'Doc.PropertySets.Item("Inventor User Defined Properties").Add(FixVal, Inventor.PropertyTypeEnum.kCustomProperty, FixProp) ' End Try End Select ' If Fail Then ' 'MessageBox.Show("Attempt set new" & vbCrLf & "FixVal: " & FixVal & vbCrLf & "FixProp: " & FixProp,"Fail Trigger |BF80") ' 'Doc.PropertySets.Item("Inventor User Defined Properties").Add(FixVal, FixProp) ' 'ThisApplication.ActiveEditDocument.PropertySets.Item("Inventor User Defined Properties").Add(FixVal, FixProp) ' 'Doc.PropertySets.Item("Inventor User Defined Properties").Add("", FixProp) ' customPropertySet.Add("", FixProp) ' iProperties.Value(Doc, "Custom", FixProp) = FixVal ' MessageBox.Show("set new Pass" & vbCrLf & "FixVal: " & FixVal & vbCrLf & "File: " & aDoc.FullFileName, "Fail Trigger after set prop|BF86") ' ' End If End Select Next End Sub
Solved! Go to Solution.