Not applicable
08-19-2019
11:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
When i do a replace function with ilogic to change parts in several sub assemblies ilogic skips one assembly.
The first 3 assemblies work fine, only the 4th one is skipped.
when the code is run a second time the last assembly is modified.
Has this something to do with the capabilities of inventor?
for each replace inside a subassembly the code is copied, so i don't think this should be an error in inventor or ilogic.
I build in a counter so the code is run twice in one go, and then it works, but this shoudl be possible to do in one go i think.
Dim Ploc41 As String = ThisDoc.Path Dim oDoc41 As Document = ThisApplication.Documents.ItemByName(Ploc41 & "\4000-5050.iam") Dim oComps41 As ComponentOccurrences = oDoc41.ComponentDefinition.Occurrences For Each oComp41 As ComponentOccurrence In oComps41 If oComp41.Name.Contains("03-02516") Then Component.Replace(oComp41.Name, "C:\Workspace\Documents\Libraries\DMT-Library\New EU\03-Piping\02-Elbow 90°\03-02516" & DN_Header & ".ipt", True) Else If oComp41.Name.Contains("02-11540") Then Component.Replace(oComp41.Name, "C:\Workspace\Documents\Libraries\DMT-Library\New EU\02-Flanges\11-Weld-neck\02-11540" & DN_Header & ".ipt", True) End If Next Dim Ploc42 As String = ThisDoc.Path Dim oDoc42 As Document = ThisApplication.Documents.ItemByName(Ploc42 & "\4000-5000.iam") Dim oComps42 As ComponentOccurrences = oDoc42.ComponentDefinition.Occurrences For Each oComp42 As ComponentOccurrence In oComps42 If oComp42.Name.Contains("03-02516") Then Component.Replace(oComp42.Name, "C:\Workspace\Documents\Libraries\DMT-Library\New EU\03-Piping\02-Elbow 90°\03-02516" & DN_Header & ".ipt", True) Else If oComp42.Name.Contains("02-11540") Then Component.Replace(oComp42.Name, "C:\Workspace\Documents\Libraries\DMT-Library\New EU\02-Flanges\11-Weld-neck\02-11540" & DN_Header & ".ipt", True) End If Next Dim Ploc43 As String = ThisDoc.Path Dim oDoc43 As Document = ThisApplication.Documents.ItemByName(Ploc43 & "\4000-5010.iam") Dim oComps43 As ComponentOccurrences = oDoc43.ComponentDefinition.Occurrences For Each oComp43 As ComponentOccurrence In oComps43 If oComp43.Name.Contains("03-02516") Then Component.Replace(oComp43.Name, "C:\Workspace\Documents\Libraries\DMT-Library\New EU\03-Piping\02-Elbow 90°\03-02516" & DN_Header & ".ipt", True) Else If oComp43.Name.Contains("03-03516") Then Component.Replace(oComp43.Name, "C:\Workspace\Documents\Libraries\DMT-Library\New EU\03-Piping\03-Elbow 45°\03-03516" & DN_Header & ".ipt", True) Else If oComp43.Name.Contains("02-11540") Then Component.Replace(oComp43.Name, "C:\Workspace\Documents\Libraries\DMT-Library\New EU\02-Flanges\11-Weld-neck\02-11540" & DN_Header & ".ipt", True) End If Next Dim Ploc44 As String = ThisDoc.Path Dim oDoc44 As Document = ThisApplication.Documents.ItemByName(Ploc44 & "\4000-5060.iam") Dim oComps44 As ComponentOccurrences = oDoc44.ComponentDefinition.Occurrences For Each oComp44 As ComponentOccurrence In oComps44 If oComp44.Name.Contains("03-02516") Then Component.Replace(oComp44.Name, "C:\Workspace\Documents\Libraries\DMT-Library\New EU\03-Piping\02-Elbow 90°\03-02516" & DN_Header & ".ipt", True) Else If oComp44.Name.Contains("02-11540") Then Component.Replace(oComp44.Name, "C:\Workspace\Documents\Libraries\DMT-Library\New EU\02-Flanges\11-Weld-neck\02-11540" & DN_Header & ".ipt", True) End If Next iLogicVb.UpdateWhenDone = True
kind regards,
Geert
Solved! Go to Solution.
Link copied