Reply

Occurance.replace works but Occurance.name is not updating

I am having a problem that seems to make no sense at all. I am running the below code to replace once part with another one using vb.net. This code works and the parts swap but the occurence name is not updated. If i swap the parts out manual the occurence name will update.

 

Problem code

Dim REPLACE_SS_BOLT As String = strNetworkLocation + "SOLID MODEL\031908-001_SCREW, WELD #8-32x.5.PAR"

For Each objOccurence In objDoc1.Occurrences
   strFilename = Split(objOccurence.Name, ".")
   If strFilename(0) = "031431-003 CAPSCW, " Then
      objOccurence.Replace(NewOccurrenceFileName:=REPLACE_SS_BOLT, ReplaceAll:=True)
      Exit For
   End If
Next

 Now i can fudge the occurance manually with this code but id'd like to understand why it is happen

 

Dim REPLACE_SS_BOLT As String = strNetworkLocation + "SOLID MODEL\031908-001_SCREW, WELD #8-32x.5.PAR"

For Each objOccurence In objDoc1.Occurrences
   strFilename = Split(objOccurence.Name, ".")
   strIndex = Split(objOccurance.name,":")
   If strFilename(0) = "031431-003 CAPSCW, " Then
      objOccurence.Replace(NewOccurrenceFileName:=REPLACE_SS_BOLT, ReplaceAll:=True)
      objOccurence.name = "031908-001_SCREW, WELD #8-32x.5.PAR:" + strIndex(1)
   End If
Next

 The only this that i can think is during the replace method and the part relantionships fail due to the part having different over all geometry(IE longer bolt) and the code is throwing an exception before the update occurance name happens.

 

Anyone else seen this problem?