Update a few things with AllReferencedDocuments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to update all ipt's in a assemblies. We have older files which we need to convert for vault.
They are 2012 ipt's and they have materials that arent good, older draftsman that don't work here anymore. Some iProperties need to be deleted.
In other words.... iLogic!
So. I have made rules for all individual things but now I want to combine it in one rule that I can unleash upon large assemblies.
How?
I thought of make a Sub Main() which iterates the .iam and for every ipt it calls a sub and does it's thing before moving to the next one.
I think I'm making a rookie mistake somwhere and I'm stuck.
I'll dump my code here first.
SyntaxEditor Code Snippet
Sub Main() 'Define the open document Dim openDoc As Document openDoc = ThisDoc.Document Dim docFile As Document 'kAssemblyDocumentObject = 12291 If openDoc.DocumentType = 12291 Then 'Iterate though the part files in the assembly For Each docFile In openDoc.AllReferencedDocuments 'kPartDocumentObject = 12290 If docFile.DocumentType = 12290 Then UpdateStylesStandards(docFile) DeleteParameters(docFile) UpdateiProperties(docFile) 'UpdateMaterials(docFile) UNFINNISHED Else MessageBox.Show("Something went wrong, probably a iam", "Error in Sub MAIN") End If Next Else End If iLogicVb.UpdateWhenDone = True End Sub Sub UpdateMaterials(docfile As Document) MessageBox.Show(docfile.FullFileName, "UpdateMaterials Name") 'test to see if I can call a ipt in an each loop. docfile = ThisApplication.ActiveDocument Dim i As Integer Dim oMaterial As String oMaterial = iProperties.Material If oMaterial = "1.4301" Then Try iProperties.Material = "1.4301-304" Catch i = i+1 End Try Else End If If oMaterial = "1.4401" Then Try iProperties.Material = "1.4401-316" Catch i = i+1 End Try Else End If If i > 1 Then MessageBox.Show("Mislukt. Ben je wel uitgecheckt?", "watwatwaaat?") End If iProperties.Material = "1.4301-304" ' End Sub Sub UpdateiProperties(docfile As Document) 'MessageBox.Show(docfile.FullFileName, "UpdateiProperties Name") End Sub Sub UpdateStylesStandards(docfile As Document) 'MessageBox.Show(docfile.FullFileName, "UpdateStylesStandards Name") End Sub Sub DeleteParameters(docfile As Document) 'MessageBox.Show(docfile.FullFileName, "DeleteParameters") docfile = ThisApplication.ActiveDocument MessageBox.Show(docfile.FullFileName, "UpdateMaterials Name") Dim param1 As Parameter Dim param2 As Parameter Dim param3 As Parameter Dim param4 As Parameter Try param1=docfile.ComponentDefinition.Parameters.Item("BREEDTE") param1.Delete param2=docfile.ComponentDefinition.Parameters.Item("LENGTE") param2.Delete param3=docfile.ComponentDefinition.Parameters.Item("DIKTE") param3.Delete param4=docfile.ComponentDefinition.Parameters.Item("DIAM") param4.Delete Catch End Try Try param1=docfile.ComponentDefinition.Parameters.Item("BREEDTE_1") param1.Delete param2=docfile.ComponentDefinition.Parameters.Item("DIAM_1") param2.Delete param3=docfile.ComponentDefinition.Parameters.Item("LENGTE_1") param3.Delete param4=docfile.ComponentDefinition.Parameters.Item("DIKTE_1") param4.Delete Catch End Try End Sub
So yes. I'm focussing on the Parameter one right now. Why doesn't it work?
I'm calling the ipt. I checked that it's active (I think) and I should be deleting the Parameters?
Anyone that can kick me in the right direction?
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
___________________________