Replacing multiple occurences


Hi all,

I've a problem by replacing multiple occurences in an assembly. One occurence works fine but the 2nd replacement throws an exception. Here my latest attemptSmiley Very Happyim objApp As SolidEdgeFramework.Application = NothingDim objDoc As SolidEdgeAssembly.AssemblyDocument = NothingDim objOccurrence As SolidEdgeAssembly.Occurrence = NothingDim objOccurrences As SolidEdgeAssembly.OccurrencesDim part1 As StringDim part2 As StringDim file_name As String ' start app objApp = CreateObject("SolidEdge.Application") For i = 0 To dgvTeile.Rows.Count - 2' read row valuespart1 = dgvTeile.Rows(i).Cells(1).Valuepart2 = dgvTeile.Rows(i).Cells(2).Valuefile_name = dgvTeile.Rows(i).Cells(0).Value ' open fileobjApp.Documents.Open(file_name)objDoc = objApp.ActiveDocumentobjOccurrences = objDoc.OccurrencesobjOccurrence = objOccurrences.Item(1)objOccurrence.Replace(NewOccurrenceFileName:=part1, ReplaceAll:=True)objOccurrence = objOccurrences.Item(1)objOccurrence.Replace(NewOccurrenceFileName:=part2, ReplaceAll:=True) ' save and close docobjDoc.Save()objDoc.Close()Next ' free objectsobjApp = NothingobjDoc = NothingobjPart = Nothing


Posted by: Markus Feder
Post date: 8/26/2009 3:37:42 AM


RE: Replacing multiple occurences

Hi cHobsen,


i see, you have Item(1) in the both replaces. Is this correct? However, try with objApp.DoIdle after replace.






Posted by: JR
Post date: 8/27/2009 11:59:35 PM

RE: Replacing multiple occurences

someone on eng-tips has a program to do this.


Posted by: HDS HDS
Post date: 9/1/2009 5:36:33 AM